The INA226 is a compact way to turn an ESP32 into a DC voltage, current and power monitor. It reads the tiny voltage across a series shunt resistor, measures the circuit voltage, and reports both over I²C. With ESPHome, those measurements can appear in Home Assistant alongside a calculated energy total. It works well for monitoring a low-voltage DC load, bench power supply, battery-powered project or small solar experiment—provided the breakout, wiring and shunt are rated for the circuit.
There are two different electrical systems to keep straight. The ESP32 and INA226 communicate on a 3.3 V logic bus; the load being measured may use a higher DC voltage. The INA226 silicon supports bus-voltage measurement up to 36 V, but that specification does not make a bare module suitable for arbitrary battery packs, mains wiring, or unrestricted load current. This guide starts with a modest, current-limited 12 V load and shows how to verify the hardware before adding it to a permanent installation.
What the INA226 actually measures
The INA226 has a shunt-voltage measurement and a bus-voltage measurement. Put a known resistor in series with the load and the voltage across it tells you the current: I = Vshunt / Rshunt. The chip uses a calibration register to report current and power in useful units; ESPHome configures that calibration using the shunt resistance and expected maximum current you provide.
For a common high-side setup, current flows from the supply through the shunt to the load. The measured bus voltage is the monitored positive node on the load side of the shunt for modules that connect their bus-sense input there. It will normally be slightly below the power supply voltage because the shunt drops a small voltage. Check your exact module schematic: not every breakout brings the chip’s VBUS sense connection to the same point.
| Reading | Meaning | Unit |
|---|---|---|
| Bus voltage | DC voltage at the module’s bus-sense point | V |
| Shunt voltage | Differential voltage across the current-sense resistor | V |
| Current | Signed current calculated using the configured shunt | A |
| Power | Reported electrical power for the monitored circuit | W |
Power is an instantaneous rate of energy use, not an energy total. A load drawing 12 W for three hours consumes approximately 36 Wh (0.036 kWh), assuming its power stays constant. ESPHome can integrate the power readings over time, but the INA226 itself is not a non-volatile energy meter. Readings missed during a device outage cannot be reconstructed afterward.
What you need
- An ESP32 development board with a reliable USB supply and two usable I²C GPIOs. The wiring below uses GPIO21 for SDA and GPIO22 for SCL on a conventional ESP32; change them for other boards.
- An INA226 breakout with a known, readable shunt resistor value, plus a module schematic or clear terminal labels.
- A regulated, current-limited low-voltage DC supply and a suitable resistive or electronic test load. Start with a modest current rather than a motor or an automotive electrical system.
- Appropriately rated wiring, a fuse if warranted by the power source, a multimeter, and ESPHome with Home Assistant for the optional dashboard.
Important: This is a DC monitor. Do not connect an INA226 breakout directly to 230 V mains, a mains-derived conductor, or an unfamiliar high-energy battery circuit. Neither a 36 V sensing specification nor the shunt rating provides mains isolation or protection against fault current.
INA226 versus INA219: why choose it?
Both chips use a series shunt and expose current, voltage and power over I²C. The INA226 offers a 16-bit shunt/bus measurement path, configurable ADC averaging and conversion times, and 16 possible I²C addresses. It is helpful when you want more control over the trade-off between measurement noise and response time. The INA219 remains a sensible choice for many simple loads; neither chip fixes a poor shunt, noisy supply or incorrectly wired breakout.
If your real requirement is several separately monitored load branches, budget for one shunt per branch or investigate a multi-channel device. Putting several loads downstream of one shunt measures their combined current, not a per-device breakdown.
Pinout and wiring: keep sensor power separate from measured power
| INA226 breakout pin | Connect to | Purpose |
|---|---|---|
| VCC / V+ (logic supply) | ESP32 3V3, if supported by your specific breakout | Powers INA226 and usually its I²C pull-ups |
| GND (logic) | ESP32 GND and the low-voltage measurement circuit’s negative reference | Logic and measurement reference |
| SDA | ESP32 GPIO21 | I²C data, pulled up to 3.3 V |
| SCL | ESP32 GPIO22 | I²C clock, pulled up to 3.3 V |
| VIN+ / IN+ | Supply positive, via suitable protection | Shunt upstream / supply side |
| VIN− / IN− | Load positive | Shunt downstream / load side |
ESP32 INA226 breakout
3V3 ---------------------- VCC (logic, 3.3 V)
GND ---------------------- GND
GPIO21 -------------------- SDA
GPIO22 -------------------- SCL
12 V supply (+) --- IN+ [ SHUNT ] IN- --- load (+)
12 V supply (-) ------------------------ load (-)
|
+------------------- ESP32/INA226 GND (common reference)
Use the module’s actual terminal markings; many boards label
VIN+/VIN- differently from VCC or VBUS.
The shunt must sit in series with the load’s positive supply conductor. Do not wire it directly across the supply: that would create a low-resistance path and could destroy the resistor, traces or source. Connect the INA226 logic supply to 3.3 V only after confirming the breakout allows it; bare INA226 devices operate from 2.7–5.5 V, but a breakout may include its own regulator, pull-ups or other circuitry.
On modules powered from 5 V, confirm where SDA and SCL are pulled up. The ESP32 GPIOs must not be driven to 5 V. Supply the sensor and pull-ups at 3.3 V when the module permits, or use a suitable bidirectional I²C level shifter for a breakout that requires 5 V logic. Sharing ground with the measured circuit is typical for this low-voltage example; the INA226 is not galvanically isolated.
A common source of confusion is the VBUS label. On the INA226 chip, VBUS is a separate bus-voltage sense input; on some modules it is internally linked to the shunt’s load side. Other boards expose it separately. Follow the board schematic instead of assuming that a terminal marked “VIN” powers the sensor logic.
Check the shunt before powering the load
A printed code such as R100 typically indicates 0.100 Ω and R010 typically indicates 0.010 Ω. The code is a clue, not a substitute for a seller’s schematic, the resistor specification or a suitable low-resistance measurement. Use the actual value fitted to your module in ESPHome. If the hardware has been modified or a different resistor has been installed, change the software value too.
The INA226 shunt measurement range is about ±81.92 mV. For a 0.100 Ω resistor, the corresponding maximum measurable current is approximately 0.819 A; for 0.010 Ω it is approximately 8.19 A. That is a chip measurement-range calculation, not a promise that the module’s resistor, PCB trace, connector or cable can carry that current safely.
| Shunt fitted | At 0.5 A: drop / heat | At 2 A: drop / heat | Approximate chip shunt-range current |
|---|---|---|---|
| 0.100 Ω | 50 mV / 0.025 W | 200 mV / 0.4 W (out of shunt range) | 0.819 A |
| 0.010 Ω | 5 mV / 0.0025 W | 20 mV / 0.04 W | 8.19 A |
These values come from V = I × R and Pshunt = I² × R. As current rises, resistor heating rises with the square of current. Check the resistor’s rated continuous dissipation, temperature rise, board traces, terminal block and conductor size independently. A module advertised as “20 A” may use external current-sense hardware that differs from the small breakout shown here.
There is a second practical limit: if the shunt is too small for the current you want to resolve, its voltage signal becomes tiny relative to offsets, wiring errors and electrical noise. A lower-resistance resistor reduces wasted power but makes very small currents harder to measure accurately. Choose the resistor for your normal operating range, not solely the largest current printed in a product listing.
Find the I²C address
With the module wired only on the logic side and its supply verified, run an ESPHome I²C scan. The INA226 commonly appears at 0x40 when address pins A0 and A1 are grounded. The device supports 16 combinations from 0x40 to 0x4F by wiring those address pins to appropriate logic/SDA/SCL signals according to its specification. Breakout solder jumpers do not all implement the same routing, so verify the address from the boot log instead of guessing.
i2c:
sda: GPIO21
scl: GPIO22
scan: true
frequency: 100kHz
If scanning reports nothing, check VCC, common GND, SDA/SCL reversal, the breakout address jumpers and 3.3 V pull-ups. An I²C scan proves that a device acknowledged an address; it does not prove that the high-current terminal wiring, shunt value or bus-voltage path is correct. If you already have an I²C bus configured for another sensor, add this monitor to that same bus rather than defining a second conflicting bus on identical pins.
Complete ESPHome configuration for an ESP32
This is a starting configuration for a conventional ESP32 development board and a module with an actual 0.100 Ω shunt. It deliberately sets max_current: 0.8A rather than claiming a 3 A range that the example shunt cannot measure. For an R010 module and suitable load hardware, change shunt_resistance to 0.01 ohm and choose the correct expected current. Replace the Wi-Fi and API secrets with your own.
esphome:
name: ina226-dc-monitor
friendly_name: INA226 DC Monitor
esp32:
board: esp32dev
framework:
type: esp-idf
logger:
api:
encryption:
key: !secret ina226_dc_monitor_api_key
ota:
- platform: esphome
encryption:
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
i2c:
sda: GPIO21
scl: GPIO22
scan: true
frequency: 100kHz
sensor:
- platform: ina226
address: 0x40
shunt_resistance: 0.1 ohm
max_current: 0.8A
adc_time: 1100us
adc_averaging: 16
update_interval: 10s
bus_voltage:
name: "DC Bus Voltage"
id: ina226_bus_voltage
accuracy_decimals: 3
shunt_voltage:
name: "DC Shunt Voltage"
accuracy_decimals: 5
current:
name: "DC Current"
id: ina226_current
accuracy_decimals: 3
power:
name: "DC Power"
id: ina226_power
accuracy_decimals: 2
The OTA encryption block shown here is suitable for a new device initially flashed over USB with ESPHome 2026.9 or later. If you are adapting an already-deployed password-based OTA device, do not replace its password with encryption: in one step; follow the staged migration in the current ESPHome OTA documentation, or use an initial serial flash. On a fresh device, generate and store the API encryption key securely in secrets.yaml; the OTA block reuses that same key.
The example requests a reading every ten seconds but averages 16 conversions internally. adc_time and adc_averaging affect the converter’s behaviour; update_interval controls how often ESPHome publishes readings. Increasing the update interval by itself does not turn the sensor into an accumulating watt-hour meter. Start with moderate averaging, watch how quickly your load changes, and increase it only if the actual measurements are noisy.
Test the readings against a known load
Start with the load disconnected and the measured supply off. The I²C device should still be discoverable if its logic side is powered. With the supply turned on and the load disconnected, the bus voltage may be present while current and power remain near zero. An exact zero is not guaranteed: offset, noise and the chosen resistor value affect the result. Do not “calibrate” an unexpectedly large reading away until you have checked the wiring.
Next, connect a current-limited load that stays within your shunt’s voltage and thermal limits. For illustration, a nominal 12 V / 0.25 A load should produce about 3 W of load power, a 25 mV shunt drop through 0.100 Ω and approximately 0.00625 W of heat in that resistor. Compare the ESPHome current with a series-connected multimeter or a trusted bench-supply current display. A normal handheld multimeter on its current range must also be connected in series, never across the supply.
If voltage looks plausible but current is consistently ten times too high, inspect the resistor marking and configured shunt_resistance. The common R100/R010 mismatch causes an almost exactly tenfold error. If current reads negative, check whether IN+ and IN− are reversed or whether the real current is flowing in the opposite direction, as it can in a bidirectional battery circuit. Do not use an absolute-value filter simply to hide an unexplained sign.
Add energy in Wh or kWh
The INA226 publishes power in W, which is a snapshot. To estimate consumed energy, integrate successive power readings over time. You can do this in ESPHome or with a Home Assistant integration helper; only add one calculated energy entity for the same source unless you have a specific reason to compare them. The following optional block is added under the existing sensor: list, not as a second top-level sensor: key.
- platform: integration
name: "DC Energy Since Reset"
sensor: ina226_power
time_unit: h
integration_method: trapezoid
unit_of_measurement: Wh
accuracy_decimals: 2
device_class: energy
state_class: total_increasing
restore: false
This optional example assumes the load only consumes power, so the integrated value is non-decreasing. It deliberately starts again after a reboot because restore: false avoids repeated flash writes. For historical energy reporting across outages, use Home Assistant’s integration helper and Recorder, or select a deliberate ESPHome restore strategy after reviewing the flash-wear and outage trade-offs. If the current can reverse—for example, battery charging and discharging—the integrated net energy can decrease. Do not label that net value total_increasing; split positive and negative power into separate charging/discharging energy streams instead.
A further subtlety: the integration estimates area between measured points. Fast load pulses that occur entirely between ten-second updates can be missed. For pulsed loads, publish more frequently or use a suitable hardware meter. Neither ESPHome nor Home Assistant can infer energy consumed while the ESP32 was powered down. For a daily-reset total, ESPHome also offers Total Daily Energy, which needs a time source and has its own restore behaviour.
Home Assistant dashboards and meaningful alerts
Once ESPHome is added through Home Assistant’s native API, add Bus Voltage, Current and Power to a history graph. Use a gauge for current only after confirming the correct shunt range; a gauge capped at 20 A does not mean the hardware is safe at 20 A. Plot voltage and current separately when diagnosing loads that sag under startup current, and keep the raw shunt reading available during commissioning even if you hide it from your final dashboard.
For a DC load, a low-voltage automation may be more valuable than an elaborate energy chart. Example: notify when the 12 V bus stays below an appropriate application-specific threshold for a minute. Choose the threshold from the load and battery specifications rather than copying a generic “low battery” voltage. A 12 V lead-acid battery, a 3S lithium-ion battery and a regulated 12 V adapter need entirely different interpretations.
For the Home Assistant Energy dashboard, verify that the selected entity is an energy sensor with supported Wh/kWh units and an appropriate total or total_increasing state class. A raw watt reading cannot substitute for watt-hours. Check Settings → Developer Tools → Statistics for problems if your derived entity does not appear. The HA Energy dashboard may also distinguish grid consumption, solar generation and battery flows; a generic load energy sensor belongs in the category that actually matches what it measures.
Calibrating for accuracy without disguising errors
First verify the shunt resistance and measure the circuit’s actual operating current. For moderate currents, inspect all screw terminals and solder joints because contact resistance and long, thin sense wires can introduce voltage drops. A four-terminal/Kelvin connection to the shunt reduces the effect of current-carrying copper on the measured differential voltage. Many inexpensive breakouts do not provide true Kelvin sensing, which limits their performance regardless of the INA226’s nominal ADC resolution.
Compare bus voltage against a reliable multimeter connected to the same point relative to circuit ground. Measuring directly at the power supply while INA226 senses the load side of the shunt can legitimately produce different voltages. Repeat current comparisons at a low and a moderate current. An offset that is most visible near zero and a scale error that grows with current point to different problems; do not apply a blanket multiplication filter before checking the physical circuit.
Keep the shunt cool. Its resistance may drift with temperature, and sustained high current can warm the module enough to alter accuracy or damage the resistor. Good software calibration does not compensate for an undersized power path. When comparing your monitor to a bench supply, remember that the supply often includes current used by the ESP32 itself if both share that source; decide whether you intend to measure the load only or the whole system.
Troubleshooting: the symptoms that matter
| Symptom | Likely checks |
|---|---|
| No 0x40 in ESPHome scan | Logic supply, common ground, address jumpers, SDA/SCL pins, 3.3 V pull-ups |
| Voltage is present, current near zero under load | Load bypasses the shunt, terminals miswired, blown/open shunt, incorrect current measurement path |
| Current is ten times expected | R100 versus R010 resistance mismatch or incorrectly entered ohms |
| Current is negative | Current-flow direction versus IN+/IN− orientation |
| Current clips or stops increasing | Shunt voltage exceeds about ±81.92 mV; check hardware and expected maximum current |
| Readings jump when motor starts | Power-supply sag, switching noise, wiring inductance, I²C integrity or insufficient averaging |
| Energy total drops on reboot | Restore setting, HA integration persistence, or unsuitable state class for signed/net energy |
If the I²C scan identifies 0x40 but the sensor is unavailable in Home Assistant, look at the ESPHome serial or network log before changing wires. An I²C communication warning and a Home Assistant API connection problem are different faults. If both fail only when the load switches on, investigate supply dips and shared-ground currents; adding software filtering is not a cure for ESP32 brownouts.
For higher-current systems, switch to a properly specified external shunt and a module designed for remote Kelvin connections. For systems above the INA226’s 36 V monitored-bus limit or those that demand electrical isolation, select a different sensing architecture. An MCU in a plastic box is not a substitute for fusing, a tested enclosure and thermal design.
Which projects benefit most?
A small solar charger can use this monitor to track output voltage and current as long as the monitored voltage, shunt and wiring stay within their actual ratings. In a workshop, it can expose changes in a 12 V pump’s power draw and help catch stalled operation or a loose connection. For a battery-powered ESP32 project, measuring only the downstream sensor load may reveal useful power savings—but remember that a Wi-Fi-connected ESP32 plus INA226 itself also consumes energy and may be excluded from that measurement path.
If the goal is simply to read a free analogue voltage, the ADS1115 with ESPHome guide covers ADC measurement, scaling and input protection. The INA226 is different: its calibrated series shunt lets you estimate current and electrical power without needing separate voltage- and current-conversion formulas in each ESPHome template.
Frequently asked questions
Can I connect a 24 V load while powering the INA226 from the ESP32’s 3.3 V pin?
The INA226 silicon can monitor a suitable DC bus up to 36 V independently of its 2.7–5.5 V logic supply. That does not authorize every breakout, wire, terminal, shunt or battery chemistry. Check the module’s circuit and the supply’s fault-energy characteristics first. Keep SDA/SCL at ESP32-safe logic levels and make sure the sensing and ground connections follow the board documentation.
Can I measure the current without breaking the positive cable?
Not with the standard in-series shunt method. The load current must pass through the shunt so that a measurable voltage develops across it. A Hall-effect sensor or properly isolated current transducer is a different approach for applications where the conductor cannot be interrupted or galvanic separation is required.
Can two INA226 boards use one ESP32?
Yes. Give each board a unique I²C address and a separate, correctly rated shunt for its own load branch. The chip provides 16 programmable addresses; breakout jumpers may expose fewer combinations. If address changes are impractical, an I²C multiplexer can isolate identical-address boards, but it does not remove the need for individual current paths.
Does max_current in ESPHome change the physical current range?
No. It configures the INA226 calibration and numeric scaling. The ±81.92 mV shunt measurement limit remains physical. For a 0.100 Ω resistor, the approximate full shunt-voltage range corresponds to only 0.819 A even if you enter 10 A in software. Hardware current and thermal limits may be lower still.
Can I monitor a rechargeable battery in both directions?
The INA226 supports bidirectional shunt sensing. Depending on the wiring, charging and discharging produce opposite current signs. For reporting separate charge and discharge energy in Home Assistant, calculate separate non-negative power streams before integrating them. Be wary of assuming that a single signed net-energy counter will behave like a standard monotonically increasing utility meter.
Official references and further reading
- ESPHome: INA226 DC current and power sensor — current YAML options, update interval, ADC timing and exposed entities.
- Texas Instruments: INA226 product information and electrical specifications — supply, 36 V sensing range and shunt-voltage limits.
- ESPHome: Integration Sensor — watt-to-watt-hour calculation and restore trade-offs.
- Home Assistant Energy FAQ — supported units, state classes and entity eligibility.
- ESPHome: OTA Updates — current encrypted OTA format and migration for existing devices.