ESP32 DC power monitor with an INA3221: battery, solar and 12 V loads
Disclosure: As an Amazon Associate I earn from qualifying purchases. Links to parts on this page are affiliate links, some through brand partnerships, so I may earn a commission at no extra cost to you. It never changes which parts I recommend.
An INA3221 measures current and voltage on three DC circuits at once. Wire one into a 12 V system and Home Assistant can show what the charger is putting into the battery, what each load is pulling, the battery voltage, and how many watt-hours went each way today. It's a good fit for an RV, a camper, a shed or cabin on solar, or a battery backup for a router and cameras.
Check your system voltage first. The INA3221 can't measure anything above 26 V. That covers 12 V systems comfortably. Most 24 V batteries charge above 26 V, so for a 24 V system use the single-channel INA226 instead (see below). 36 V and 48 V banks are beyond both. For a big bank of 2 V cells, see the battery cell monitor instead.
- Cost
- $15–30 (more with external shunts)
- Time
- 1–2 hours
- Difficulty
- Intermediate
- Skills
- Basic wiring; soldering for external shunts
How it measures
Each of the three channels has its own small resistor, called a shunt, that the current flows through. The chip measures the tiny voltage across the shunt, and ESPHome turns that into amps using Ohm's law. Each channel also measures the circuit's voltage, and ESPHome multiplies the two for watts.
- It sits in the positive wire. The INA3221 is a high-side monitor, so each channel goes in the + side of its circuit, and the negative side stays untouched.
- The stock shunts are small. Most INA3221 boards come with 0.1 Ω shunts marked R100. The chip's measuring range tops out at 163.8 mV across the shunt, so with 0.1 Ω each channel reads up to about 1.6 A. That's fine for a router, a camera or LED strips. A fridge, an inverter or a charge controller needs an external shunt, covered below.
- It reads in both directions. Current flowing the "wrong" way reads negative, which is useful on a battery line that both charges and discharges.
Parts
- INA3221 3-channel current and voltage monitorView on AmazonIllustration
- ESP32 DevKitView on AmazonPhoto: Edwiyanto, CC BY-SA 4.0

- 12 V to 5 V buck converter (5 A)View on AmazonIllustration
- Inline fuse holderView on AmazonIllustration
- One INA3221 board covers three circuits. Its address jumper lets up to four share one ESP32 for twelve circuits.
- The buck converter powers the ESP32 from the same 12 V system, so the monitor keeps running when there's no USB power around.
- A fuse on every wire that comes off the battery positive, sized for that wire.
- For circuits over 1.6 A: a 75 mV DC shunt rated above that circuit's highest current.
Wiring
Logic side
The INA3221 talks over I²C, so it needs four wires to the ESP32: VCC to 3.3 V, GND to GND, SDA to GPIO21 and SCL to GPIO22. Most boards include the I²C pull-up resistors, so nothing else goes on those lines.
Power side
- Put each channel in a positive wire. IN+ goes toward the source (the battery, or the charge controller), and IN− goes toward whatever it feeds.
- Tie the grounds together. The INA3221 measures each circuit's voltage relative to its own GND pin, so the battery negative, the load negatives, the INA3221 GND and the ESP32 GND all connect. Without that, voltage and power read as zero or nonsense.
- Fuse at the battery. Every wire that leaves the battery positive needs its own fuse close to the battery, including the thin ones running to this monitor.
- Power the ESP32 from the 12 V system through the buck converter, set to 5 V and connected to the ESP32's 5V pin. Set the buck's output with a meter before connecting the board.
Measuring more than 1.6 A: external shunts
For real loads, swap the board's shunt for a bigger one that lives in the main wire:
- Pick a 75 mV shunt rated above that circuit's highest current. A 50 A / 75 mV shunt is 1.5 mΩ (0.075 V ÷ 50 A). 75 mV sits comfortably inside the INA3221's 163.8 mV range.
- Remove that channel's R100 resistor from the board with a soldering iron. Left in place, it carries part of the measurement in parallel and throws the reading off.
- Bolt the shunt into the positive wire, using its two big terminals.
- Run two thin sense wires from the shunt's two small screws to that channel's IN+ (source side) and IN− (load side). Twist them together, and fuse the IN+ wire near the shunt, since it connects straight to the battery positive.
- Tell ESPHome the new value, for example
shunt_resistance: 0.0015 ohmfor a 50 A / 75 mV shunt.
The chip reads the shunt in 40 µV steps, so with a 1.5 mΩ shunt each step is about 27 mA. That's plenty for a fridge or an inverter, but it's not built to measure tiny standby currents on a big shunt.
24 V systems: the INA226
The INA226 is the INA3221's single-channel cousin. It measures up to 36 V, which covers a 24 V battery while it charges, and it reads with finer, 16-bit steps. You need one board per circuit, each on its own I²C address.
- INA226 current and voltage monitor (36 V)View on AmazonIllustration
- Its shunt range is half the INA3221's: 81.92 mV. With the board's 0.1 Ω shunt that's about 0.8 A, so real loads need an external shunt here too. A 75 mV shunt still fits.
- It wires the same way: VCC, GND, SDA and SCL to the ESP32, IN+ toward the source, IN− toward the load, and VBUS to the circuit's positive if the board breaks it out separately.
sensor:
- platform: ina226
address: 0x40
shunt_resistance: 0.0015 ohm
max_current: 50A
adc_averaging: 16
update_interval: 10s
bus_voltage:
name: "Battery voltage"
current:
name: "Battery current"
power:
name: "Battery power"
Set shunt_resistance and max_current to match your shunt. This example is a 50 A / 75 mV shunt.
The ESPHome config
This config reads all three channels every 10 seconds. Channel 1 also reports the battery voltage, and the three integration sensors add power up into watt-hours for Home Assistant's Energy dashboard.
i2c:
sda: GPIO21
scl: GPIO22
scan: true
sensor:
- platform: ina3221
address: 0x40
update_interval: 10s
channel_1:
shunt_resistance: 0.1 ohm
bus_voltage:
name: "Battery voltage"
current:
name: "Charge current"
power:
name: "Charge power"
id: charge_power
channel_2:
shunt_resistance: 0.1 ohm
current:
name: "Load A current"
power:
name: "Load A power"
id: load_a_power
channel_3:
shunt_resistance: 0.1 ohm
current:
name: "Load B current"
power:
name: "Load B power"
id: load_b_power
- platform: integration
name: "Charge energy"
sensor: charge_power
time_unit: h
unit_of_measurement: Wh
device_class: energy
state_class: total_increasing
restore: true
filters:
- lambda: return max(x, 0.0f);
- platform: integration
name: "Load A energy"
sensor: load_a_power
time_unit: h
unit_of_measurement: Wh
device_class: energy
state_class: total_increasing
restore: true
- platform: integration
name: "Load B energy"
sensor: load_b_power
time_unit: h
unit_of_measurement: Wh
device_class: energy
state_class: total_increasing
restore: true
- Change
shunt_resistanceon any channel that uses an external shunt. - The address is 0x40 out of the box. The board's address jumper moves it to 0x41, 0x42 or 0x43 for a second, third or fourth board; give each its own
- platform: ina3221block. - The
max(x, 0.0f)filter on the charge energy stops a charge controller's tiny night-time reverse current from counting against the total. restore: truekeeps the running totals through a reboot.
Calibrating
- Voltage: measure the battery with a multimeter and compare it with Battery voltage. The two should agree within a few hundredths of a volt. If not, check the ground connection first.
- Current: run a steady load, measure its current with a clamp meter or a meter in series, and compare. If the reading is off by a fixed percentage, adjust that channel's shunt value: new value = old value × (reading ÷ real current). Real shunts are rarely exactly their marked value, so external shunts usually need this.
Using it in Home Assistant
- Energy dashboard: add Charge energy as solar production, and Load A energy and Load B energy as individual devices.
- Low battery warning: notify when Battery voltage stays under your chemistry's low point for 5 minutes. The right number depends on the battery: lead-acid and lithium iron phosphate sit at very different voltages for the same charge.
- Load shedding: pair it with a relay or smart switch and cut a non-essential load when the voltage drops, so the router and cameras keep running longest.
- Charger check: notify when Charge current stays at zero all day on a sunny day. That usually means a blown fuse or a tripped charge controller.
Frequently asked questions
What voltage can an INA3221 measure?
Up to 26 V on each channel. That covers 12 V systems, but most 24 V batteries charge above 26 V, so use an INA226, which reads up to 36 V, for those.
How much current can an INA3221 board measure?
About 1.6 A per channel with the usual 0.1 Ω shunts. For more, remove that channel's shunt resistor and wire the channel to an external 75 mV shunt rated for your current.
Does ESPHome support the INA3221?
Yes. ESPHome has an ina3221 sensor platform that reports bus voltage, current and power for each of the three channels, with a shunt_resistance setting per channel.
Can I see INA3221 readings in Home Assistant's Energy dashboard?
Yes. Add an ESPHome integration sensor that turns each channel's watts into watt-hours, with the energy device class and the total_increasing state class, then add those sensors in the Energy dashboard.
Troubleshooting
| Symptom | Likely cause and fix |
|---|---|
| The INA3221 isn't found on I²C | Check SDA and SCL aren't swapped and VCC is on 3.3 V. The I²C scan in the log shows the address; set the config's address to match (0x40 to 0x43). |
| Voltage and power read zero | The INA3221 GND isn't connected to the battery negative. Every ground in the system has to be common. |
| Current reads negative | IN+ and IN− are swapped on that channel. Swap them, or leave it if negative means discharging on a battery line. |
| Current never goes past about 1.6 A | The stock 0.1 Ω shunt has hit the chip's limit. Use an external shunt and remove that channel's R100 resistor. |
| Current is off by the same percentage | The shunt isn't exactly its marked value. Adjust shunt_resistance: new = old × (reading ÷ real current). |