|
ProtoCore v1.0.16
Deterministic, zero-heap network stack for embedded targets
|
TI INA219 high-side current / power monitor codec (PROTOCORE_ENABLE_INA219). More...
#include "protocore_config.h"Go to the source code of this file.
TI INA219 high-side current / power monitor codec (PROTOCORE_ENABLE_INA219).
The INA219 measures the voltage across a shunt resistor (LSB 10 uV) and the bus voltage (LSB 4 mV, in the upper 13 bits of its register), and - once a calibration value derived from the shunt resistance and a chosen current LSB is programmed - reports current and power directly. From those you get how much current and power a circuit draws.
This codec is pure and host-tested: ::protocore_ina219_bus_mv / ::protocore_ina219_shunt_uv decode the voltage registers, ::protocore_ina219_calibration computes the calibration register, and ::protocore_ina219_current_ua / ::protocore_ina219_power_uw scale the raw current / power registers by the current LSB. On an ESP32 the binding programs the calibration + config and reads the registers over I2C (Wire); only that touches hardware.
A cheap solder-and-bench-test breakout: put it in series with a load and watch the current.
Definition in file ina219.h.