Skip to content
Manuel Reimer edited this page Aug 23, 2025 · 11 revisions

Reading the LED light pulses from an electricity meter

Diese Seite in Deutsch

Photo of the mounted sensor

Modern digital electricity meters usually have a LED which reports energy usage. Usually the amount of pulses is noted next to this LED. For example "1000 pulses / kWh". Don't be fooled if the LED seems to not output any pulses. It may be possible that the LED uses invisible infrared light. With an Arduino it is possible to monitor those pulses.

Arduino pulse sensor

Circuit diagram

The light pulses are detected with a photo transistor. In my case the SFH309FA, which is an infrared only detector. I used this part as my electricity meter sends its pulses with infrared light. If yours uses visible light (for example red), you have to use a photo transistor which is sensitive to visible light. The 2k2 ohms resistor translates the current through the photo transistor into a voltage which can be detected on the analog pin A7.

The LED and the 560 ohms resistor are used for visual feedback, so you can see that the calibration is done correctly and pulses are detected. This feedback LED "mirrors" pulses that are actually handled. Meaning that skipped pulses (configuration constant "pulsesToSkip") are not displayed here.

Pin D2 is used by the original project to drive an infrared LED. My fork does not actually need it, but to keep backwards compatible to the original project, it should not be used for anything else.

Software

The software is preconfigured for a 5000 pulses per kWh meter to report 100 pulses per kWh. To change this, please have a look at the "pulsesToSkip" variable on the top of the Arduino sketch and its documentation comment.

Once flashed to the Arduino, the startup mode is always "trigger mode", which reports detected pulses (excluding skipped pulses). Sending "C" via Arduino Serial Monitor allows to enter following commands:

  • D - retrieve and print raw data
  • T - enter trigger mode and print trigger data (0/1)
  • S low high - Set trigger levels (e.g. 85 90)
  • C - Cancel data acquisition and enter command mode

In mode "D" the raw values are reported. This is mainly used for calibration. "T" switches back to trigger mode (startup default). "S" followed by the wanted trigger levels, saves those levels into EEPROM.

Calibration

If your meter uses high pulse rates, like 5000 pulses per kWh in my case, it may be needed to increase the serial baud rate to not loose information in raw data mode. An alternative "Serial.begin" command is provided in the source code.

Mount your sensor to the electricity meter and connect it to your Arduino circuit. Now connect your Arduino to a PC and open the Arduino Serial Monitor. At first send "C" to enter command mode. then send "D" to get raw data. If you disable "Auto Scroll", then you can copy and paste your values to a spreadsheet software, like LibreOffice Calc, to create a diagram.

Trigger levels diagram

While the electricity meter is running, you should see distinct pulses in your diagram. Now define an upper and lower trigger level, with some safety margin. In my case, I decided to go for 200 as lower trigger level and 550 as upper trigger level. To finally set this value, Cancel raw data mode by sending "C" and finally send the command "S 200 550" (replace the numbers with the ones you need) to store the trigger levels to EEPROM.

Working with the trigger events

After correctly calibrating your sensor, the serial output will report a "0" for a rising edge on the LED brightness and an "1" for a falling edge. Example software to detect those is provided in the respository (written by Martin Kompf).