Adafruit ADS1X15 ADC Driver Library
Public Member Functions | Protected Attributes | List of all members
Adafruit_ADS1X15 Class Reference

Sensor driver for the Adafruit ADS1X15 ADC breakouts. More...

#include <Adafruit_ADS1X15.h>

Inheritance diagram for Adafruit_ADS1X15:
Adafruit_ADS1015 Adafruit_ADS1115

Public Member Functions

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...
 

Protected Attributes

Adafruit_I2CDevice * m_i2c_dev
 I2C bus device.
 
uint8_t m_bitShift
 bit shift amount
 
adsGain_t m_gain
 ADC gain.
 
uint16_t m_dataRate
 Data rate.
 

Detailed Description

Sensor driver for the Adafruit ADS1X15 ADC breakouts.

Member Function Documentation

◆ begin()

bool Adafruit_ADS1X15::begin ( uint8_t  i2c_addr = ADS1X15_ADDRESS,
TwoWire *  wire = &Wire 
)

Sets up the HW (reads coefficients values, etc.)

Parameters
i2c_addrI2C address of device
wireI2C 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
channelADC 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
channelADC channel to use
thresholdcomparator 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
countsthe 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
gaingain setting to use

◆ getGain()

adsGain_t Adafruit_ADS1X15::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
ratethe data rate to use

◆ 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
muxmux field value
continuouscontinuous 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: