By Blake Felt - [email protected]
A component for TI ADS1115 on ESP-IDF. For an example, see https://github.com/Molorius/ESP32-Examples.
To add to a project, type:
git submodule add https://github.com/Molorius/esp32-ads1115.git components/ads1115
into the base directory of your project.
The datasheet can be found here.
This has not been tested with more than one ADS1115 connected. Any suggestions or fixes are gladly appreciated.
The different multiplexer options on the ADS1115.
Values
ADS1115_MUX_0_1
: Connect pins 0 and 1.ADS1115_MUX_0_3
: Connect pins 0 and 3.ADS1115_MUX_1_3
: Connect pins 1 and 3.ADS1115_MUX_2_3
: Connect pins 2 and 3.ADS1115_MUX_0_GND
: Connect pin 0 to ground.ADS1115_MUX_1_GND
: Connect pin 1 to ground.ADS1115_MUX_2_GND
: Connect pin 2 to ground.ADS1115_MUX_3_GND
: Connect pin 3 to ground.
The different full-scale resolution options.
Values
ADS1115_FSR_6_144
: 6.144 voltsADS1115_FSR_4_096
: 4.096 voltsADS1115_FSR_2_048
: 2.048 voltsADS1115_FSR_1_024
: 1.024 voltsADS1115_FSR_0_512
: 0.512 voltsADS1115_FSR_0_256
: 0.256 volts
The different samples per second, or data rate, options.
Values
ADS1115_SPS_8
: 8 samples per secondADS1115_SPS_16
: 16 samples per secondADS1115_SPS_32
: 32 samples per secondADS1115_SPS_64
: 64 samples per secondADS1115_SPS_128
: 128 samples per secondADS1115_SPS_250
: 250 samples per secondADS1115_SPS_475
: 475 samples per secondADS1115_SPS_860
: 860 samples per second
Continuous or single-shot mode.
Values
ADS1115_MODE_CONTINUOUS
: continuous mode.ADS1115_MODE_SINGLE
: single-shot mode.
Setup of the device.
Parameters
i2c_port
: the i2c bus number.address
: the device's i2c address.
Returns
- The configuration file, which is passed to all subsequent functions.
Notes
- This does not setup the i2c bus, this must be done before passing to this function.
Sets up an optional data-ready pin to verify when conversions are complete. Connect to ALRT/RDY pin on ADS1115.
Parameters
ads
: The configuration file.gpio
: The esp32 gpio. Do not setup beforehand.
Sets the pins to be multiplexed.
Parameters
ads
: the configuration file.mux
: the desired multiplex option (see enumeration).
Sets the full-scale range, or the programmable-gain amplifier.
Parameters
ads
: the configuration file.fsr
: the desired full-scale range option (see enumeration).
Sets the read mode.
Paremeters
ads
: the configuration file.mode
: the desired mode (see enumeration).
Notes
- To end continuous mode, set it to single-shot mode and make one voltage read.
Sets the sampling speed.
Parameters
ads
: the configuration file.sps
: the desired samples per second (see enumeration).
Sets the maximum wait ticks for the i2c reads and writes. See the i2c documentation.
Parameters
ads
: the configuration file.max_ticks
: maximum wait ticks.
Reads the voltage based on the current configuration.
Parameters
ads
: the configuration file.
Returns
- The 16 bit raw voltage value directly from the ADS1115.
Reads the voltage based on the current configuration.
Parameters
ads
: the configuration file.
Returns
- The voltage, based on the current full-scale range. This is just a conversion from the raw value.