Advanced
6 hours
ESP32 Home Energy Monitor with CT Sensors
This energy monitor clips non-invasive current transformer (CT) sensors around the live wires in your consumer unit (fuse box) to measure current flow without any electrical modification. The ESP32 samples these signals 1000 times per second, calculates true RMS current, multiplies by assumed voltage to get approximate watt readings, and publishes to MQTT every 5 seconds. Historical data creates daily, weekly, and monthly consumption graphs in Home Assistant’s Energy dashboard.
What You’ll Need
- ESP32 DevKit
- 3 × SCT-013-000 current transformer sensors (100 A range, no built-in burden resistor)
- 3 × 22 Ω burden resistors (converts CT output to voltage)
- 6 × 10 kΩ resistors (biasing)
- 3 × 10 µF capacitors (DC blocking)
- 3.5 mm stereo jack sockets (×3, for CT sensors)
- 5 V / 1 A USB power supply
- Project enclosure
- Home Assistant with Mosquitto MQTT broker
Step-by-Step Instructions
- Build the input conditioning circuit: For each CT channel: solder the 22 Ω burden resistor across the 3.5 mm jack socket’s tip and sleeve terminals. Create a voltage divider biasing circuit: two 10 kΩ resistors from 3.3 V to GND, centre tap to the junction of burden resistor and ADC pin via a 10 µF cap. This biases the AC signal to 1.65 V midpoint so the ESP32 ADC can read both halves of the waveform.
- Wire to ESP32 ADC: Three CT channels → GPIO 34, 35, 36 (ADC1 pins, not shared with WiFi ADC).
- Install EmonLib: Add the EmonLib library for ESP32 (port by JoaoLopesF on GitHub, or adapt the Arduino version).
- Measure and publish: Initialise each CT channel with emon1.current(34, 111.1) (calibration factor = CT_ratio / burden_ohm = 100A÷0.9V ≈ 111). Call emon1.calcIrms(1480) for RMS current over 1480 samples (~30 AC cycles). Multiply by 230 V (or your local mains voltage) for apparent power. Publish three current and three watt values to MQTT every 5 seconds.
- Home Assistant integration: Add MQTT sensors in HA configuration.yaml for each channel. Configure the HA Energy Dashboard: add each phase as a “Grid consumption” source.
- Calibrate: Run a known load (e.g. a 1 kW kettle) and adjust the calibration factor until the displayed watts match the kettle’s rating. Recalibrate all channels using the same factor.
- Mount safely: House the ESP32 and circuit board in a plastic enclosure. ONLY the CT sensors go inside the consumer unit — the electronics mount outside. CT sensors clip around the cable, requiring no electrical connection to mains.
Safety Notes
- The consumer unit contains mains voltage — do not open or work inside it unless you are a qualified electrician. In many countries it is illegal for an unqualified person to work inside a consumer unit. Hire an electrician to clip the CT sensors if needed.
- CT sensors must be clipped around a single conductor (live wire only) — never around a twin-and-earth cable pair together, as the fields cancel and you read zero.
- Never open a CT sensor while it is clamped around a live wire with the output terminals open-circuit — dangerous voltage can develop across the output.
Tips & Troubleshooting
- Reading is half the expected value: you may have the CT clamped around a twin cable — re-clamp around just the live conductor.
- Noisy readings: ensure the biasing midpoint capacitor is properly installed. Increasing sample count (emon1.calcIrms(2960)) also reduces noise.
- Home Assistant Energy Dashboard shows lifetime consumption, daily/weekly charts, and calculated cost if you enter your electricity tariff rate — a powerful tool for identifying which appliances consume most power.