Ships from Alingsås, Sweden · Free shipping from 149 SEK · Swedish support by email and phone
Measure power and energy with ESP32 in Home Assistant

Measure power and energy with ESP32 in Home Assistant

2/12, 2026 –

Do you want to know what your camper battery is charging, how much a machine draws, or what a heater costs to run? With an ESP32 board and an M5Stack measuring unit you can bring the numbers into Home Assistant and use them in the energy dashboard. This guide helps you choose the right unit, shows a simple project and is clear about what you should not do yourself.

Important: mains voltage (230 V)

All work on 230 V must be carried out by a qualified electrician. That applies to the AC Measure Unit (U164) and to any measurement in or on fixed electrical installations. The low-voltage meters in this guide (INA226, Voltmeter, Ammeter) are for DC only and must never be connected to mains voltage.

First: what do you want to measure?

  • DC (12 V, 24 V, solar, battery): you need a DC voltage and current meter.
  • AC 230 V: you need an isolated mains meter, installed by an electrician.
  • An existing energy meter or inverter with RS485/Modbus: then you do not need your own meter, only an RS485 connection to read it.

Which part fits what

ProductMeasuresRange
INA226 10 A (U200)Voltage, current and power (DC)0–30 V, ±10 A, I2C
INA226 1 A (U200-1A)Same, for small currentsUp to 1 A
Ammeter Unit (U086)Isolated current±4 A
Voltmeter Unit (U087)Isolated voltage±36 V
AC Measure Unit (U164)Voltage, current and power (AC, isolated)100–240 V, up to 10 A, I2C. Electrician required.
Atomic RS485 Base (A131)Reads Modbus devices over RS4856–24 V in

INA226 for DC

The INA226 10 A (U200) is the easiest choice for batteries and solar systems: it measures 0–30 V and ±10 A, current in both directions, so you see both charging and consumption. For small loads, such as a sensor node or a pump, the INA226 1 A (U200-1A) gives better resolution. ESPHome has a ready-made component (ina226). The unit talks I2C at address 0x41.

Ammeter and Voltmeter when you need isolation

The Ammeter Unit (U086) and Voltmeter Unit (U087) are isolated meters, useful when the measuring point sits at a different ground potential than your ESP32 board. They cost more than the INA226, so choose them when isolation is actually needed. Always check the measuring range in M5Stack's documentation against your circuit.

AC Measure for 230 V (electrician)

The AC Measure Unit (U164) measures voltage, current and power on single-phase AC, isolated, over I2C (address 0x42). It must be mounted and wired by a qualified electrician. Only buy it if you have an electrician who will do the installation. Note that we do not know of a ready-made ESPHome component for this specific unit, so expect to program it with Arduino or UIFlow, or follow M5Stack's examples.

RS485 when the meter already exists

Many energy meters, solar inverters and heat pumps have an RS485 port. With the Atomic RS485 Base (A131) and an ATOM Lite (C008) or AtomS3 Lite (C124) you can read them directly. ESPHome supports Modbus and some energy meters, for example the Eastron SDM series. Installing the meter itself on 230 V is a job for an electrician.

Example project: battery monitor for a camper, boat or cabin

You need: an ATOM Lite (C008) or AtomS3 Lite (C124), an INA226 10 A (U200), a Grove cable (for example the Grove cable 10 cm (A034)) and 5 V over USB-C.

  1. Connect the INA226 in series with the positive wire between the battery and the load. Double-check the polarity and that the voltage is below 30 V.
  2. Plug the INA226 into the Grove port on the board.
  3. Add an ESPHome configuration. Take the shunt and maximum current values from M5Stack's documentation for the U200:
i2c:
  sda: GPIO26
  scl: GPIO32

sensor:
  - platform: ina226
    address: 0x41
    shunt_resistance: 0.005 ohm   # U200 (10 A). For U200-1A: 0.08 ohm
    max_current: 10 A             # U200-1A: 1 A
    bus_voltage:
      name: "Battery voltage"
    current:
      name: "Battery current"
    power:
      name: "Battery power"

The pins above are for the ATOM Lite. On the AtomS3 Lite the Grove port is on GPIO2 (SDA) and GPIO1 (SCL).

  1. Add the device in Home Assistant. For the energy dashboard you need kWh or Wh: create an Integration (Riemann sum) helper on the power sensor, or use the ESPHome integration component.

Getting started

  • Decide what you will measure and whether it is DC, AC or a bus.
  • Pick a meter from the table and an ESP32 board with a Grove port.
  • Test the ESPHome configuration on the bench with a low-voltage source before you build anything in.
  • Fit a fuse close to the battery and use cables of sufficient thickness.

FAQ

Can I measure 230 V with the INA226?

No. The INA226 is for DC up to 30 V only. For 230 V you need a unit made for it, such as the AC Measure Unit (U164), installed by an electrician.

Which ESP32 board should I choose?

Any M5Stack board with a Grove port works. The ATOM Lite (C008) and AtomS3 Lite (C124) are the most common for ESPHome.

Can I get kWh in the energy dashboard?

Yes. Home Assistant needs an energy sensor. You can convert power to energy with a Riemann sum helper or the ESPHome integration component.

How long can the cable be?

I2C is meant for short distances. Keep the Grove cable as short as possible, and for longer runs RS485 is the better choice.