Reference
INA219
Voltage, current, and power monitor.
- Connects over
- I²C
- Address
- 0x40 (or 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F)
- Made by
- Texas Instruments
- Datasheet
- ti.com
Use it
hardware {
device ina219: INA219
}
every 1s {
let value: float = ina219.voltage()
log("ina219", "voltage={value}")
}
On its own, the declaration puts the INA219 on the first I²C bus (SDA 21, SCL 22 on the ESP32) at 0x40. To choose the pins or the address, declare the bus and attach the device: device ina219: INA219 on i2c0 at 0x41 with i2c i2c0(sda: 21, scl: 22).
Methods
-
ina219.voltage() -> float
Bus voltage in V
-
ina219.current() -> float
Current in A
-
ina219.power() -> float
Power in W
-
ina219.shunt_voltage() -> float
Shunt voltage in V
Wiring
| Pin | Connect to |
|---|---|
VCC | 3.3V or 5V |
GND | Ground |
SDA | Pull-up to VCC (often on breakout board) |
SCL | Pull-up to VCC |
Vin+ | Connect to + side of load |
Vin- | Connect to load — Vin+/Vin- straddle the shunt |
A0/A1 | Address select (0x40 – 0x4F) |
Specifications
- Voltage
- 3V – 5.5V (logic); measures bus 0–26V
- Current
- 1 mA active, 6 μA sleep
- Current range
- Default ±3.2 A through a 0.1 Ω shunt; ±400 mA via gain change
- Resolution
- 12-bit (≈ 100 μA per LSB at default gain)
- Interface speed
- I²C up to 3.4 MHz
Tips
- Default shunt is 0.1 Ω — change if your load is < 100 mA (use bigger shunt for resolution) or > 3.2 A (use smaller).
- Measures HIGH-side current — Vin+/Vin- are at supply potential, not ground.
- Power calculation register saves you from manually multiplying V × I.
Alternatives worth knowing:
- INA226: Better accuracy + alert pin; 0–36V range.
- INA3221: 3-channel version — useful for measuring multiple rails.