Source: https://mokxi.com/libraries/adafruit-ina219
Updated: 2026-11-02

Libraries / Sensors
Arduino library · Sensors

# Adafruit INA219: current, voltage and power on I2C

The INA219 from Texas Instruments measures current by the tiny voltage across a 0.1 ohm shunt resistor in the supply line, and the voltage of the line itself, and reports both over I2C. The Adafruit INA219 library turns the chip’s registers into milliamps, volts and milliwatts, which makes it the usual choice for measuring what a motor, LED strip or solar panel draws.

Open the example in the editor See the calls

Built in on Mokxi: #include <Adafruit_INA219.h> and it builds, with nothing to install. Free, and no account needed.

## What Adafruit INA219 does

Unlike a Hall sensor, the INA219 sits in the high side of the circuit: the supply goes into VIN+ and out of VIN- to the load. It measures up to 26 V on the bus. The default calibration covers 32 V and 2 A; setCalibration_32V_1A() and setCalibration_16V_400mA() trade range for finer steps when the current is small.

Bus voltage is measured at VIN-, after the shunt. The voltage the load really sees is that bus voltage, and the supply voltage is the bus voltage plus the shunt voltage, which is how the library’s example works out "load voltage".

Library Manager name | Adafruit INA219

Author | Adafruit

Include | #include <Adafruit_INA219.h>

Boards | every board Mokxi compiles for but ATtiny85

In the simulator | Simulated: it runs against the part the way it does on the bench.

Parts it drives | Current monitor, INA219

## Install it

It builds on every board Mokxi compiles for but ATtiny85.

In Mokxi it is built in: #include <Adafruit_INA219.h> and the sketch compiles, with no download, no zip and no Library Manager.

On a real board, install "Adafruit INA219" by Adafruit from the Arduino IDE’s Library Manager (Sketch, Include Library, Manage Libraries), or add Adafruit INA219 to lib_deps in PlatformIO. Mokxi follows the calls of release 1.2.3, so a sketch written here builds there too.

ESP32-C3 · Arduino Uno · Arduino Nano · Arduino Mega 2560 · Arduino Leonardo · SparkFun Pro Micro · Arduino Micro · ESP32-C6 · Raspberry Pi Pico · Raspberry Pi Pico W · Seeed XIAO SAMD21 · STM32 · STM32 Nucleo-F411RE · STM32 Blue Pill · micro:bit V2 · Arduino Uno R4 · ESP32 DevKit · ESP32-S3-DevKitC-1 · ESP8266 NodeMCU · Arduino Pro Mini 3.3 V · Seeed XIAO ESP32-C3 · ESP32-C3 SuperMini · Seeed XIAO ESP32-C6 · ESP32-DevKitC V4 · LOLIN32 Lite · Wemos D1 R32 · Cheap Yellow Display · TTGO T-Display · Seeed XIAO ESP32-S3 · Arduino Nano ESP32 · Arduino Nano RP2040 Connect · Seeed XIAO RP2040 · Waveshare RP2040-Zero · Arduino Uno R4 WiFi

## The calls you will use

In the order a sketch meets them.

### Adafruit_INA219 ina219

Creates the sensor at the default address 0x40. Adafruit_INA219 ina219(0x41) for a board with A0 bridged.

### ina219.begin()

Starts I2C and applies the 32 V, 2 A calibration. Returns false when the chip does not answer.

### ina219.getCurrent_mA()

Current through the shunt in milliamps, negative when it flows backward.

### ina219.getBusVoltage_V()

The voltage on VIN- relative to ground, in volts.

### ina219.getShuntVoltage_mV()

The voltage across the shunt in millivolts, at most 320 mV.

### ina219.getPower_mW()

Power in milliwatts, worked out by the chip from the current and the bus voltage.

### ina219.setCalibration_16V_400mA()

A finer range for small loads: 16 V and 400 mA in 0.1 mA steps. setCalibration_32V_1A() is between the two.

## Example: Current and voltage

On the ESP32-C3-DevKitM-1. It runs in the browser exactly as printed.

sketch.ino · ESP32-C3-DevKitM-1

Open it in the editor, wired and ready to run · Current and voltage: the project page

## Common errors and how to fix them

### Failed to find INA219 chip

begin() returned false. Check SDA and SCL, the address jumpers (0x40 to 0x45), and that the module’s VCC is powered, not only VIN+.

### Current reads 0 while the load runs

The load current is not going through the shunt. The supply must go into VIN+ and leave from VIN- to the load; the load’s ground and the board’s ground must be joined.

### Current is negative

VIN+ and VIN- are swapped, so current flows backward through the shunt. Swap the two wires, or flip the sign in the sketch if the direction is intended.

## Projects that use Adafruit INA219

Built-in projects that include it. Each page has the full sketch and opens in the editor, already wired.

Solar tracker Four light sensors steer a pan and tilt servo pair, an INA219 measures the panel, and the sketch alternates tracked and fixed windows, printing only measured averages.

## Keep going

### Learn

- Arduino INA219: Current Sensor Library and Code

### Parts

- Current monitor, INA219

### More sensors libraries

- DHT sensor library
- DHT20
- VL53L0X
- Adafruit_VL53L0X
- HX711 Arduino Library
- MPU6050
- Adafruit MPU6050
- BME280

Every built-in library · Open the editor

## Try Adafruit INA219 without installing anything

Open the example, change the sketch, and keep your version in a free account.

Start building free

Open the editor
