Reference
INA219 / INA226 Voltage, Current and Power Sensor Complete Guide
The INA219 and INA226 measure voltage, current and power on a low-voltage DC bus over I2C, using a shunt resistor and Ohm's law, not the mains-AC energy-meter ICs this site already covers. This guide covers both chips' real specs, wiring one to an ESP32, and which to pick for a battery or power-budget project.
The INA219 and INA226 are Texas Instruments current/power monitor ICs: they measure the tiny voltage drop across a shunt resistor in series with a DC load, then report current, bus voltage and power over I2C. This is a different job from the already-published BL0937/BL0942 energy-meter ICs on this site, those measure mains AC power for a smart plug, these measure low-voltage DC bus power, for example how much current a battery pack, solar panel or 3.3V/5V rail is actually drawing.
INA219 vs. INA226: real differences
| INA219 | INA226 | |
|---|---|---|
| ADC resolution | 12-bit | 16-bit |
| Max current (with a 0.1Ω shunt, 3.2A range) | 3.2A (has a built-in PGA to boost sensitivity) | 0.8A (no PGA, use a smaller shunt for higher current) |
| Selectable I2C addresses | 4 (via 2 address pins) | 16 (via 2 address pins) |
| Default I2C address | 0x40 | 0x40 |
The INA219 handles higher current out of the box thanks to its programmable gain amplifier. The INA226 trades that for finer resolution and more selectable addresses, useful when monitoring several rails on one I2C bus. For most single-battery or single-rail hobby monitoring, either works, pick the INA219 if you’re already reaching for its very common Adafruit breakout, or the INA226 if you specifically need its extra resolution or address count.
Wiring to an ESP32
Both chips measure current by sitting in series with the load’s supply line, through the shunt resistor built into the breakout board.
| Pin | Function | ESP32 Pin |
|---|---|---|
| VCC | Logic power, 3V–5.5V | 3.3V |
| GND | Ground | GND |
| SDA | I2C data | GPIO21 |
| SCL | I2C clock | GPIO22 |
| VIN+ / VIN− | Shunt terminals, wired in series with the load being measured | — (power path, not logic) |
Arduino code (Adafruit INA219 library)
#include <Wire.h>
#include <Adafruit_INA219.h>
Adafruit_INA219 ina219;
void setup() {
Serial.begin(115200);
Wire.begin(21, 22);
if (!ina219.begin()) {
Serial.println("Failed to find INA219");
while (1) delay(10);
}
}
void loop() {
float busVoltage = ina219.getBusVoltage_V();
float current_mA = ina219.getCurrent_mA();
float power_mW = ina219.getPower_mW();
Serial.print("Bus Voltage: "); Serial.print(busVoltage); Serial.println(" V");
Serial.print("Current: "); Serial.print(current_mA); Serial.println(" mA");
Serial.print("Power: "); Serial.print(power_mW); Serial.println(" mW");
delay(1000);
}Install “Adafruit INA219” via the Arduino Library Manager. For the INA226, there’s no official Adafruit library, the community RobTillaart/INA226 library is a well-maintained alternative with a similar API.
Practical Applications
- Battery fuel gauging: track real current draw to estimate remaining runtime.
- Solar panel monitoring: measure actual power output under real conditions.
- Power-budget debugging: find which part of a project is drawing more current than expected.
- Overcurrent protection logic: cut power in software if current exceeds a safe threshold.
Conclusion
The INA219 and INA226 give you real voltage/current/power visibility into a DC bus over I2C, complementing (not duplicating) the mains-AC BL0937/BL0942 guides already on this site. Either pairs cleanly with an ESP32 over I2C.
Related
Reference
Seeed Studio XIAO nRF52840 Pinout
This site's first non-Espressif board: Nordic's nRF52840 Bluetooth Low Energy SoC on Seeed's thumbnail-sized XIAO carrier, with no Wi-Fi radio at all.
Read more
Reference
SSD1306 OLED Display
A tiny, self-illuminating I2C display for turning a headless ESP32 project into something readable at a glance. Covers the SSD1306 vs SH1106 offset trap, how the page-based framebuffer works, and avoiding burn-in.
Read more
Guide
ATtiny 0/1/2-Series Pinout
The complete pin reference for Microchip’s modern ATtiny 0/1/2-series: true USART, SPI and I2C peripherals, and single-wire UPDI programming instead of classic ISP.
Read more
More guides
Keep building.
From ESP32 HomeKit accessories to Arduino and ATtiny reference guides, there’s more where this came from.
All guides