ATM90E32 with ESP32 and ESPHome: Multi-Circuit AC Power Monitoring

Build an ESP32 and ESPHome multi-circuit AC energy monitor with the ATM90E32: SPI configuration, CT and voltage-reference pairing, calibration and reliable Home Assistant kWh tracking.

An ESP32 can report the live power of several AC circuits to Home Assistant without installing a separate smart plug on every appliance. An ATM90E32-based energy-meter board measures voltage, current and real power using dedicated metering hardware; ESPHome reads the chip over SPI and publishes the results over the native Home Assistant API. The difficult part is not writing YAML. It is selecting a suitable isolated metering board, pairing the right voltage reference with each current transformer (CT), and interpreting the resulting energy figures correctly.

This guide builds a three-circuit, single-phase monitoring example. It then explains what changes for six-circuit boards, split-phase supplies and true three-phase installations. It also addresses a subtle Home Assistant integration problem: the ATM90E32’s native active-energy readings are interval counts, not necessarily persistent lifetime totals.

What the ATM90E32 measures—and what it does not

An ATM90E32 can sample three voltage channels and three current channels, calculate real and reactive power, and expose metrics such as RMS voltage, RMS current, power factor and line frequency. Board designers choose which of those inputs are actually wired. Some products expose three CT channels but route a single voltage transformer to all of them. Others use two ATM90E32 chips to provide six current channels. Do not interpret “three phases” in the ESPHome YAML as proof that a particular board has three independent voltage-reference inputs.

ReadingMeaningUnit
RMS voltageAlternating-voltage magnitude at the board’s voltage referenceV
RMS currentCurrent passing through the monitored conductorA
Real/active powerRate of useful electrical energy transfer, including power-factor effectsW
Apparent powerRMS voltage multiplied by RMS currentVA
Reactive powerNon-working alternating componentvar
Power factorRatio/sign relationship of real to apparent powerUnitless
EnergyPower accumulated over timeWh or kWh

A CT by itself is only a current sensor. Without a correctly paired and calibrated voltage waveform, it cannot directly determine accurate real power, power factor or import/export direction. Multiplying measured current by an assumed 230 V gives an estimate of apparent power, not a substitute for active-power metering on all types of loads.

Choose the meter board before choosing the wiring

For a practical first build, use a commercially designed ATM90E32 metering board with its own documented CT inputs and isolated AC-voltage reference. The ESP32 is the user interface and network endpoint; it does not make an unknown metering PCB suitable for a distribution board. A bare ATM90E32 chip or unverified open-frame module is not a drop-in, safely isolated smart-meter product.

  • Single-phase, three-circuit monitor: one suitable voltage-reference input, with three CTs fitted to individual circuits on that same phase, is an understandable starting point.
  • Six-circuit monitor: a board with two ATM90E32 chips needs two distinct chip-select pins and two atm90e32 instances; the chips may share SCLK, MOSI and MISO.
  • Split-phase or three-phase monitoring: confirm that the PCB has the necessary independent voltage sensing and that every current channel is assigned to the matching voltage phase.
  • Solar import/export: use the manufacturer’s supported wiring arrangement and verify polarity and direction against a trusted reference meter; a positive RMS current number cannot show direction on its own.

Check the board revision, transformer specification, CT type and connector pinout against its actual manual. Example gain numbers published for one CircuitSetup revision and transformer combination can be dramatically wrong on another. A “100 A CT” is also not sufficient identification: a 100 A:50 mA current-output CT and a 100 A:1 V voltage-output CT need different analogue front ends.

Mains safety: keep the ESP32 side isolated

Work inside an electrical panel, install circuit CTs and connect the voltage-reference transformer only through a qualified electrician. De-energising, securing and verifying the circuit must follow local electrical rules; do not remove a panel cover or clamp a conductor just to test a YAML example. The protective enclosure, conductor separation, creepage/clearance, fusing, wire strain relief and measurement category of the complete installation matter as much as the chip selected.

A split-core CT normally encloses one conductor only—not live and neutral together, whose magnetic fields largely cancel. It must be rated for that conductor, installation environment and expected current. Keep CT secondary connections in the condition required by the CT manufacturer; some current-output CTs can generate hazardous secondary voltage if opened while primary current flows. Never treat an energised CT secondary as a harmless GPIO lead, and never unplug a CT on a live circuit unless the meter/CT maker explicitly provides a safe procedure.

Use only the board’s documented low-voltage SPI interface to connect the ESP32. A correctly isolated voltage transformer is different from a simple resistor divider connected to live mains. Do not put mains voltage, a raw current-transformer output or a 5 V SPI signal on ESP32 GPIO pins.

ESP32-to-meter SPI wiring

The reference below uses the familiar ESP32 DevKit SPI pins. These are example MCU GPIO assignments, not a universal connector pinout. Follow the meter board’s documentation for power input, logic voltage, jumper configuration and the actual SPI header. Confirm whether the board supplies the ESP32 itself and whether its signal outputs are 3.3 V-compatible.

ESP32 DevKit GPIOSPI functionATM90E32 board connection
GPIO18SCLK / clockDocumented SCK input
GPIO19MISODocumented meter data output
GPIO23MOSIDocumented meter data input
GPIO5Chip select for first ICDocumented CS1 input
Second available GPIO, if usedChip select for second ICDocumented CS2 input
3.3 V / GND as requiredLogic power / common referenceUse the board’s specified isolated low-voltage supply and ground

SCLK, MOSI and MISO can be shared between several SPI devices, but each ATM90E32 requires its own chip-select signal. Other ESP32 models, including C3 and S3 boards, can have different usable GPIOs and bootstrapping constraints; adapt the pin assignments rather than copying this DevKit pinout uncritically. Keep the low-voltage SPI wires short and away from noisy or mains wiring.

Before flashing: identify your measurement topology

Label the meter inputs in terms of the actual installation, such as “water heater”, “oven” and “office sockets”. Avoid labelling the code’s phase_a, phase_b and phase_c as L1, L2 and L3 unless the hardware really measures those separate supply phases. In the following single-phase example, the three labels represent three individual circuits on one supply phase, not a complete three-phase house meter.

Have the electrician document which voltage-reference input is connected to which supply phase and which CT belongs to each channel. This mapping is critical for real-power accuracy. An apparently plausible current reading can coexist with a completely wrong active-power or power-factor reading when the waveform reference is mismatched.

Complete ESPHome YAML: three circuits on the same phase

This configuration is a starting point for a board wired like a compatible six-channel CircuitSetup main board, using its first ATM90E32 IC, with a board-appropriate isolated voltage reference and three CTs on the same supply phase. It uses sample calibration values reported for a particular board/transformer/CT combination; replace them with your manufacturer’s values before relying on any measurement. Also replace the secrets, ESP32 board name and pins for your own installation. Do not attach an undocumented voltage input to try this example.

substitutions:
  device_name: ac-circuit-meter
  friendly_name: AC Circuit Meter
  voltage_gain: "7305"       # Example only: verify board revision + transformer
  ct_gain_1: "27961"          # Example only: compatible 100 A:50 mA CT
  ct_gain_2: "27961"
  ct_gain_3: "27961"

esphome:
  name: ${device_name}
  friendly_name: ${friendly_name}

esp32:
  board: esp32dev
  framework:
    type: esp-idf

logger:
api:
  encryption:
    key: !secret api_encryption_key
ota:
  - platform: esphome
    password: !secret ota_password
wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password

spi:
  clk_pin: GPIO18
  miso_pin: GPIO19
  mosi_pin: GPIO23

sensor:
  - platform: atm90e32
    id: ac_meter_1
    cs_pin: GPIO5
    line_frequency: 50Hz    # Use 60Hz only for a 60Hz installation
    gain_pga: 1X
    update_interval: 10s
    phase_a:
      voltage:
        name: "Supply Voltage"
        accuracy_decimals: 1
      current:
        name: "Circuit 1 Current"
      power:
        name: "Circuit 1 Active Power"
        id: circuit_1_power
      power_factor:
        name: "Circuit 1 Power Factor"
      gain_voltage: ${voltage_gain}
      gain_ct: ${ct_gain_1}
    phase_b:
      current:
        name: "Circuit 2 Current"
      power:
        name: "Circuit 2 Active Power"
        id: circuit_2_power
      power_factor:
        name: "Circuit 2 Power Factor"
      gain_voltage: ${voltage_gain}
      gain_ct: ${ct_gain_2}
    phase_c:
      current:
        name: "Circuit 3 Current"
      power:
        name: "Circuit 3 Active Power"
        id: circuit_3_power
      power_factor:
        name: "Circuit 3 Power Factor"
      gain_voltage: ${voltage_gain}
      gain_ct: ${ct_gain_3}
    frequency:
      name: "Supply Frequency"
    chip_temperature:
      name: "Meter IC Temperature"

The ESPHome ATM90E32 component documentation specifies an SPI bus with miso_pin and mosi_pin, one cs_pin per chip, and line_frequency of either 50Hz or 60Hz. It provides the phase_a, phase_b and phase_c sections used above. The names in Home Assistant are descriptive labels you control; they do not change how the analogue inputs are routed on the PCB.

Do not assume every current channel on every board can share the same voltage reference. That is appropriate for this illustration only because all three monitored circuits are on the same phase and the board is designed for that arrangement. On a different topology, the sensor may publish apparently sensible current while its real-power readings are invalid.

What changes for a six-channel meter?

Many six-circuit solutions contain two ATM90E32 chips. Configure one ESPHome atm90e32 entry for the first three channels and another for the remaining three. Each entry can use the same SPI bus but requires a different chip-select GPIO. On one documented CircuitSetup main board, those are GPIO5 and GPIO4; other boards may use different pins.

# Add the following inside the EXISTING sensor: list,
# after the first atm90e32 entry. Do not add a second sensor: key.
  - platform: atm90e32
    id: ac_meter_2
    cs_pin: GPIO4          # Board-specific example; check your PCB
    line_frequency: 50Hz
    gain_pga: 1X
    update_interval: 10s
    phase_a:
      current:
        name: "Circuit 4 Current"
      power:
        name: "Circuit 4 Active Power"
      gain_voltage: ${voltage_gain}
      gain_ct: ${ct_gain_1}
    phase_b:
      current:
        name: "Circuit 5 Current"
      power:
        name: "Circuit 5 Active Power"
      gain_voltage: ${voltage_gain}
      gain_ct: ${ct_gain_2}
    phase_c:
      current:
        name: "Circuit 6 Current"
      power:
        name: "Circuit 6 Active Power"
      gain_voltage: ${voltage_gain}
      gain_ct: ${ct_gain_3}

The additional code is illustrative, not an instruction to wire six circuits onto one mains phase. Verify the second chip’s voltage-reference wiring and CT gains independently. If the board’s manufacturer supports a second voltage transformer, the phase allocation and jumpers must be set according to that specific hardware manual by the installer.

True three-phase and split-phase systems: voltage matching matters

For real-power measurement, voltage and current must correspond to the same electrical phase. On a three-phase building supply, using one L1 reference while measuring the current of an L2 or L3 circuit introduces a phase-angle error. Swapping CT direction cannot fix a 120-degree reference mismatch. Similarly, North American split-phase installations require the correct leg reference when the board’s calculation relies on voltage/current phase relationships.

The ATM90E32 silicon supports multiple voltage inputs, but a particular breakout may expose only one or two of them. Before advertising a project as “three-phase monitoring”, check the schematic for three appropriately isolated voltage channels, CT-to-voltage mapping, supported nominal voltage range and manufacturer installation instructions. If those facilities are absent, choose an appropriate certified three-phase meter instead of modifying a single-voltage hobby board.

Even with the correct board, comparing its totals with the electricity utility meter requires identifying exactly what is being measured. Three CTs around three selected branch circuits are not the same as three CTs covering every incoming phase. Also ensure generation, battery inverter feeds and bidirectional flows have not been counted twice.

Calibrate voltage, current and real power in that order

The published default gains are not universal calibration constants. The correct gain_voltage depends on the transformer and metering-board revision; gain_ct depends on the CT’s transfer ratio, burden arrangement and analogue front end; gain_pga changes the chip’s current-channel amplification. Start with the board maker’s recommended values for the exact parts fitted, then compare the results with a trusted instrument.

  • Verify the voltage: compare the reported RMS voltage with a safe reference from a qualified electrician or a trusted correctly rated meter. Do not probe live panel terminals merely for hobby calibration.
  • Verify current channel by channel: compare against a suitable reference at a steady known load, avoiding a circuit whose load changes rapidly.
  • Verify active power: compare the reported watts against a reference power meter; for a nearly resistive load, power factor should be near unity, but current × voltage alone is not a general calibration standard.
  • Verify zero and low load: inspect readings with each monitored circuit off. Large phantom current or watts may indicate CT noise, channel mismatch, calibration or wiring problems.
  • Recheck after moving a CT: a different conductor or phase can change the sign and accuracy of power readings even though the amperes still look plausible.

ESPHome exposes optional enable_gain_calibration and enable_offset_calibration features for this chip. The gain workflow can use reference voltage/current number entities and calibration buttons in Home Assistant. Enable those only once the hardware mapping is verified; offset calibration requires the conditions stated in the component documentation, and a careless “zero” with a live load can make subsequent readings worse. Record the resulting gains in your YAML so you can reproduce the setup after a complete reflash.

Convert watts into a persistent Home Assistant energy history

For the default Home Assistant workflow, start with the three active-power sensors in watts. Then create one Integral (Riemann sum) helper per circuit under Settings → Devices & services → Helpers. Select the corresponding power entity, choose a time unit of hours and a metric prefix of kilo so watts are integrated into kWh. A left-hand integration method is often appropriate for power readings that hold their last value between updates; it remains an approximation, especially for short loads occurring between samples.

The integration helper can retain accumulated energy through Home Assistant restarts, but it cannot know exactly how much an appliance consumed while ESPHome or Home Assistant was offline. Increasing the update rate may improve short-load visibility at the cost of more sensor events. Check the output entity in Developer Tools for device_class: energy, a supported energy unit and a suitable cumulative state class before adding it to the Energy dashboard. Do not place the instantaneous watt sensor directly into a field requiring kWh.

ESPHome also offers forward_active_energy and reverse_active_energy for each ATM90E32 channel. These chip readings are not equivalent to a persistent lifetime meter reading: the official documentation says the chip’s per-direction accumulation counter is reset when read. Treat the published values as per-reading energy intervals, not as a cumulative sensor that you can safely label total_increasing. If you choose this route, accumulate deltas explicitly in a suitable store and test restarts, missed readings and import/export direction; otherwise use the simpler watts-to-kWh Home Assistant helper described above.

For daily or monthly totals, add the Utility Meter helper with the cumulative kWh entity as its input, not the instantaneous watts sensor. Create independent counters for circuits 1, 2 and 3. Start observing the daily or monthly totals after the relevant complete cycle; a meter created halfway through a day or month cannot reconstruct earlier consumption.

A useful Home Assistant dashboard

Display the three circuit-power sensors together on a line chart and the three cumulative energy sensors alongside their daily utility-meter counters. Label the channels with the actual appliances or circuits, not vague “phase A/B/C” names. A conditional warning can highlight an unusually high sustained load, while a graph makes it easier to spot a heater cycling, a pump repeatedly starting or an appliance using unexpected standby power.

Do not use a homemade power-monitoring node as the sole overcurrent, overtemperature, electrical-fault or fire-protection device. A CT reading is an observation, not a replacement for protective switchgear. Home Assistant automations can alert you to trends, but network failure, sensor unavailability and software delays make it unsuitable for safety-critical tripping.

Troubleshooting: identify which layer is failing

No measurements or ESPHome reports SPI communication problems

Confirm that the PCB is powered from the specified isolated low-voltage supply, its logic voltages match the ESP32, SCK/MOSI/MISO are not swapped and the first chip-select is the board’s actual CS1 line. Some breakout boards have onboard ESP32 routing that differs from an external DevKit. If two chips share SPI, confirm their CS pins are distinct and that neither is inadvertently asserted. Check the ESPHome serial logs and the exact hardware revision before changing multiple settings at once.

Current is approximately zero, but the appliance is on

Ask the electrician to verify that the CT fully closes around the intended single conductor and that the secondary/connector suits the board’s CT input. A clamp enclosing live and neutral together normally reports a small net current. A disconnected, miswired or incompatible CT can also appear dead. The absence of a reading does not prove that the conductor is de-energised.

Voltage looks plausible but watts or power factor are nonsensical

First check the CT-to-voltage phase pairing. Then verify CT orientation, the corresponding gain_ct/gain_voltage values and the actual load type. For a purely consuming load, persistent negative watts may indicate reversed CT polarity or a mismatched reference. Where a solar inverter genuinely exports energy, negative power may be expected, so do not “fix” the sign before tracing the conductor and flow direction.

Readings drift, jump or disagree with a reference meter

A high-frequency inverter, an unstable CT connection, noisy SPI wiring and incorrect calibration can each produce odd readings. Compare a stable resistive load at several power levels before trying to correct the numbers with arbitrary software filters. Filters may hide spikes but cannot repair a wrong transformer, misrouted reference waveform or a sensor operating outside its analogue range.

Energy jumps backward or grows after a reboot

Check whether you mistakenly used the ATM90E32 per-read forward-active-energy register as though it were a lifetime meter. In Home Assistant, view the energy helper’s source, units and statistics warnings. Restart the ESP32 and Home Assistant during a controlled test and compare the cumulative helper before and after. Never change a published energy entity from cumulative to interval semantics without considering existing long-term statistics.

Where this fits alongside other ESPHome energy projects

An INA226, INA260 or INA228 is intended for suitably designed DC measurements with a shunt; a PZEM-017 also monitors DC via a shunt and RS485. The PZEM-016 is a single-phase AC meter with a CT and RS485. The ATM90E32 approach is different: it provides multiple AC current channels and power-quality data from a metering IC over SPI, but its accuracy still relies on board-specific voltage sensing and calibration. Pick the architecture to match the circuit and the level of installation work it actually requires.

Final checklist

  • Use a documented isolated ATM90E32 metering board, with its required transformer and compatible CTs.
  • Have a qualified electrician verify each CT, voltage reference, enclosure and installation.
  • Confirm the three example channels are all on the same phase before using one voltage reference.
  • Match the physical CT specification and board revision to the calibration constants.
  • Keep ESP32 SPI pins at the correct logic voltage and use separate CS pins for multiple metering chips.
  • Integrate active power in Home Assistant to build cumulative kWh figures; do not mistake interval Wh readings for lifetime totals.
  • Compare voltage, current, real power and accumulated energy with a trusted reference under representative loads.

The most valuable result of a multi-circuit monitor is not a flashy real-time wattage display. It is a repeatable, labelled and calibrated history showing which loads account for consumption over time. Build the measurement chain correctly first; automation and dashboards are straightforward once the electrical data can be trusted.

Further reading and official documentation

Share your love