Skip to content
Go back

Power consumption meter with SCT-013 and ESP32

Published:  at  12:20 PM

What an SCT-013 measures

The SCT-013 is a family of clamp-style current transformers. You put it around a conductor and it can measure current without cutting the cable, depending on the model and its load circuit. It does not measure power or energy directly: to calculate them you need current, voltage, power factor and time.

The family has variants with a current output and variants with a voltage output. The reading circuit differs between them. Identify the exact model before copying a resistor or a formula.

Safety first

This project can work close to mains voltage. The clamp must be installed without opening or modifying a live conductor, following the manufacturer’s instructions. If you are not trained to work in electrical panels, do not do the installation: ask a professional for help.

Low-voltage materials

The ESP32 measures a voltage inside its ADC range. The alternating signal from the clamp must be shifted around a reference and limited so it does not exceed the input. Connecting two SCT-013 wires straight to an analog pin is not enough.

Conceptual diagram of reading an SCT-013 with signal conditioning before the ESP32 ADC
Conceptual low-voltage flow: clamp, conditioning and ADC. This is not a diagram to work inside an electrical panel.

Calculation principle

Alternating current changes constantly. To estimate its effective value, take samples over several cycles, remove the offset and calculate the RMS value. A conceptual approximation is:

I_RMS = square root of the mean of (sample - offset)²

Then you apply the transformation ratio and the circuit calibration. Approximate active power would be current times voltage times power factor, but using current times a fixed voltage only gives an apparent estimate.

Reading with the ESP32

Use a suitable ADC and a sampling frequency high enough to represent the signal. The exact implementation depends on the circuit, the SCT-013 model and the mains frequency. Document the resolution, attenuation, number of samples and time window.

Do not publish a consumption figure with false precision. The result depends on calibration, noise, waveform, power factor and the exact point where you place the clamp.

Calibration

Compare the result with a known load or a reliable meter. Take several measurements with small and large loads and check whether the error is constant or grows with current. Adjust the conversion only after reviewing the offset, the load resistor and the ADC reference.

A resistive light bulb can be a simple load for a first test, but a motor, a switching power supply or a charger have different power factors and waveforms. A single calibration does not validate every appliance.

Common problems

What to show in Home Assistant

Start by showing current and one estimate with a clear unit. If you have not measured voltage and power factor, label the result as an estimate and not as exact active power. Add history data after verifying that the readings are stable.

External sources

Next step

The homeiotguide editorial team

Editorial lead: Néstor Espuch


Suggest changes
Share this article on:

Previous article
ESP32 Won't Connect to WiFi: Causes and Fixes
Next article
Automatic irrigation with ESPHome and a soil sensor