ModularSensors > Files > sensors / TIINA219.h

TIINA219.h file

Contains the TIINA219 sensor subclass and the variale subclasses TIINA219_Current, TIINA219_Volt, and TIINA219_Power.

These are for the Texas Instruments INA219 current/voltage sensor.

This depends on the Adafruit INA219 Library

Classes

class TIINA219
The Sensor sub-class for the TexasInstruments INA219 sensor.
class TIINA219_Current
The Variable sub-class used for the current output from a TI INA219 power and current monitor.
class TIINA219_Volt
The Variable sub-class used for the bus voltage output from a TI INA219 power and current monitor.
class TIINA219_Power
The Variable sub-class used for the power use output calculated from the voltage and current measured by a TI INA219 power and current monitor.

Defines

#define INA219_NUM_VARIABLES = 3
Sensor::_numReturnedValues; the INA219 can report 3 values.
#define INA219_ADDRESS_BASE = 0x40
The default address of the INA219.

Sensor Timing

The sensor timing for a TI INA219

#define INA219_WARM_UP_TIME_MS = 100
Sensor::_warmUpTime_ms; the INA219 warms up in 100ms.
#define INA219_STABILIZATION_TIME_MS = 4000
Sensor::_stabilizationTime_ms; the INA219 is stable after 4000ms.
#define INA219_MEASUREMENT_TIME_MS = 1100
Sensor::_measurementTime_ms; the INA219 takes 1100ms to complete a measurement.

Current

The current variable from a TI INA219

  • Range is between +/-0.4 Amps and +/-3.2 Amps
  • Absolute accuracy is range dependent, and approx 2LSB (R accuracy unknown)

TIINA219_Current(TIINA219* parentSense, const char* uuid = "", const char* varCode = INA219_CURRENT_MA_DEFAULT_CODE) explicit

Construct a new TIINA219_Current object.

Parameters
parentSense The parent TIINA219 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 "TIINA219Amp".

#define INA219_CURRENT_MA_RESOLUTION = 1
Decimals places in string representation; current should have 1.
#define INA219_CURRENT_MA_VAR_NUM = 0
Sensor variable number; current is stored in sensorValues[0].
#define INA219_CURRENT_MA_VAR_NAME = "electricCurrent"
Variable name in ODM2 controlled vocabulary; "electricCurrent".
#define INA219_CURRENT_MA_UNIT_NAME = "milliamp"
Variable unit name in ODM2 controlled vocabulary; "milliamp".
#define INA219_CURRENT_MA_DEFAULT_CODE = "TIINA219Amp"
Default variable short code; "TIINA219Amp".

Bus Voltage

The bus voltage variable from a TI INA219

  • Range is 0 to 26V
  • Accuracy is ±4mV (1 LSB step size)

TIINA219_Volt(TIINA219* parentSense, const char* uuid = "", const char* varCode = INA219_BUS_VOLTAGE_DEFAULT_CODE) explicit

Construct a new TIINA219_Volt object.

Parameters
parentSense The parent TIINA219 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 "TIINA219Volt".

#define INA219_BUS_VOLTAGE_RESOLUTION = 3
Decimals places in string representation; bus voltage should have 4 - resolution is 0.001V.
#define INA219_BUS_VOLTAGE_VAR_NUM = 1
Sensor variable number; bus voltage is stored in sensorValues[1].
#define INA219_BUS_VOLTAGE_VAR_NAME = "voltage"
Variable name in ODM2 controlled vocabulary; "voltage".
#define INA219_BUS_VOLTAGE_UNIT_NAME = "volt"
Variable unit name in ODM2 controlled vocabulary; "volt".
#define INA219_BUS_VOLTAGE_DEFAULT_CODE = "TIINA219Volt"
Default variable short code; "TIINA219Volt".

Power

The power variable from a TI INA219

TIINA219_Power(TIINA219* parentSense, const char* uuid = "", const char* varCode = INA219_POWER_MW_DEFAULT_CODE) explicit

Construct a new TIINA219_Power object.

Parameters
parentSense The parent TIINA219 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 "TIINA219Power".

#define INA219_POWER_MW_RESOLUTION = 2
Decimals places in string representation; power draw should have 2 - resolution is 0.01mW.
#define INA219_POWER_MW_VAR_NUM = 2
Sensor variable number; power draw is stored in sensorValues[2].
#define INA219_POWER_MW_VAR_NAME = "electricPower"
Variable name in ODM2 controlled vocabulary; "electricPower".
#define INA219_POWER_MW_UNIT_NAME = "milliwatt"
Variable unit name in ODM2 controlled vocabulary; "milliwatt".
#define INA219_POWER_MW_DEFAULT_CODE = "TIINA219Power"
Default variable short code; "TIINA219Power".