Projects / Read your electricity meter's LED

Read your electricity meter's LED

Intermediate2 hGuided buildReviewed

Build it step by step

0 of 8 done
  1. ESP32LM393

    Build the sensor

    Wire the photodiode, comparator and pot on a breadboard.

  2. ESP32

    Test with a torch

    Pulse a torch on it and see the pulse count rise.

  3. ESP32

    Find your meter constant

    Read imp/kWh from the label.

  4. ESP32

    Tape the sensor over the LED

    Cover it with black tape and tune the pot.

  5. ESP32

    Fill in the placeholders

    Add Wi-Fi and broker details.

  6. ESP32

    Upload

    Watch the power change when you switch a heater on.

  7. ESP32

    Compare

    Check a known load, such as a 1 kW heater, against the reading.

  8. ESP32

    Log over days

    Record standby power at night.

In short

How do you build a read your electricity meter's LED?

A light sensor taped over the meter's pulse LED counts kWh and shows live power without opening anything. You need ESP32 DevKit V1, Photodiode BPW34, LM393 Comparator, Resistor 10 kΩ × 2, Potentiometer 10 kΩ and 5 V 2 A USB adapter. It takes 8 steps and about 120 minutes.

Level
Intermediate
Time
About 120 min
Parts
6

Parts list

Tick what you already own. It saves to My Garage, so “Build with what I have” knows.

Wiring

FromToWhy
LM393 pin 8ESP32 3V3Power
LM393 pin 4ESP32 GNDGround
BPW34 cathodeESP32 3V3Reverse bias
BPW34 anode10 kΩ resistor to GND, and LM393 pin 3 (IN+A)Light makes the voltage rise
Potentiometer endsESP32 3V3 and GNDReference divider
Potentiometer wiperLM393 pin 2 (IN-A)Threshold
10 kΩ resistor (pull-up)3V3 and LM393 pin 1 (OUT-A)Open-collector output needs a pull-up
LM393 pin 1ESP32 GPIO27One pulse per meter blink
LM393 pins 5, 6GNDUnused comparator

Code

Most electricity meters blink a small LED once for every fixed amount of energy, printed on the label as imp/kWh. Tape the photodiode over that LED with black tape to keep room light out, and tune the potentiometer so the output switches cleanly with each blink; the sensor only looks at a light, so do not open the meter, remove any seal or touch its terminals, and never connect anything to the meter's mains side. Power in watts is 3 600 000 divided by imp/kWh times the seconds between pulses. The reading is good for tracking trends and standby loads but is not a billing record. Use placeholders for the Wi-Fi and broker details, and run the broker on your own network. Arduino IDE with the ESP32 boards package, board "ESP32 Dev Module".

Runs on a virtual ESP32 Dev Module in your browser, with sliders for the sensors. Happy with it? Verify and upload to your real board from the same page (Chrome or Edge on a computer).

// Counts the meter's pulse LED and publishes power and energy over MQTT. Libraries: PubSubClient.
#include <WiFi.h>
#include <PubSubClient.h>

const char* WIFI_SSID = "YOUR_WIFI_NAME";
const char* WIFI_PASS = "YOUR_WIFI_PASSWORD";
const char* MQTT_HOST = "YOUR_BROKER_ADDRESS";
const float IMP_PER_KWH = 1600.0;        // read this off your meter label, for example 1600, 3200 or 1000 imp/kWh
const byte PULSE_PIN = 27;

volatile unsigned long pulses = 0, lastPulseMs = 0, intervalMs = 0;
WiFiClient net;
PubSubClient mqtt(net);
unsigned long lastPublish = 0;

void IRAM_ATTR onPulse() {
  unsigned long now = millis();
  if (now - lastPulseMs > 30) {           // ignore bounces within 30 ms
    intervalMs = now - lastPulseMs;
    lastPulseMs = now;
    pulses++;
  }
}

void setup() {
  Serial.begin(115200);
  pinMode(PULSE_PIN, INPUT);
  attachInterrupt(digitalPinToInterrupt(PULSE_PIN), onPulse, RISING);
  WiFi.begin(WIFI_SSID, WIFI_PASS);
  while (WiFi.status() != WL_CONNECTED) delay(300);
  mqtt.setServer(MQTT_HOST, 1883);
}

void loop() {
  if (!mqtt.connected()) { mqtt.connect("meter-reader"); }
  mqtt.loop();
  if (millis() - lastPublish > 10000) {
    lastPublish = millis();
    noInterrupts(); unsigned long p = pulses, iv = intervalMs, last = lastPulseMs; interrupts();
    float kwh = p / IMP_PER_KWH;
    float watts = 0;
    if (iv > 0 && millis() - last < 120000UL) watts = 3600000.0 / (IMP_PER_KWH * (iv / 1000.0));   // power from the time between pulses
    char m[80];
    snprintf(m, sizeof(m), "{\"watts\":%.0f,\"kwh_since_start\":%.3f}", watts, kwh);
    mqtt.publish("home/meter", m);
    Serial.println(m);
  }
}

Test checklist

What you should see at each check. If a reading is far off, stop and use the troubleshooting list.

CheckExpected
Torch flashesPulse count rises
Heater onPower rises to about its rating
Everything offPower falls to the standby level
Pulse intervalShorter at higher power

If it does not work

No pulses

Adjust the pot and check the photodiode direction.

Too many pulses

Block room light and raise the threshold.

Power wrong

Check the imp/kWh figure on the label.

MQTT silent

Check the broker address and port.

Still stuck? Find the fault step by step with your multimeter →

Ask Lark AI

Common questions

What parts do I need for the read your electricity meter's LED?

ESP32 DevKit V1, Photodiode BPW34, LM393 Comparator, Resistor 10 kΩ × 2, Potentiometer 10 kΩ and 5 V 2 A USB adapter.

How long does the read your electricity meter's LED take to build?

About 120 minutes for a intermediate maker, in 8 steps.

How do I know the read your electricity meter's LED works?

Torch flashes: Pulse count rises. Heater on: Power rises to about its rating. Everything off: Power falls to the standby level.

No pulses: what should I check?

Adjust the pot and check the photodiode direction.

Too many pulses: what should I check?

Block room light and raise the threshold.

Power wrong: what should I check?

Check the imp/kWh figure on the label.

MQTT silent: what should I check?

Check the broker address and port.