An open API service indexing awesome lists of open source software.

https://github.com/berndporr/rpi_ads1115

ADS1115 Raspberry PI API using C++ callbacks. In contrast to unprecise getters this class hands over the data at a given sampling rate via a callback handler.
https://github.com/berndporr/rpi_ads1115

callback-api cpp cpp-library real-time realtime

Last synced: about 1 month ago
JSON representation

ADS1115 Raspberry PI API using C++ callbacks. In contrast to unprecise getters this class hands over the data at a given sampling rate via a callback handler.

Awesome Lists containing this project

README

        

# Data acquisition with the ADS1115 on the Raspberry PI with callback handlers

![alt tag](ads1115.jpg)

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.* Without this connection this driver
won't work. The ALERT/RDY pin wakes up a thread when a sample is available
which then calls the callback interface with the sample value.

## Prerequisites

apt-get install cmake
apt-get install libgpiod-dev

## Building:

To build:

cmake .

make

## Install

sudo make install

## Usage examples

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.

## General usage

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.

### Start the data acquisition:
```
myAD7705comm.start(settings)
```

### Receiving data
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.

### Stop the data acquisition:
```
myAD7705comm.stop();
```

## Author: Bernd Porr

- [email protected]
- [email protected]
- www.berndporr.me.uk