An INA3221 lets an ESP32 measure the voltage and current of three DC power rails through one I²C connection. Connect it to ESPHome and Home Assistant to watch a 12 V router, a 5 V electronics rail and a separate low-voltage load on the same dashboard. This guide covers the full wiring path—not just the four I²C pins—because a current sensor only gives useful readings when every load is routed through the correct shunt resistor.
The INA3221 is a monitor, not a power supply, protection switch or mains-energy meter. Use it on appropriately rated, low-voltage DC circuits only. For a single channel, see our INA226 with ESP32 and ESPHome guide; the INA3221 trades that single-channel arrangement for three independent measurement channels that share a ground reference.
What the INA3221 measures
Texas Instruments specifies the INA3221 as a triple-channel current and bus-voltage monitor with a 0–26 V bus-measurement range, a 2.7–5.5 V chip supply and an I²C/SMBus interface. It senses a small voltage drop across a resistor inserted in series with each circuit’s positive feed. From that drop and the resistor value, software calculates current. ESPHome also reports bus voltage and calculated power for each channel. TI INA3221 specifications and the ESPHome INA3221 component document these capabilities.
| Reading | What it means | Practical use |
|---|---|---|
| Bus voltage (V) | DC voltage on the monitored load side of the shunt | Detect a supply droop or an unexpected shutdown |
| Shunt voltage (V) | Small differential voltage across that channel’s resistor | Check wiring, polarity and range |
| Current (A) | Shunt voltage divided by the configured resistance | See what the individual load draws |
| Power (W) | Bus voltage multiplied by current | Estimate each load’s instantaneous DC consumption |
For example, if channel 1 measures 12.0 V at 0.40 A, the reported power is approximately 4.8 W. That is an instantaneous reading: it is not yet energy in Wh or kWh. Energy needs to be accumulated over time, as shown later. The three channels can measure different positive voltages, but they are not galvanically isolated from one another.
What you need
- An ESP32 development board with accessible 3.3 V, GND, SDA and SCL pins. The example below uses GPIO21 for SDA and GPIO22 for SCL on a classic ESP32; change these for your actual board.
- An INA3221 module or breakout with a clearly documented pinout, three fitted shunts and an I²C interface suitable for 3.3 V logic. Check the actual board, not only the chip specification.
- One, two or three independently fused, low-voltage DC loads; a bench supply and a known test resistor or small fan make commissioning straightforward.
- An appropriately rated supply for the ESP32, short I²C wires, correctly sized power wiring, and a multimeter for checking resistance, voltage and current.
The example assumes three 0.1 Ω shunts, often marked R100. Some breakouts use different values or provide a way to replace the resistors. Read the markings and the schematic before copying the YAML. Also inspect the breakout’s terminal blocks and PCB traces: their current rating can be more restrictive than the chip’s measurement range.
ESP32-to-INA3221 I²C wiring
| ESP32 | INA3221 breakout | Notes |
|---|---|---|
| 3V3 | VS / VCC / VIN as documented for your module | Use 3.3 V only if the actual board accepts it; distinguish VIN-regulator inputs from bare-chip VS. |
| GND | GND | Common reference for the measurement circuits and I²C. |
| GPIO21 | SDA | 3.3 V I²C logic, with appropriate pull-up resistors. |
| GPIO22 | SCL | 3.3 V I²C logic, with appropriate pull-up resistors. |
The INA3221 chip accepts a supply up to 5.5 V, but that does not make 5 V on an ESP32 GPIO safe. A breakout powered from 5 V might pull SDA and SCL to 5 V. Power a compatible module at 3.3 V or use suitable bidirectional I²C level shifting when the board requires a higher supply. Some branded breakouts have onboard level shifting; verify the specific board rather than assuming every INA3221 PCB is identical.
The chip’s 26 V measurement capability applies to its monitored analog inputs; it does not mean its VS/VCC supply pin should receive 12 V or 24 V. Never connect the load supply to the ESP32’s 3V3 pin. Keep the load-power path electrically separate from the four low-current I²C connections except for the necessary common ground.
How to connect all three loads
Each channel measures current by placing its own shunt in series with the positive lead to a load. On a typical breakout, the terminal labelled IN1+ or CH1+ faces the supply, while IN1- or CH1- faces the load. Repeat for channels 2 and 3. The minus sign here is the downstream measurement terminal, not the power-supply negative terminal.
12 V supply + ── fuse ── CH1+ [shunt 1] CH1− ── 12 V router +
5 V supply + ── fuse ── CH2+ [shunt 2] CH2− ── 5 V load +
9 V supply + ── fuse ── CH3+ [shunt 3] CH3− ── 9 V load +
All three load negatives ──────────────── common GND
All three supply negatives ────────────── common GND
INA3221 GND and ESP32 GND ─────────────── common GND
ESP32 3V3 → INA3221 logic supply (compatible breakout only)
ESP32 GPIO21 → SDA ESP32 GPIO22 → SCL
This schematic is for three non-isolated DC circuits that are permitted to share ground. Do not use one INA3221 board to bridge unrelated, floating, isolated or hazardous supplies: joining their negative terminals to the ESP32 ground defeats isolation and can damage equipment. For a high-side, ground-referenced installation, run only the intended positive feed through each shunt; do not connect a load in parallel with the shunt, which would bypass current measurement.
Some low-cost INA3221 boards label terminals differently or expose power-distribution links that tie channels together. Examine the copper traces or the board schematic before wiring separate voltage sources. If a module already joins the channel inputs internally, it is unsuitable for this three-different-voltage example without an appropriate redesign. Start with one correctly fused test load at a time, power off before rewiring and confirm the source-to-load path with a multimeter.
Choosing the shunt resistance and current range
A shunt trades measurable signal against heat and voltage drop. Two relationships are essential: Vshunt = I × Rshunt and Pshunt = I² × Rshunt. TI specifies a shunt-voltage measurement range of approximately ±163.84 mV. That makes the approximate theoretical current limit 1.638 A with a 0.1 Ω shunt, before allowing for overload headroom, resistor heating, connector ratings or trace width. Designing to the theoretical limit is poor practice.
| Current with 0.1 Ω shunt | Shunt voltage | Resistor heating | Load-voltage drop |
|---|---|---|---|
| 0.2 A | 20 mV | 0.004 W | 0.02 V |
| 0.5 A | 50 mV | 0.025 W | 0.05 V |
| 1.0 A | 100 mV | 0.10 W | 0.10 V |
| 1.5 A | 150 mV | 0.225 W | 0.15 V |
At 1.5 A the shunt is already close to the chip’s measurement limit, while a cheap breakout may have an undersized resistor or terminal. For a continuous installation, select a resistor with sufficient power derating and check all series elements—including fuses, wiring and connectors. Replacing the shunt with a lower resistance raises the useful current range but reduces the voltage signal at low currents. Every channel can have a different resistor, provided its own ESPHome shunt_resistance matches the hardware.
This also explains why the INA3221 is a poor choice for measuring a sleeping ESP32 at tens of microamps. With a 0.1 Ω shunt, a 1 mA change produces only 0.1 mV; offset and quantisation start to matter. Use a measurement instrument designed for microamp-scale current when deep-sleep optimisation is the goal.
Complete ESPHome YAML for three channels
Create a device in ESPHome, select the correct ESP32 variant and use the code below as a starting point. Substitute your normal device name and Wi-Fi secrets; do not overwrite an existing device’s API encryption key. This example uses the official ina3221 platform and explicitly sets each shunt to 0.1 ohm. ESPHome’s component documentation shows the same channel keys: channel_1, channel_2 and channel_3.
esphome:
name: ina3221-power-monitor
friendly_name: INA3221 Power Monitor
esp32:
board: esp32dev
framework:
type: esp-idf
logger:
api:
ota:
- platform: esphome
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
ap:
ssid: "INA3221 Recovery"
password: !secret fallback_ap_password
captive_portal:
i2c:
sda: GPIO21
scl: GPIO22
scan: true
frequency: 100kHz
sensor:
- platform: ina3221
address: 0x40
update_interval: 10s
channel_1:
shunt_resistance: 0.1 ohm
bus_voltage:
name: "Router Bus Voltage"
shunt_voltage:
name: "Router Shunt Voltage"
entity_category: diagnostic
current:
name: "Router Current"
power:
name: "Router Power"
channel_2:
shunt_resistance: 0.1 ohm
bus_voltage:
name: "Five Volt Bus Voltage"
shunt_voltage:
name: "Five Volt Shunt Voltage"
entity_category: diagnostic
current:
name: "Five Volt Current"
power:
name: "Five Volt Power"
channel_3:
shunt_resistance: 0.1 ohm
bus_voltage:
name: "Auxiliary Bus Voltage"
shunt_voltage:
name: "Auxiliary Shunt Voltage"
entity_category: diagnostic
current:
name: "Auxiliary Current"
power:
name: "Auxiliary Power"
ESPHome’s shunt_voltage entity is expressed in volts. A 0.04 V reading across a 0.1 Ω resistor corresponds to 0.4 A. Avoid labelling that reading “40 V” just because the number is sometimes displayed as 40 millivolts in a chip datasheet. If your board uses 0.05 Ω on channel 2, change only channel 2 to shunt_resistance: 0.05 ohm.
The YAML uses a ten-second polling interval for a useful dashboard; the default is 60 seconds. This is not a high-speed oscilloscope or a protection relay, and transient startup spikes may not appear in Home Assistant. Keep the production configuration simple until you have verified each channel with a known load.
First power-up and measurement checks
- With every power source disconnected, check for unintended continuity between a channel’s source and load terminals other than the fitted shunt. Confirm the shunt marking and ensure no two independent supply positives are unintentionally linked by the breakout.
- Power only the ESP32 and INA3221 logic interface. Open ESPHome logs. With
scan: true, the chip should normally appear at0x40; no visible address means you must fix supply, SDA/SCL, pull-ups or the board address before adding loads. - Connect one small, fused DC load to channel 1 and use a multimeter to check both the actual load voltage and the shunt drop. Confirm the reported current is plausible and positive with supply on
CH1+and load onCH1−. - Repeat for channels 2 and 3, preferably with distinct load voltages or currents. If switching channel 2 changes channel 1, inspect the terminal wiring and any shared copper connections on the breakout.
- Log normal idle, peak and startup behaviour, then select proper fuses, shunt ratings, wire sizes and enclosure ventilation before unattended use.
The INA3221 offers four I²C addresses via its address-configuration pin: 0x40, 0x41, 0x42 and 0x43. Modules do not all expose that pin in the same way. If the scan shows another address, confirm the board’s jumper or A0 wiring and update address: accordingly; do not blindly try all addresses when other I²C devices are attached.
Calibration: compare against a multimeter
A fixed resistor marking is a useful starting point, not a precision calibration certificate. With a stable load, compare the INA3221 current to a known-good series ammeter. If the sensor reads 0.47 A while the meter reads 0.50 A, check for a shunt-value mismatch and loose connections first. The resistor implied by the measured shunt voltage is R = Vshunt / Ireference. For instance, 0.047 V across a known 0.50 A load implies 0.094 Ω. Set that measured value only after validating the test equipment and repeating the measurement at another load.
You can apply ESPHome sensor filters to smooth noise, but smoothing does not repair a wrong shunt value or clipped hardware readings. Do not add an arbitrary multiplier to a derived power value while leaving current incorrect: the dashboard will then contain mutually inconsistent measurements. Correct the underlying hardware configuration, then check voltage and current separately.
Showing all three loads in Home Assistant
When the device appears through the ESPHome integration, put each rail’s bus voltage, current and power on one dashboard. A useful arrangement is three Entities cards for instantaneous readings, followed by a history graph of all three power entities. Set sensible display precision: more decimal places do not mean the shunt or breakout became more accurate.
To convert watts into an accumulated energy value, create one Integral helper per power entity in Settings → Devices & Services → Helpers. Select the appropriate power sensor, integrate over hours and use the k prefix if you want kWh from a W input. Home Assistant’s Integral integration documents the calculation. For example, a steady 5 W load uses approximately 0.005 kWh in one hour.
For regular consumption reports, create a Utility Meter helper from each resulting energy sensor and select daily or monthly cycles. The Utility Meter documentation explains how those cycles reset. Do not give a raw current sensor the energy device class: amperes measure flow of electrical charge, not accumulated energy. Decide whether your use case needs signed net flow or only positive consumption before importing values into an Energy dashboard.
Software integration has a limitation: if the ESP32 or Home Assistant is offline, unobserved load changes cannot be reconstructed. Short-lived spikes may be missed at ten-second reporting intervals, and some dashboard integration methods assume the last measured value persists until a new one arrives. For billing or critical long-term accounting, use a meter with its own validated energy accumulator and suitable retention strategy.
Example automations worth building
Alert when a supply rail falls
A router running from a nominal 12 V DC supply might deserve an alert if channel 1 stays below a threshold chosen from your own measured normal operating range. In Home Assistant, add a Numeric state trigger on the Router Bus Voltage entity, a short duration to reject momentary dips, and a notification action. Use a separate unavailable-state alert; no reading is not the same as a healthy voltage.
Find unexpected standby consumption
Record typical idle and active power separately for each load. Compare nightly averages rather than reacting to one sample. If the auxiliary rail is expected to switch off, monitor whether its power remains elevated for several minutes after shutdown. This can reveal an accessory, peripheral or relay whose standby demand is larger than expected.
Estimate supply capacity before adding loads
Sum the three measured channel powers only when they represent separate loads and do not double-count an upstream rail feeding the other two. A 12 V input feeding a 5 V converter and then a 5 V output cannot be counted as two independent consumptions. Use upstream power minus downstream power to estimate conversion losses, bearing in mind different sample times and sensor error.
Troubleshooting common INA3221 problems
| Symptom | Likely explanation | What to check |
|---|---|---|
| No 0x40 device in logs | Wrong I²C pins, voltage, address or pull-ups | Measure VS; swap only SDA/SCL if miswired; inspect A0 and scan output. |
| Voltage appears but current is zero | Positive load wire bypasses the shunt or its path is open | Trace actual current path from source through CH+ and CH− to load. |
| Negative current | CH+ and CH− reversed or actual reverse power flow | Confirm polarity with a meter; do not mask reverse flow blindly. |
| Current differs by a fixed factor | Incorrect channel shunt value | Inspect each resistor marking and verify its actual resistance. |
| Current stops rising at high load | Shunt-voltage range reached; possible thermal limit | Reduce load and redesign shunt/wiring for adequate headroom. |
| Multiple channel readings change together | Loads share a supply, wiring is crossed, or board links channels | Check rails, traces and each channel’s actual positive feed. |
| ESP32 resets when a load switches | Supply dip, noisy ground or load transients | Power ESP32 separately as needed; improve layout and transient protection. |
| Energy rises during a network outage | Integral helper interpolates or holds stale power | Check unavailable-state behaviour; do not treat inferred energy as metered data. |
A bus-voltage display of zero can mean the load supply is genuinely off, but a completely unavailable ESPHome entity points instead to a communication or device problem. Do not build safety-critical shutdowns that rely exclusively on Home Assistant connectivity or a consumer-grade breakout.
INA3221 vs INA226: which fits the project?
The earlier INA226 guide is useful when one DC supply needs dedicated monitoring and you want to study one channel’s shunt selection in detail. The INA3221 is more convenient when three related, common-ground DC loads need separate readings with just one I²C address. Its monitored bus limit is 26 V, so it is not a drop-in replacement for a higher-voltage monitor. Check the real voltage range and shunt power before choosing a sensor.
If the loads cannot share ground, require galvanic isolation, exceed the analog voltage limits or involve AC mains, use a measurement architecture designed for those conditions. Adding a level shifter to SDA/SCL does not isolate the measured circuits or extend the INA3221’s analog input limits.
References and next steps
- ESPHome INA3221 component — supported YAML keys, per-channel shunt values, units and I²C defaults.
- Texas Instruments INA3221 product information — 26 V range, supply requirements and channel capabilities.
- Adafruit INA3221 wiring guide — a clearly labelled example of source-side and load-side connections.
- Home Assistant Integral helper and Utility Meter — converting measured DC power into energy and period totals.
Start with a single known, fused load and compare voltage, shunt drop and current against a multimeter. Once those three readings agree, add the other two channels, calibrate each shunt independently and build the Home Assistant dashboard. That sequence avoids the most common mistake with three-channel monitors: beautiful graphs for three loads that were never actually routed through three separate resistors.