Part

Power and energy monitor, INA228

A 20-bit power monitor on a 15 milliohm shunt that adds up energy and charge as it goes.

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 and energy monitor, INA228 as drawn in the Mokxi simulator
At a glance

The Power and energy monitor, INA228 in brief

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

The TI INA228 is a power and energy monitor. It measures current, bus voltage and power to 20 bits through a 15 milliohm shunt, and adds up energy in joules and charge in coulombs as it goes, which makes it the monitor for a battery's state of charge or a project's energy use over a day. The chip keeps the running totals itself. It talks over I2C, with an address from 0x40 to 0x4F. In Mokxi it is used with Adafruit's library, shipped as Adafruit_INA228.h, and the sketch calls setShunt(0.015, 10.0). VBUS is the bus voltage input, tied to the load's supply side, and IN+ and IN- are the two ends of the shunt, in series with the load. The Mokxi model leaves out the limit comparisons and their alerts, the shunt temperature compensation, and noise. Nothing is draggable: the current is the circuit's own.

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 a conversion when the conversion-ready alert is on.
VBUS
The bus voltage input: tie it to the load's supply side.
IN+
The two ends of the 15 milliohm shunt, in series with the load.
IN-
The two ends of the 15 milliohm shunt, in series with the load.
How to use it

How to use the INA228 with an Arduino Uno

The example project is an energy meter. An INA228 sits in series with a 12 V lamp: IN+ goes to 12 V and IN- goes to the lamp, while VBUS ties to the 12 V supply side. VCC goes to 5 V, GND to the Uno's GND, and SCL and SDA to the Uno's SCL and SDA. An OPT3001 light sensor reads the light falling on the solar panel that would charge the battery.

The sketch includes Adafruit_INA228.h and ClosedCube_OPT3001.h, calls meter.begin(), then meter.setShunt(0.015, 10.0) to set the 15 milliohm shunt. The chip keeps the running totals itself, so the loop only reads them: every 500 ms it prints bus voltage, current in mA, power in mW, energy in joules, charge in coulombs, and the panel light in lux. 3600 coulombs is one amp hour.

With default settings, the serial monitor printed: "Energy meter", "12.00 V 100 mA 1197 mW 0.65 J 0.055 C panel 19999 lux", "12.00 V 100 mA 1197 mW 1.29 J 0.108 C panel 19999 lux". The voltage, current and power stay the same because the load does not change. The joules and coulombs climb every line as the chip accumulates them.

Try swapping the lamp for another model and watch the totals climb faster or slower. Drag the light slider on the OPT3001 and watch the lux number change.

Part pin
Goes to
VCC
5 V
GND
Arduino Uno R3 pin GND
SCL
Arduino Uno R3 pin SCL
SDA
Arduino Uno R3 pin SDA
IN+
12 V
IN-
lamp pin 1
VBUS
12 V
Energy meterlive0.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.
sketch.ino · Arduino Uno R3 · the first 45 lines
// Energy meter: an INA228 on a 12 V load adds up the energy and the charge
// that flow through its shunt, the way a battery monitor counts what is
// left, and an OPT3001 reads the light falling on the solar panel that
// would charge the battery.
//
//   INA228    SDA -> SDA   SCL -> SCL   in series with the load
//   OPT3001   SDA -> A4    SCL -> A5
//
// The chip keeps the running totals itself, so the sketch only reads them:
// joules of energy and coulombs of charge (3600 coulombs is one amp hour).
//
// Things to try. Swap the lamp for another model and watch the totals climb
// faster or slower. Drag the light slider on the OPT3001.

#include <Adafruit_INA228.h>
#include <ClosedCube_OPT3001.h>

Adafruit_INA228 meter;
ClosedCube_OPT3001 light;

void setup() {
  Serial.begin(9600);
  if (!meter.begin()) {
    Serial.println("No INA228");
    while (1);
  }
  meter.setShunt(0.015, 10.0);
  light.begin(0x44);
  OPT3001_Config config;
  config.rawData = 0;
  config.RangeNumber = 0b1100;      // automatic range
  config.ModeOfConversionOperation = 0b11;  // continuous, 100 ms
  light.writeConfig(config);
  Serial.println("Energy meter");
}

void loop() {
  delay(500);
  Serial.print(meter.getBusVoltage_V(), 2);
  Serial.print(" V  ");
  Serial.print(meter.readCurrent(), 0);
  Serial.print(" mA  ");
  Serial.print(meter.readPower(), 0);
  Serial.print(" mW  ");
  Serial.print(meter.readEnergy(), 2);
Common errors

Common Power and energy monitor, INA228 errors and fixes

What goes wrong
The fix
Leaving VBUS unconnected.
VBUS is the bus voltage input. Tie it to the load's supply side, as the example does with 12 V.
Putting the shunt anywhere but in series with the load.
IN+ and IN- are the two ends of the 15 milliohm shunt. In the example IN+ goes to 12 V and IN- to the lamp.
Looking for a slider to change the current.
There is nothing to drag. The current is the circuit's own, so change the load, for example swap the lamp for another model.
Questions

Questions and answers

what is the ina228

A TI chip that measures current, bus voltage and power to 20 bits through a 15 milliohm shunt and adds up energy and charge as it goes.

what is the ina228 i2c address

The address property ranges from 0x40 to 0x4F.

how does the ina228 count energy and charge

The chip keeps the running totals itself in registers that accumulate with each conversion, until cleared.

why does the ina228 read zero power and energy

VBUS is probably unconnected. Tie it to the load's supply side.

How it is modeled

What is true about the Power and energy monitor, INA228, here

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

Not modeled

The limit comparisons and their alerts, the shunt temperature compensation, and noise.

From INA228 power and energy monitor, in full.

Projects

See the Power and energy monitor, INA228 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 and energy monitor, INA228 in it.

Wire up the Power and energy monitor, INA228

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