Skip to content

CircuitSetup/Expandable-6-Channel-ESP32-Energy-Meter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

447 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Expandable 6 Channel ESP32 Energy Meter v1.3 Main Board

CircuitSetup Expandable 6 Channel ESP32 Energy Meter

The CircuitSetup Expandable 6 Channel ESP32 Energy Meter is a real-time power and energy monitor built around two ATM90E32AS metering ICs. The main board measures six current transformer channels and one voltage reference by default, and you can stack up to six add-on boards for a total of 42 current channels. It is a good fit for whole-home monitoring, subpanels, solar, large branch circuits, and multi-voltage or 3-phase projects.

The first AC-AC adapter powers the main board and provides the primary voltage reference. A second voltage can be measured on the main board, and stacked systems can monitor additional voltage references when the hardware is configured for it.

Table of Contents

Typical Uses

  • North American split-phase 120V/240V 60Hz service: mains, solar, subpanels, and individual circuits
  • Single-phase 230V/240V 50Hz or 60Hz systems with a suitable 9VAC or 12VAC AC-AC adapter
  • 3-phase systems when each measured phase has the correct voltage reference

Features

  • 6 current channels on the main board
  • Expandable to 42 current channels and up to 8 voltage references with add-on boards
  • Built around two ATM90E32AS energy metering ICs
  • Calculates active power, reactive power, apparent power, power factor, frequency, and temperature
  • 16-bit measurement resolution
  • 22 ohm burden resistors on each current channel
  • Built-in buck converter to power the board and supported ESP32 dev boards
  • SPI interface to the ESP32
  • Energy pulse outputs, IRQ outputs, warning output, and zero-crossing signals are available on the board
  • Typical metering IC accuracy is 0.1 percent with a 6000:1 dynamic range
  • Current gain selection is available up to 4x

Quick Start: ESPHome via ESP Web Installer

The fastest way to get the meter running is to flash ESPHome directly from the CircuitSetup ESP Web Installer, connect it to your network, then adopt the device into Home Assistant.

Flash Now With the Web Installer

CircuitSetup ESPHome Installer options

  1. Open the CircuitSetup ESP Web Installer
  2. Under 6 Channel Meter, choose:
    • the number of add-on boards
    • the connection type: Wi-Fi, Ethernet (Lilygo), or Ethernet (Waveshare)
  3. Choose the firmware version
  4. Connect the ESP32 to your computer with a USB data cable
  5. Click Connect, choose the correct serial port, and start the flash
  6. If the board does not enter the bootloader automatically, hold the right or IO0 button while the installer starts
  7. If you flashed a Wi-Fi build, provision Wi-Fi after the flash
  8. Once the device is online, adjust names, calibration values, and extra sensors as needed

The current Wi-Fi configs in this repo already include captive_portal, esp32_improv, and improv_serial, so the device can be provisioned before it is ever adopted into Home Assistant.

Adopt Into Home Assistant/ESPHome Device Builder

If you want UI-based management, dashboard imports, OTA updates from Home Assistant, to change default meter/CT names, and do any other YAML editing, install ESPHome Device Builder after the first flash.

  1. Open Settings > Add-ons > Add-on Store
  2. Search for ESPHome Device Builder
  3. Install it, then click Start
  4. Click Open Web UI

ESPHome add-on install

The device should then appear in ESPHome Device Builder and in Home Assistant under Settings > Devices & services.

For package layout, local copies, calibration files, CS-pin changes, and advanced YAML examples, see Software/ESPHome/.

What You Will Need

Current Transformers

You can use any mix of supported CTs as long as the secondary output does not exceed 720mV RMS or 33mA. CircuitSetup CTs with mA output work directly with the board and do not require cutting the burden resistor jumpers on the back.

AC-AC Transformer

The meter requires an AC output transformer, not a DC wall adapter.

ESP32

Supported and documented controller options:

Boards with different pin maps are not drop-in compatible just because they are "ESP32" boards. For example, ESP32-C6 dev boards use different pins and are not part of the documented support path for this repo. If you are comparing boards visually, the documented dev boards are usually 19 pins per side, with 3V3 at the upper-left corner and CLK at the lower-right corner when installed correctly.

Software

Setting Up the Meter

Expandable 6 Channel ESP32 Energy Meter Diagram Expandable 6 Channel ESP32 Energy Meter Back Diagram

Plugging In the ESP32

The board is designed so the ESP32 dev board plugs directly into the meter.

Always insert the ESP32 with 3V3 in the upper-left corner of the meter. The lower pins are used to pass the voltage reference to add-on boards. Plugging the ESP32 into the lower row will likely short the board.

Main Board SPI and Chip-Select Pins

The meter communicates with the ESP32 over SPI.

Main board SPI pins:

  • CLK - GPIO18
  • MISO - GPIO19
  • MOSI - GPIO23
  • CS1 - GPIO5 for CT1-CT3 and Voltage 1
  • CS2 - GPIO4 for CT4-CT6 and Voltage 2

The 6-channel version of EmonESP in this repo is already set up with the main board pin defaults. Current ESPHome configs for the main board and add-on boards are in Software/ESPHome.

Add-On Boards

Each add-on board adds six more CT channels. Up to six add-on boards can be stacked on the main board.

Each add-on board has two CS jumper banks:

  • CS for CT1-CT3 on that add-on board
  • CS2 for CT4-CT6 on that add-on board

Only choose one pin per bank. The default jumper positions used by the installer and repo configs are:

Add-on board CS for CT1-CT3 CS2 for CT4-CT6
1st add-on GPIO0 GPIO16
2nd add-on GPIO27 GPIO17
3rd add-on GPIO2 GPIO21
4th add-on GPIO13 GPIO22
5th add-on GPIO14 GPIO25
6th add-on GPIO15 GPIO26

GPIO2 can interfere with programming on some ESP32 boards. If you temporarily cannot flash the ESP32 while that jumper is connected, disconnect that add-on board or move the jumper while programming, then restore the expected setting.

If you change jumper positions from the defaults, update the matching cs_pin values in your ESPHome config. See Software/ESPHome/README.md for examples.

Expandable 6 Channel ESP32 Energy Meter Add-on Diagram

CT Compatibility, Burden Resistors, and JP1-JP6

Each current channel on the board has an onboard burden resistor. That is correct for CircuitSetup CTs with mA output.

Only cut the matching rear jumper trace for a CT channel if that CT already has its own burden resistor, which is usually the case for voltage-output CTs such as 1V-output models.

In practice:

  • CircuitSetup SCT-006, SCT-010, SCT-013-000, SCT-016, and SCT-024 CTs do not require cutting JP1-JP6
  • 1V-output CTs such as SCT-013-030 or SCT-013-050 do require cutting the matching jumper trace for the channel they are connected to
  • If you are mixing CT types, only cut the jumper traces for the specific channels using CTs with built-in burden resistors

Common Calibration Starting Values

Each current channel can use its own calibration value. In the current ESPHome configs that means setting current_cal_ct1, current_cal_ct2, and so on for the main board, plus the add-on board calibration variables where needed.

Common starting values:

Sensor Calibration value
SCT-006 20A/25mA 11143
SCT-013-030 30A/1V 8650
SCT-013-050 50A/1V 15420
SCT-010 50A/16.6mA 41334
SCT-010 80A/26.6mA 41660
SCT-013-000 100A/50mA 27518
SCT-016 120A/40mA 41787
SCT-024 200A/100mA 27518
SCT-024 200A/50mA 55036
Jameco 9VAC transformer 7305

These are good starting points, not guaranteed final values. If you want tighter accuracy, use the ESPHome semi-automatic calibration workflow described below.

Measuring More Than 65A on One Channel

The ATM90E32 current register tops out at 65.535A before scaling. If you expect to measure more than that on one channel, divide the CT calibration value and multiply the reported current and power in software. Current examples are already documented in Software/ESPHome/README.md and shown in Software/ESPHome/6chan_energy_meter_main_board.yaml.

For 200A service this usually means you are monitoring a larger CT but scaling it in software so the meter stays within range.

Power Calculations and Board Revisions

The board uses voltage references to calculate power, power factor, and the other metering values.

  • v1.1 used one voltage channel per ATM90E32 by default, so some power calculations had to be done in software unless registers were remapped
  • v1.2 and v1.3 added JP8-JP11 so voltage channels could be tied together. Most v1.3 boards shipped with those connections already joined
  • v1.4 and later removed JP8-JP11 and route those voltage channels internally on the PCB

Measuring Dual-Pole 240V Circuits on Split-Phase Service

For split-phase systems, a 240V load has two hot legs. There are three practical ways to measure it:

  1. Measure one hot leg with one CT and double the current and power in software. This uses the fewest channels but is the least accurate.
  2. Measure each hot leg with its own CT. This is the most flexible option.
  3. If the wiring layout allows it and the CT opening is large enough, pass both hot legs through a single CT in opposite directions.

If a CT is not in phase with its voltage reference, current and power will read negative. On split-phase systems that usually means the CT is flipped around the wrong conductor.

Measuring a Second Voltage

The VA2 pads next to the power jack on the main board, and the VA2 pads on add-on boards, let you measure a second voltage reference.

To do that:

  1. Cut JP12 and JP13 on v1.3 and newer boards, or JP7 on older revisions
  2. Use a second AC-AC transformer, ideally the same model as the primary one
  3. Connect that second transformer to the opposite phase you want to reference
  4. Add a suitable connector or pigtail to the VA2+ and VA2- pads

When those voltage jumpers are cut:

  • CT1-CT3 stay referenced to the primary voltage
  • CT4-CT6 use the VA2 voltage reference

That means CT4-CT6 should measure circuits on the same phase as VA2, or the CT direction must be reversed so the current is in phase with the voltage reference.

On add-on boards, the primary voltage normally comes from the main board. If you wire a separate VA2 voltage reference on an add-on board, that secondary voltage is used for CT4-CT6 on that add-on board.

Measuring 3-Phase Power

For accurate 3-phase power metering you need a matching voltage reference for each measured phase.

The cleanest 3-phase setup is:

  • one main board, v1.4 or newer
  • one add-on board
  • three AC-AC transformers, one per phase
  • headers or connectors installed on the VA2 pads as needed
  • JP12 and JP13 cut on the boards where separate voltage references are being used

The first transformer connected to the main board also powers the electronics and ESP32, so it should provide at least 500mA.

With that hardware:

  • main board CT1-CT3 can reference phase 1
  • main board CT4-CT6 can reference phase 2
  • add-on board CT1-CT6 can reference phase 3, depending on how you feed voltage to that board

An alternate 3-phase approach is to use two add-on boards and feed a separate transformer into each add-on board. In that setup, the bottom VA- and VA+ feed from the main board is no longer used for those add-ons, and you wire the new transformer to the VA2 pads on each add-on instead.

If a CT is tied to a different phase than its voltage reference, active power and power factor will be wrong even if current itself looks reasonable.

Software Options

ESPHome and Home Assistant

ESPHome is still the recommended software path. If you just want to get firmware onto the meter, use the quick-start section above. The rest of this section covers what the maintained ESPHome configs already include after the device is flashed.

Useful references:

What the Default ESPHome Config Already Includes

The current repo configs are built for the current ESPHome workflow, not the older legacy setup:

  • dashboard_import so the device can be adopted into ESPHome Device Builder
  • name_add_mac_suffix: true so multiple identical meters do not collide on the network
  • ota: - platform: esphome for current OTA updates
  • captive_portal, esp32_improv, and improv_serial on Wi-Fi builds for provisioning
  • time: - platform: homeassistant in the shared packages used by the standard configs

After the first flash:

  • Wi-Fi builds can be provisioned from the browser, via Improv, or through the fallback captive portal if the device is not yet on your network
  • Ethernet builds come up on your wired network once flashed and connected
  • The device should appear in ESPHome Device Builder and in Home Assistant under Settings > Devices & services
  • You can edit the imported YAML inside ESPHome Device Builder, or copy the files locally from Software/ESPHome if you prefer to manage everything yourself

If you want the maintained package-based configs, start from the files in Software/ESPHome. If you want more control, use Software/ESPHome/README.md as the advanced reference for package layout, calibration files, CS-pin changes, and example configs.

ESPHome Calibration

Default calibration values are usually good enough to get started, but calibration is strongly recommended if you are using custom CTs, a different AC-AC transformer, longer CT leads, or if you want especially accurate readings.

On the main board, calibration is done through two separate ATM90E32 chips, not one 6-channel block. main_meter_id1 / Meter 1-3 handles CTs 1-3, and main_meter_id2 / Meter 4-6 handles CTs 4-6. Each Run ... Calibration button in Home Assistant acts on only one of those chips, so calibrate CTs 1-3 and CTs 4-6 separately.

In the CircuitSetup YAML, the normal starting points are current_cal_ct1 through current_cal_ct6, plus voltage_cal1 and voltage_cal2 in the top-level config file you flashed or imported from Software/ESPHome. Under the hood, those map to ESPHome's gain_ct and gain_voltage values for each ATM90E32 phase. Software/ESPHome/calibration/6chan_main_calibration.yaml adds the Home Assistant calibration buttons and the runtime reference number entities. Software/ESPHome/calibration/6chan_main_offset_calibrations.yaml is where copied offset values can be persisted in YAML.

To use the semi-automatic calibration workflow, make sure offset_calibration and gain_calibration are set to "true" and that the calibration package is included. After the meter is adopted into Home Assistant, open the meter device page. There you will see:

  • ${main_meter_name1} Ref V 1 and CT1 Ref Current through CT3 Ref Current for the first ATM90E32
  • ${main_meter_name2} Ref V 2 and CT4 Ref Current through CT6 Ref Current for the second ATM90E32
  • Run ... Offset Cal, Run ... Power Offset Cal, Run ... Gain Cal, and matching Clear ... buttons for each chip

If you renamed the meter groups in YAML, the button labels will follow those names instead of the default Meter 1-3 and Meter 4-6.

In practice:

  • gain calibration fixes scaling when the meter reads high or low under a known load
  • offset calibration fixes false zero-level readings when current or voltage should be at or very near zero
  • power-offset calibration fixes false power readings when voltage is present but CT current is zero

Recommended workflow:

  1. Start with the closest known values for your CTs and AC transformer by setting current_cal_ct1 through current_cal_ct6 and voltage_cal1/voltage_cal2 to the nearest matching starting values.
  2. Open the meter device page in Home Assistant and choose which ATM90E32 you are calibrating: Meter 1-3 for CTs 1-3, or Meter 4-6 for CTs 4-6. For that chip, phase A/B/C in the ESPHome logs correspond to CT1/CT2/CT3 or CT4/CT5/CT6 respectively.
  3. For gain calibration, restore the meter to normal wiring, apply a stable known load, and use a trusted reference meter or clamp meter to get the real voltage and current. Enter that chip's real voltage into its Ref V field. For the CircuitSetup 6-channel meter, that reference voltage is used across that chip's phases. Then enter the real current into the matching CTx Ref Current field for each CT you want to calibrate.
  4. Press that chip's Run ... Gain Cal button. ESPHome then logs a calibration table showing phase A/B/C, measured voltage, measured current, reference voltage, reference current, and the old-to-new V_gain and I_gain values for that chip. If a reference voltage or reference current is left at 0, ESPHome skips recalculating that part and logs a warning instead.
  5. Open the ESPHome logs and copy the reported values back into YAML. In the standard workflow that means opening LOGS in ESPHome Device Builder for the device, but serial logs or esphome logs work too. For Meter 1-3, map the logged gain results back to voltage_cal1 and current_cal_ct1 through current_cal_ct3. For Meter 4-6, map them back to voltage_cal2 and current_cal_ct4 through current_cal_ct6.
  6. Only run offset calibration if idle baselines are not clean. For this step, the ATM90E32 button code and docs both expect current and voltage inputs to be at 0, so the practical approach is USB power only with the AC transformer and CTs disconnected. Press the matching Run ... Offset Cal button for the chip you want to clean up. The logs will show a table of offset_voltage and offset_current for phases A/B/C on that chip.
  7. Only run power-offset calibration if power still shows a small non-zero value with voltage present but CT current at zero. For this step, the voltage reference should be connected but CT current should be 0. Press that chip's Run ... Power Offset Cal button. The logs will show offset_active_power and offset_reactive_power for phases A/B/C on that chip.
  8. If you want offset values persisted in config, copy them into Software/ESPHome/calibration/6chan_main_offset_calibrations.yaml. ESPHome's button logs refer to gain_ct, gain_voltage, offset_voltage, offset_current, offset_active_power, and offset_reactive_power under each phase_x; in this repo those results map back to the current_cal_ctX and voltage_cal1/2 substitutions plus the offset include file.
  9. After those values are saved in YAML, press the matching Clear ... buttons for that same chip so the temporary calibration values stored in flash no longer override your YAML. The component stores gain, offset, and power-offset calibration values in memory and applies them immediately, so clearing them is the step that hands control back to the YAML values.

What the logs will show:

  • gain calibration logs a table with V_meas (V), I_meas (A), V_ref, I_ref, V_gain (old→new), and I_gain (old→new) for phases A/B/C of the selected chip
  • offset calibration logs a table of offset_voltage and offset_current for phases A/B/C of the selected chip
  • power-offset calibration logs a table of offset_active_power and offset_reactive_power for phases A/B/C of the selected chip
  • the button press itself also logs guidance such as Use gain_ct: & gain_voltage: or Use offset_voltage: & offset_current: and reminds you about the required wiring conditions for offset and power-offset calibration

The key output from semi-automatic calibration is written to the ESPHome logs through logger, not into the Home Assistant entity state itself. The normal CircuitSetup workflow is: run the correct chip's calibration button from the Home Assistant device page, watch the output in ESPHome Device Builder LOGS, copy the values into YAML, clear the stored chip calibration for that same button group, then reboot or reload and verify against your reference meter.

Useful references:

Home Assistant Energy Dashboard

Home Assistant Energy Config

The current repo configs already use the right Home Assistant time source and current energy-sensor metadata. If you are building your own sensors, use the same pattern as the current configs:

sensor:
  - platform: total_daily_energy
    name: ${friendly_name} Total kWh
    power_id: totalWattsMain
    filters:
      - multiply: 0.001
    unit_of_measurement: kWh
    device_class: energy
    state_class: total_increasing

If you are using the standard package configs in this repo, time: - platform: homeassistant is already included and does not need to be added again.

Helpful example configs:

In Home Assistant:

  1. Open Settings > Energy
  2. Add your total import sensor under the electricity grid section
  3. Add return-to-grid and solar production sensors if you are tracking export or generation
  4. Add per-circuit energy sensors if you want individual device or branch circuit tracking

Optional: InfluxDB and Grafana

If you want long-term storage outside the default Home Assistant recorder, the easiest path is to expose the meter data to Home Assistant first and then use the Home Assistant InfluxDB integration.

EmonESP and EmonCMS

EmonESP is still a good option if your main goal is sending data to a local EmonCMS install, emoncms.org, or MQTT without making Home Assistant the center of the system.

The 6-channel EmonESP files in this repo already include the correct pin defaults for the main board and support calibration changes from the web UI.

Key points:

If you need separate voltage calibration for a specific add-on-board voltage channel in EmonESP, note the local EmonESP readme: by default the add-on voltage channel uses the main board calibration unless you define a separate variable in energy_meter.cpp.

CircuitPython and MicroPython

If you want to build your own application stack instead of using ESPHome or EmonESP, these community libraries are available:

FAQ

Q: One CT is reading low, or not reading at all. What should I check first?

A: First make sure the CT plug is fully seated. The jacks can be tight, and the connector often needs to be pushed in until it clicks. If one channel still reads low after that, swap CTs between channels to find out whether the issue follows the CT or stays with the board jack.

Q: Does the 6-channel meter work outside North America?

A: Yes. Set the line frequency for your system and use the correct AC-AC transformer for your mains voltage. For 230V or 240V systems, use a native 230V to 9VAC or 12VAC adapter when possible instead of a step-down transformer plus a US wall adapter.

Q: Can I use a 230V to 120V step-down transformer with a US 9VAC adapter?

A: It can work, but it is not the preferred setup. A native 230V to 9VAC or 12VAC AC-AC adapter is simpler, cleaner, and usually the better long-term choice. If you do use a different adapter, plan to calibrate the voltage.

Q: I am getting a negative value on one current channel. What is happening?

A: The CT is usually backwards on the conductor. Turn the CT around. If every CT is negative, the AC transformer phase is probably reversed.

Q: I see a small negative value at no load, but positive values under load. Is that normal?

A: That is usually offset error, not a wiring failure. Run the voltage and current offset calibration in ESPHome if you want the cleanest fix. If you just need to clamp small negative values to zero in a template, that is also possible, but offset calibration is the better solution.

Q: Can I extend the CT wires?

A: Yes. A short 3.5mm extension cable or a clean custom extension usually works fine. After adding a longer run, recalibrate if you want the best accuracy.

Q: Can I use other CTs with this meter?

A: Usually yes, as long as the CT secondary output stays within the supported range. The important limits are the CT output, not the brand name. If the CT has a built-in burden resistor or a voltage output such as 1V, cut the matching jumper trace on the board for that channel.

Q: Can I use SCT-024 200A CTs on the 6-channel meter?

A: Yes, but you still need to respect the meter input range. With the newer 200A/50mA SCT-024, the practical maximum current you should measure directly without additional scaling is about 132A on one channel. If you need to monitor more than that, use the software scaling approach described above.

Q: How do I know whether to cut JP1-JP6?

A: Leave the jumper trace intact for mA-output CTs such as CircuitSetup SCT-006, SCT-010, SCT-013-000, SCT-016, and SCT-024. Cut the matching jumper trace only for channels using CTs with built-in burden resistors, which usually means voltage-output CTs such as 1V models.

Q: Do CTs need mono 3.5mm plugs, or will stereo plugs work?

A: The board uses the CT signal on the tip and sleeve. A CT with a stereo 3.5mm plug usually works fine as long as the CT output is wired correctly and the electrical output itself is compatible. The plug style matters less than the CT secondary type and wiring.

Q: Can I mix different CT types on one meter?

A: Yes. That is a common setup. Give each current channel the correct calibration value for the CT on that channel. Do not assume the same calibration applies to every CT just because they are on the same board.

Q: My add-on board shows NA, or I see connection to ATM90E32 failed. What should I check?

A: Start with the basics:

  • confirm you flashed the firmware for the correct add-on count
  • confirm the add-on board jumper positions match the expected CS pair for that stack position
  • confirm the add-on board is fully seated
  • if you changed jumper positions, confirm the matching cs_pin values were also changed in ESPHome

If the main board works by itself and both boards stop reporting as soon as the add-on is installed, the jumper selection or physical seating is usually the first thing to verify.

Q: Which ESP32 dev boards are supported?

A: Use a NodeMCU 32s, an ESP32-DevKitC-32E, an ESP32-DevKitC-VIE, or another board with the same pinout. Ethernet is supported with the documented LilyGO or Waveshare ESP32-S3 options plus the proper adapter and matching YAML. Boards with different pin maps, including ESP32-C6 dev boards, are not documented drop-in replacements for this repo.

Q: Can I connect the meter to Ethernet?

A: Yes, with the documented ESPHome Ethernet options. Start with:

Use the matching firmware in the web installer for Ethernet (Lilygo) or Ethernet (Waveshare).

Q: How do I set up solar and return-to-grid tracking?

A: Use separate power calculations for house import, solar generation, and return-to-grid export. The best starting point is the maintained example here:

Q: How can I do calculations across two different meters in Home Assistant?

A: Create a template helper or template sensor in Home Assistant and do the math there. Use each meter's total power or energy sensor as inputs, then expose the calculated sensor back to the Energy dashboard if needed.

Q: My older ESPHome config no longer compiles after updating ESPHome. What is the easiest fix?

A: The repo has moved forward with the current ESPHome workflow, including esp-idf, dashboard_import, current OTA syntax, and the maintained package structure in Software/ESPHome. The fastest path is usually to start from the current repo config or reflash with the CircuitSetup ESP Web Installer and then merge your custom names and calibration values back in.

More Resources

About

Hardware & Software documentation for the CircuitSetup Expandable 6 Channel ESP32 Energy Meter. Works with ESPHome and Home Assistant.

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors