INA226 current and power monitor
The TI INA226 measures current through a real 0.1 ohm shunt, the bus voltage and the power, to 2.5 microvolts, over I2C.
Aliases: CJMCU-226, INA226 module, power meter, current sensor. It is the INA219's more precise sibling, with a bus voltage pin of its own and an alert pin, and the sensor of battery monitors and solar chargers.
Pins
| Pin | What it does |
|---|---|
VCC, GND |
Supply, 2.7 to 5.5 V. |
SCL, SDA |
I2C. The board carries the pull-ups. |
ALERT |
Pulls low on the alert chosen in mask/enable. |
VBUS |
The bus voltage input: tie it to the load's supply side. |
IN+, IN- |
The two ends of the 0.1 ohm shunt, in series with the load. |
Properties
address, 0x40 to 0x4F. There is nothing to drag: the current is whatever the circuit
puts through the shunt.
Reading it on an Arduino
With Rob Tillaart's library, which Mokxi ships as INA226.h:
#include "INA226.h"
INA226 INA(0x40);
void setup() {
Serial.begin(9600);
Wire.begin();
INA.begin();
INA.setMaxCurrentShunt(0.8, 0.1);
}
void loop() {
Serial.print(INA.getBusVoltage(), 3);
Serial.print(" V ");
Serial.print(INA.getCurrent_mA(), 1);
Serial.println(" mA");
delay(1000);
}
Wolfgang Ewald's INA226_WE.h reads it too.
How it talks
Sixteen-bit registers: 0x00 configuration (averaging and conversion times), 0x01 the
shunt at 2.5 uV a count, 0x02 the bus at 1.25 mV, 0x03 power, 0x04 current, 0x05
calibration (current and power read zero until it is written), 0x06 mask/enable with
the conversion ready flag, 0x07 the alert limit, 0xFE 0x5449 and 0xFF 0x2260. A
conversion takes 2.2 ms by default, times the averaging count.
What it does not model
The noise that averaging removes, and the SMBus alert response.
Common mistakes
Leaving VBUS unconnected: the bus voltage and power read zero. Expecting current
before the calibration is written: every library writes it in its setup call.