Skip to main content

Module ina219

Module ina219 

Source
Expand description

Texas Instruments INA219 high-side current, voltage, and power monitor.

The INA219 measures the voltage across a shunt resistor and the bus voltage, and, once its calibration register is programmed, computes current and power on the chip. This module builds the calibration value and decodes each register into a physical quantity, following the datasheet’s equations and its worked design example, so a solar-battery or microgrid node reads amps and watts directly.

Currents, voltages, and powers are returned in integer micro-units (microvolts, microamps, microwatts) so the conversions stay exact without floating point.

Modules§

register
The INA219 register addresses.

Constants§

CONFIG_RESET
The power-on value of the configuration register (0x399F): 32 V bus range, gain /8, 12-bit ADCs, and continuous shunt-and-bus conversion.

Functions§

bus_millivolts
Decodes the bus voltage register to millivolts.
bus_register
Builds the bus voltage register a monitor reports for a bus voltage.
calibration
Computes the calibration register value for a chosen current resolution and shunt.
conversion_ready
Returns whether the bus voltage register’s conversion-ready (CNVR) flag is set.
current_microamps
Decodes the current register to microamps for a given current LSB.
current_register
Builds the current register a monitor reports for a current.
math_overflow
Returns whether the bus voltage register’s math-overflow (OVF) flag is set.
minimum_current_lsb_microamps
Returns the smallest current LSB, in microamps, that still spans a full-scale current.
power_microwatts
Decodes the power register to microwatts for a given current LSB.
power_register
Builds the power register a monitor reports for a power.
shunt_microvolts
Decodes the shunt voltage register to microvolts.
shunt_register
Builds the shunt voltage register a monitor reports for a shunt voltage.