The ADS1115 is a sigma delta converter which has a PGA and a programmable sampling rate from 8Hz..860Hz. It's perfect for slowly changing inputs such as pressure, temperature, heart rate etc.
This repo offers the class ADS1115rpi
which manages the
communication between the ADS1115 and the client who just needs to
implement the callback hasSample(float sample)
which is then called
at the requested sampling rate.
The class uses the ALERT/RDY pin of the ADS1115 connected to GPIO 17 to establish the sampling rate.
apt-get install cmake
apt-get install libgpiod-dev
To build:
cmake .
make
sudo make install
Data printer: In the subdir example
is a simple application which prints
the ADC data to the screen or you can pipe it into a file.
cd example
./ads1115_printer
Data plotter: In the subdir qwt-plot
is a simple QT plotting application.
The online doc is here: https://berndporr.github.io/rpi_ads1115/
You need to overload the abstract callback handler: virtual void hasSample(float v) { };
with the functionality you'd like it to
do. You can switch the input channel within the callback handler to cycle
through different inputs.
myAD7705comm.start(settings)
Once start
has been called hasSample
will be called at the
specified sampling rate.
You can switch to another channel inside the callback handler by
calling setChannel (ADS1115settings::Input channel)
and then cycle
through the channels. You might need to let the ADC settle to the
next channel so it's recommended to read every channel twice and
then discard the 1st callback event after having switched the channel.
myAD7705comm.stop();