ADS1115
An Elixir library for interacting with ADS1115 and ADS1015 analog-to-digital chips. Please see the datasheet for details.
Usage
I'm using these chips to read moisture sensors.
I wired the analog signal to AIN0
and I want to compare that to GND
.
For this use-case I can do the following:
{:ok, ref} = I2C.open("i2c-1")
addr = 72 # the default i2c address for my sensor
{:ok, reading} = ADS1115.single_shot_read(ref, addr, {:ain0, :gnd})
# reading will be between -32,768 and 32,767
You can similarly use this library to interact with ADS1015 chips like this:
{:ok, ref} = I2C.open("i2c-1")
addr = 72 # the default i2c address for my sensor
{:ok, reading} = ADS1015.single_shot_read(ref, addr, {:ain0, :gnd})
Installation
If available in Hex, the package can be installed
by adding ads1115
to your list of dependencies in mix.exs
:
def deps do
[
{:ads1115, "~> 0.1"}
]
end
Documentation can be generated with ExDoc and published on HexDocs. Once published, the docs can be found at https://hexdocs.pm/ads1115.