ina3221
Embedded driver for the INA3221 triple-channel power monitor in Rust.
The INA3221 is very similar to the classic INA219 power monitor IC.
Compatibility
Any board that supports embedded-hal blocking 1.0 I2c should be compatible with this library.
NOTE: Some HALs require feature flagging to enable 1.0 functionality, for example esp-hal requires the eh1 feature.
Installation
You can add via crates.io:
$ cargo add ina3221
NOTE: Some HALs require feature flagging to enable 1.0 functionality, for example esp-hal requires the eh1 feature.
Documentation
You can find the documentation here.
Example
This example assumes a 0.1 Ohm shunt resistor for current and power calculations.
const INA3221_I2C_ADDR: u8 = 0x40;
const SHUNT_RESISTANCE: f32 = 0.1f32; // 0.1 Ohm
use INA3221;
Output
This is sample output powering an Arduino Uno R3 over USB, running the blinky script.
Channel 1: load = 5.212 V, current = 36.800 mA, power = 191.790 mW
Channel 1: load = 5.211 V, current = 33.600 mA, power = 175.102 mW
Channel 1: load = 5.212 V, current = 36.800 mA, power = 191.790 mW
Channel 1: load = 5.219 V, current = 34.000 mA, power = 177.460 mW
Channel 1: load = 5.212 V, current = 36.800 mA, power = 191.790 mW
Channel 1: load = 5.211 V, current = 34.000 mA, power = 177.188 mW
Channel 1: load = 5.211 V, current = 34.000 mA, power = 177.188 mW
Channel 1: load = 5.212 V, current = 36.400 mA, power = 189.704 mW
Channel 1: load = 5.211 V, current = 34.000 mA, power = 177.188 mW
Channel 1: load = 5.212 V, current = 36.800 mA, power = 191.790 mW
Channel 1: load = 5.211 V, current = 34.000 mA, power = 177.188 mW