Part

Current monitor, INA219

A 0.1 ohm shunt in series with a load, and the current, voltage and power it sees, over I2C.

See every part
  • 6 pins
  • 1 setting
  • In 4 projects
  • In 1 lesson
Drawn live by the editor's own code, at the size you see it.
At a glance

The Current monitor, INA219 in brief

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

The INA219 is Texas Instruments’ high-side current and power monitor, sold on a purple breakout with a 0.1 ohm shunt and six pins: VCC, GND, SCL, SDA, VIN+ and VIN-. VCC takes 3 to 5.5 V, SDA and SCL go to A4 and A5 on an Uno or GPIO 21 and 22 on an ESP32, and the load’s current goes in at VIN+ and out at VIN-. The address is 0x40 as it ships, 0x41, 0x44 or 0x45 with its solder jumpers. In Mokxi the shunt is a real 0.1 ohm resistor in the circuit, so the reading is the load’s own current, not a slider. The chip reads the shunt in 10 microvolt steps and the load side in 4 mV steps, its gain ranges are 40 to 320 mV, which is 0.4 to 3.2 A through the shunt, and a conversion takes 532 microseconds at 12 bits. The current register reads zero until the calibration is written, which begin() does. The classic mistakes are wiring it backwards, so the current reads negative, and leaving out the common ground. Noise, saturation of the 16 V range and the chip’s own supply current are not modeled.

Family
Sensors
Pins
6
address
64
Pins

6 pins

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

Pin
What it does
VCC
The chip's own supply, 3 to 5.5 V.
GND
Ground, shared with the circuit being measured.
SCL
I2C clock. The module carries the pull-ups.
SDA
I2C data.
VIN-
The other end: to the load.
VIN+
One end of the shunt: the supply side.
How to use it

How to use the INA219 current sensor with an Arduino

The INA219 has two sides. VCC, GND, SDA and SCL power the chip and talk to the board; VIN+ and VIN- go in series with the load, supply into VIN+ and VIN- on to the load. In the project here an ESP32-C3 reads it on GPIO 8 and 9, and its VIN+ takes the 3.3 V rail into a 220 ohm load, about 15 mA. Change the resistor while it runs and the reading follows, because the shunt is a real 0.1 ohm resistor in the circuit.

ina219.begin() matters more than it looks: it writes the calibration register, and until something does, the current reads zero whatever flows. Then getCurrent_mA(), getPower_mW() and getBusVoltage_V() are the three calls. The bus voltage is measured at VIN-, the load side, so it is the supply less the shunt’s drop. Swap VIN+ and VIN- and the current reads negative.

Part pin
Board pin
VCC
3.3 V (3V3)
GND
GND
SDA
GPIO 8
SCL
GPIO 9
VIN+
3.3 V rail
VIN-
220 ohm load to GND

On an Uno, SDA and SCL go to A4 and A5 and VCC to 5 V. Whatever supplies the load, its ground has to be shared with the board’s, or the readings mean nothing.

ESP32-C3: current and voltagelive0.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.
Milliamps, milliwatts and volts
#include <Wire.h>
#include <Adafruit_INA219.h>
Adafruit_INA219 ina219;
void setup() {
  Serial.begin(115200);
  if (!ina219.begin()) Serial.println("no INA219 at 0x40");
}
void loop() {
  Serial.print(ina219.getCurrent_mA());
  Serial.print(" mA, ");
  Serial.print(ina219.getPower_mW());
  Serial.print(" mW, ");
  Serial.print(ina219.getBusVoltage_V());
  Serial.println(" V");
  delay(500);
}
How it is modeled

What is true about the Current monitor, INA219, here

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

Modeled

Calibration. The chip powers up with its calibration register at zero, and until something writes it the current and power registers read zero, whatever flows. The library's begin() writes it; a hand-written driver that forgets gets a perfectly steady zero.

Gain. The shunt amplifier's range is ±40, 80, 160 or 320 mV, which through 0.1 Ω is 0.4, 0.8, 1.6 or 3.2 A. A current past the range reads as the end of it.

Time. The ADC converts continuously by default, shunt then bus, 532 µs each at 12 bits and up to 68 ms each when averaging 128 samples. Results change when a conversion finishes, and the conversion-ready bit says so. The triggered and power-down modes are there too.

Not modeled

Noise, so averaging changes only the conversion time here. The 16 V bus range does not saturate above 16 V. The address pins, which are the address property. The chip's own supply current.

From INA219 current monitor, in full.

Projects

See the Current monitor, INA219 in a project

4 built-in projects use it. Each opens in the editor, already wired.

Lessons

Where it turns up in a lesson

One lesson places it in its own circuit.

Boards

The boards it is shown on

Each of these 2 boards has a built-in project with the Current monitor, INA219 in it.

Libraries

Arduino libraries for the Current monitor, INA219

Built in, so the sketch compiles with nothing to install. Each page has the calls, the wiring and an example to run.

Wire up the Current monitor, INA219

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