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.
Re-exports§
pub use crate::ina226::AddressPin;
Modules§
Structs§
- Configuration
- The Configuration register (00h).
- Ina219
- An INA219 on an I2C bus, measuring shunt and bus voltage, current, and power on demand.
- Reading
- One set of results, with the current resolution they were taken at.
Enums§
- Adc
- An ADC resolution or averaging setting, for the
BADCandSADCfields. - BusRange
- The bus voltage full-scale range, the
BRNGbit of the Configuration register. - Gain
- The shunt voltage gain and range, the
PGbits of the Configuration register. - Mode
- The operating mode, the
MODEbits of the Configuration register.
Constants§
- BASE_
ADDRESS - The I2C address with both address pins tied to GND; A1 and A0 select the rest.
- 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.
- STATUS_
POLLS - How many times the Bus Voltage register is polled, 1 ms apart, after the conversion time has elapsed before the conversion is called overdue.
Functions§
- address
- Returns the 7-bit I2C address the A1 and A0 pins select.
- 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.