Sensor driver for the Adafruit ADS1X15 ADC breakouts.
More...
#include <Adafruit_ADS1X15.h>
|
bool | begin (uint8_t i2c_addr=ADS1X15_ADDRESS, TwoWire *wire=&Wire) |
| Sets up the HW (reads coefficients values, etc.) More...
|
|
int16_t | readADC_SingleEnded (uint8_t channel) |
| Gets a single-ended ADC reading from the specified channel. More...
|
|
int16_t | readADC_Differential_0_1 () |
| Reads the conversion results, measuring the voltage difference between the P (AIN0) and N (AIN1) input. Generates a signed value since the difference can be either positive or negative. More...
|
|
int16_t | readADC_Differential_0_3 () |
| Reads the conversion results, measuring the voltage difference between the P (AIN0) and N (AIN3) input. Generates a signed value since the difference can be either positive or negative. More...
|
|
int16_t | readADC_Differential_1_3 () |
| Reads the conversion results, measuring the voltage difference between the P (AIN1) and N (AIN3) input. Generates a signed value since the difference can be either positive or negative. More...
|
|
int16_t | readADC_Differential_2_3 () |
| Reads the conversion results, measuring the voltage difference between the P (AIN2) and N (AIN3) input. Generates a signed value since the difference can be either positive or negative. More...
|
|
void | startComparator_SingleEnded (uint8_t channel, int16_t threshold) |
| Sets up the comparator to operate in basic mode, causing the ALERT/RDY pin to assert (go from high to low) when the ADC value exceeds the specified threshold. More...
|
|
int16_t | getLastConversionResults () |
| In order to clear the comparator, we need to read the conversion results. This function reads the last conversion results without changing the config value. More...
|
|
float | computeVolts (int16_t counts) |
| Compute volts for the given raw counts. More...
|
|
void | setGain (adsGain_t gain) |
| Sets the gain and input voltage range. More...
|
|
adsGain_t | getGain () |
| Gets a gain and input voltage range. More...
|
|
void | setDataRate (uint16_t rate) |
| Sets the data rate. More...
|
|
uint16_t | getDataRate () |
| Gets the current data rate. More...
|
|
void | startADCReading (uint16_t mux, bool continuous) |
| Non-blocking start conversion function. More...
|
|
bool | conversionComplete () |
| Returns true if conversion is complete, false otherwise. More...
|
|
Sensor driver for the Adafruit ADS1X15 ADC breakouts.
◆ begin()
bool Adafruit_ADS1X15::begin |
( |
uint8_t |
i2c_addr = ADS1X15_ADDRESS , |
|
|
TwoWire * |
wire = &Wire |
|
) |
| |
Sets up the HW (reads coefficients values, etc.)
- Parameters
-
i2c_addr | I2C address of device |
wire | I2C bus |
- Returns
- true if successful, otherwise false
◆ readADC_SingleEnded()
int16_t Adafruit_ADS1X15::readADC_SingleEnded |
( |
uint8_t |
channel | ) |
|
Gets a single-ended ADC reading from the specified channel.
- Parameters
-
channel | ADC channel to read |
- Returns
- the ADC reading
◆ readADC_Differential_0_1()
int16_t Adafruit_ADS1X15::readADC_Differential_0_1 |
( |
| ) |
|
Reads the conversion results, measuring the voltage difference between the P (AIN0) and N (AIN1) input. Generates a signed value since the difference can be either positive or negative.
- Returns
- the ADC reading
◆ readADC_Differential_0_3()
int16_t Adafruit_ADS1X15::readADC_Differential_0_3 |
( |
| ) |
|
Reads the conversion results, measuring the voltage difference between the P (AIN0) and N (AIN3) input. Generates a signed value since the difference can be either positive or negative.
- Returns
- the ADC reading
◆ readADC_Differential_1_3()
int16_t Adafruit_ADS1X15::readADC_Differential_1_3 |
( |
| ) |
|
Reads the conversion results, measuring the voltage difference between the P (AIN1) and N (AIN3) input. Generates a signed value since the difference can be either positive or negative.
- Returns
- the ADC reading
◆ readADC_Differential_2_3()
int16_t Adafruit_ADS1X15::readADC_Differential_2_3 |
( |
| ) |
|
Reads the conversion results, measuring the voltage difference between the P (AIN2) and N (AIN3) input. Generates a signed value since the difference can be either positive or negative.
- Returns
- the ADC reading
◆ startComparator_SingleEnded()
void Adafruit_ADS1X15::startComparator_SingleEnded |
( |
uint8_t |
channel, |
|
|
int16_t |
threshold |
|
) |
| |
Sets up the comparator to operate in basic mode, causing the ALERT/RDY pin to assert (go from high to low) when the ADC value exceeds the specified threshold.
This will also set the ADC in continuous conversion mode.
- Parameters
-
channel | ADC channel to use |
threshold | comparator threshold |
◆ getLastConversionResults()
int16_t Adafruit_ADS1X15::getLastConversionResults |
( |
| ) |
|
In order to clear the comparator, we need to read the conversion results. This function reads the last conversion results without changing the config value.
- Returns
- the last ADC reading
◆ computeVolts()
float Adafruit_ADS1X15::computeVolts |
( |
int16_t |
counts | ) |
|
Compute volts for the given raw counts.
- Parameters
-
counts | the ADC reading in raw counts |
- Returns
- the ADC reading in volts
◆ setGain()
void Adafruit_ADS1X15::setGain |
( |
adsGain_t |
gain | ) |
|
Sets the gain and input voltage range.
- Parameters
-
◆ getGain()
Gets a gain and input voltage range.
- Returns
- the gain setting
◆ setDataRate()
void Adafruit_ADS1X15::setDataRate |
( |
uint16_t |
rate | ) |
|
Sets the data rate.
- Parameters
-
◆ getDataRate()
uint16_t Adafruit_ADS1X15::getDataRate |
( |
| ) |
|
Gets the current data rate.
- Returns
- the data rate
◆ startADCReading()
void Adafruit_ADS1X15::startADCReading |
( |
uint16_t |
mux, |
|
|
bool |
continuous |
|
) |
| |
Non-blocking start conversion function.
Call getLastConversionResults() once conversionComplete() returns true. In continuous mode, getLastConversionResults() will always return the latest result. ALERT/RDY pin is set to RDY mode, and a 8us pulse is generated every time new data is ready.
- Parameters
-
mux | mux field value |
continuous | continuous if set, otherwise single shot |
◆ conversionComplete()
bool Adafruit_ADS1X15::conversionComplete |
( |
| ) |
|
Returns true if conversion is complete, false otherwise.
- Returns
- True if conversion is complete, false otherwise.
The documentation for this class was generated from the following files: