Part

Power monitor, INA226

Current, bus voltage and power through a real 0.1 ohm shunt, 2.5 uV a count, over I2C.

See every part
  • 8 pins
  • 1 setting
  • In 1 project
Drawn live by the editor's own code, at the size you see it.
Power monitor, INA226 as drawn in the Mokxi simulator
At a glance

The Power monitor, INA226 in brief

What it is, and every setting the properties panel gives it.

The INA226 is TI’s current and power monitor, the more precise sibling of the INA219. It measures the voltage across a shunt resistor to 2.5 microvolts, the bus voltage on a pin of its own and the power, and reports them over I2C. On the common CJMCU-226 board the shunt is a real 0.1 ohm resistor between IN+ and IN-, in series with the load, and VBUS is tied to the load’s supply side. Mokxi models the sixteen-bit registers: the configuration, the shunt at 2.5 microvolts a count, the bus at 1.25 millivolts, power, current, the calibration, the mask and enable with its conversion-ready flag, and the alert limit, plus the two ID registers. Current and power read zero until the calibration is written, which every library does in its setup call. A conversion takes 2.2 ms by default, times the averaging count. Rob Tillaart’s INA226.h and INA226_WE.h both read it. The noise that averaging removes and the SMBus alert response are not modeled.

Family
Sensors
Pins
8
address
64
Pins

8 pins

Named as the editor names them, so a wire lands where you expect it.

Pin
What it does
VCC
Supply, 2.7 to 5.5 V.
GND
Ground.
SCL
I2C. The board carries the pull-ups.
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+
The two ends of the 0.1 ohm shunt, in series with the load.
IN-
The two ends of the 0.1 ohm shunt, in series with the load.
How to use it

How to read an INA226 current and power monitor

The built-in project watches a 12 V lamp on one INA226 and a 5 V load on an INA3221, both on one I2C bus. For the INA226, VCC takes 5 V and GND, SDA and SCL go to the Uno’s bus, and the load is wired through the shunt: the 12 V supply to IN+, then IN- to the lamp and the lamp to ground. VBUS goes to the supply side of the load, which is how the chip reads the rail’s own voltage. The address is 0x40.

The sketch uses Rob Tillaart’s library: INA226 rail12(0x40), then begin() and setMaxCurrentShunt(0.8, 0.1), 0.8 A of expected maximum and the 0.1 ohm shunt. That call writes the calibration register, which is why it matters: until it is written, current and power read zero. After that getBusVoltage(), getCurrent_mA() and getPower_mW() print the rail every half second, and swapping the lamp for another model changes the current.

Two mistakes cause most of the zeros. Leaving VBUS unconnected makes the bus voltage and the power read zero, and reading current before the calibration is written does the same to current and power. The registers are sixteen bits: the shunt is 2.5 microvolts a count, the bus 1.25 millivolts, and a conversion takes 2.2 ms by default times the averaging count. The address runs from 0x40 to 0x4F.

Part pin
Board pin
VCC, GND
5 V and ground (2.7 V to 5.5 V)
SDA, SCL
The Uno’s I2C bus; the board carries the pull-ups
IN+
The 12 V supply
IN-
The load, here a 12 V 0.1 A lamp
VBUS
The load’s supply side
ALERT
Not used

The chip runs from 2.7 V to 5.5 V, so it works on a 3.3 V ESP32 or Pico, on that board’s I2C pins, at the same address.

Arduino Uno: an INA226 and an INA3221 on two railslive0.000 s 0.00x
Click to open it in the editor
This is the simulator itself, running here. Click anything to open it in the editor.
Reading voltage, current and power every half second
#include <Wire.h>
#include "INA226.h"

INA226 INA(0x40);

void setup() {
  Serial.begin(9600);
  Wire.begin();
  INA.begin();
  INA.setMaxCurrentShunt(0.8, 0.1);   // writes the calibration
}

void loop() {
  Serial.print(INA.getBusVoltage(), 2);
  Serial.print(" V  ");
  Serial.print(INA.getCurrent_mA(), 0);
  Serial.print(" mA  ");
  Serial.print(INA.getPower_mW(), 0);
  Serial.println(" mW");
  delay(500);
}
Common errors

Common Power monitor, INA226 errors and fixes

What goes wrong
The fix
Current and power read zero.
The calibration register has not been written. Call the library’s setup, such as setMaxCurrentShunt(0.8, 0.1), after begin().
The bus voltage and power read zero.
VBUS is not connected. Tie it to the supply side of the load.
The chip is not found on the bus.
Check the address, 0x40 to 0x4F set by the strap pins and the part’s address property, and that SDA and SCL are not swapped.
A reading changes slowly or lags a step.
A conversion takes 2.2 ms by default times the averaging count. Wait for the conversion-ready flag, or lower the averaging.
Questions

Questions and answers

What is the difference between the INA226 and the INA219?

The INA226 is the more precise one: 2.5 microvolts a count on the shunt, a bus voltage pin of its own and an alert pin. Both talk over I2C.

Why does the INA226 read zero current?

Because the calibration register is still zero. Every library writes it in its setup call, such as setMaxCurrentShunt(), which takes the expected maximum current and the shunt’s resistance.

Which libraries read the INA226?

Rob Tillaart’s INA226.h, which the project uses, and Wolfgang Ewald’s INA226_WE.h, which Mokxi also compiles.

What shunt does the module have?

A 0.1 ohm resistor between IN+ and IN-, in series with the load. The model uses a real 0.1 ohm resistance, so the voltage it drops is part of the circuit.

How it is modeled

What is true about the Power monitor, INA226, here

In its help article’s own words: what the simulation gets right, and where it stops.

Not modeled

The noise that averaging removes, and the SMBus alert response.

From INA226 current and power monitor, in full.

Projects

See the Power monitor, INA226 in a project

One built-in project uses it. It opens in the editor, already wired.

Boards

The boards it is shown on

This board has a built-in project with the Power monitor, INA226 in it.

Wire up the Power monitor, INA226

Open the editor and push it into the breadboard. It is free, and it runs on your own machine.