ModularSensors > Files > sensors / ExternalVoltage.h

ExternalVoltage.h file

This file contains the ExternalVoltage sensor subclass and the ExternalVoltage_Volt variable subclass.

  • These are used for any voltage measureable on a TI ADS1115 or ADS1015. There is a multiplier allowed for a voltage divider between the raw voltage and the ADS.

This depends on the soligen2010 fork of the Adafruit ADS1015 library.


class ExternalVoltage
The Sensor sub-class for the external votlage as measured by TI ADS1115 or ADS1015.
class ExternalVoltage_Volt
The Variable sub-class used for the voltage output from a TI ADS1115 or ADS1015.


Sensor::_numReturnedValues; the ADS1115 can report 1 value.
#define ADS1115_ADDRESS = 0x48
The assumed address of the ADS1115, 1001 000 (ADDR = GND)

Sensor Timing

The sensor timing for a TI ADS1x15 analog-to-digital converter (ADC) The timing used for simple external voltage measurements is that of the ADS1x15.

Sensor::_warmUpTime_ms; the ADS1115 warms up in 2ms.
Sensor::_stabilizationTime_ms; the ADS1115 is stable 0ms after warm-up.
Sensor::_measurementTime_ms; the ADS1115 completes 860 conversions per second, but the wait for the conversion to complete is built into the underlying library, so we do not need to wait further here.


The volt variable from a TI ADS1x15 analog-to-digital converter (ADC)

  • Range:
    • without voltage divider: 0 - 3.6V [when ADC is powered at 3.3V]
    • 1/gain = 3x: 0.3 ~ 12.9V
    • 1/gain = 10x: 1 ~ 43V
  • Accuracy:
    • 16-bit ADC (ADS1115): < 0.25% (gain error), <0.25 LSB (offset errror)
    • 12-bit ADC (ADS1015, using build flag MS_USE_ADS1015): < 0.15% (gain error), <3 LSB (offset errror)
  • Resolution:
    • 16-bit ADC (ADS1115):
    • 12-bit ADC (ADS1015, using build flag MS_USE_ADS1015):

ExternalVoltage_Volt(ExternalVoltage* parentSense, const char* uuid = "", const char* varCode = EXT_VOLTAGE_DEFAULT_CODE) explicit

Construct a new ExternalVoltage_Volt object.

parentSense The parent ExternalVoltage providing the result values.
uuid A universally unique identifier (UUID or GUID) for the variable; optional with the default value of an empty string.
varCode A short code to help identify the variable in files; optional with a default value of "extVoltage".

Variable number; voltage is stored in sensorValues[0].
#define EXT_VOLTAGE_VAR_NAME = "voltage"
Variable name in ODM2 controlled vocabulary; "voltage".
#define EXT_VOLTAGE_UNIT_NAME = "volt"
Variable unit name in ODM2 controlled vocabulary; "volt".
#define EXT_VOLTAGE_DEFAULT_CODE = "extVoltage"
Default variable short code; "extVoltage".
Decimals places in string representation; voltage should have 4.