Impulse readers / electricity metering

i am wondeirng if anyone has any experience they would care to share with metering the electricity and/or gas consumption with an impulse meter.
in my home i have an impulse meter which lets out an impulse per kwh, or per m3… these are installed by the electricity/gas company.
i would like to have a counter for this… which i can integrate into home assistant… are there any people who have done this?.. or what tools could one use for this… i would rather not solder something together, but would like to use some kind of wireless technology … Wifi/zwave or zigbee… any ideas?

1 Like

If you can find out an existing device you can integrate for this I’d be keen to find out also. There are a few ways I know people have done this, one involving a photodiode on top of the blinking LED, for example this one:

I have no experience with this product myself though.

I’ve been fiddling around with a current transformer ring which outputs the measurements via MQTT. The accuracy is lower (around 90%) than a MID certified meter, but for non-billing purposes should be fine. This approach does entail some electrical work, in any case, please be safe if you do look into it and obey your local regulation.

OpenEnergyMonitor has several products intended for this type of purpose.

A notable thing about pulse counting is, that not all pulse meters emit pulses at the same frequency/power, probably it’s a lot less than one kWh.

I just finished that project today :slight_smile:
I think it needs some additional fine tuning with conversion, etc.
If anyone has any suggestions how to make this configuration better, please share :slight_smile:

I copied this project from this guide: Here (polish)

Here is what I did:


  • MQTT Broker configured
  • ESP Flashing Basics Guide


  • ESP-12E CP2102 NodeMcu Lua V2 Here
  • Photodiode Here
  • Connector Wires
  • Duct tape :wink:


  • Connect photodiode to GPIO Pin (my case GPIO-14), Voltage (3.3V) and GND

  • Flash ESP Easy Mega Here

  • Configure ESP to communictae with MQTT Broket in HA

  • Configure device in ESP:

    Note: Values 1/6400 is defined by my electricity couter from provider - it is stated on cover as 6400 impulses / kWh
    Note2: Change “Count” value to: “(%value%*(1/6400)) * 1000 * 60” to get value of Watts every 60 seconds

  • Configure MQTT sensors in HA:
    First one uses Count value and provides power consumption every minute (ESP is set to 60 seconds interval - screen above)
    Second one uses Total value and provides input for utility meter component:

  • Place photodiode directed on electricity meter flashing diode:
    Duct tape is your friend :slight_smile:

Final efect looks like this:
I added cost calculation

1 Like

almost what i looking for, i dont what whan to use mqtt to get all the info, i what to use Utility Meter in HA to get in all the data. any ide how?

Will you be using an ESP device with ESPHome firmware on it? If so, you don’t need to use mqtt, you can just use the homeassistant API for communication, then just plug the values into a Utility Meter entity.

mmm i dont know, relly… now i am just trying to understand how i can bulid on, then i need some to make the code

So I’d definitely suggest using an ESP device, flashing it with an ESPHome firmware (where you’re using homeassistant for communication rather than mqtt). Here’s the code for my firmware:

  name: power_meters
  platform: ESP32
  board: esp-wrover-kit

  ssid: {{ssid}}
  password: {{passw}}

# Enable logging

# Enable Home Assistant API


# Enable Web server
  port: 80

  # Uptime sensor
  - platform: uptime
    name: Elec Meter Uptime

  # WiFi Signal sensor
  - platform: wifi_signal
    name: Elec Meter WiFi Signal
    update_interval: 60s
  # Electricity usage
  # usage right now in kW
  - platform: pulse_counter
    pin: GPIO12
    unit_of_measurement: 'kW'
    name: 'Power Meter'
    id: power_meter
      - multiply: 0.06
  # converts above to kWh used today
  - platform: total_daily_energy
    name: "Total Daily Energy test"
    power_id: power_meter
    id: kwh_so_far
  # Switch to restart
  - platform: restart
    name: Electricity meter monitor restart
# Sync time
  - platform: sntp
    id: my_time

i have order some stuff. I hope i can make it work never use esp so its a a good way to trying to get it to work.

Hello, have almost got all that I order:

ESP-32 ESP32S Development Board 2.4GHz WiFi+Bluetooth Antenna CP2102 Module

NodeMcu Lua V2 WiFi Development Board Based On ESP8266 ESP-12E CP2102 Module

I am still wating for Photodiode module detects brightness light-sensitive light detector

Can link what firmware I should download so I can use your code?


If you get my code just paste it into a new node on the ESPHome addon, change your details, compile the firmware, download it and flash it onto your board with something like ESPHome Flasher. Does that make sense? Sounds long winded but it’s relatively simple.

i think i understand. This is a new world for me, never using this before so i know very litel about this.
think i need to reda alot about this
i allos need to figuer out how to coonect it all:S

Yeah I understand, if you want to get into ESPHome this video covers the basics I mentioned. You’d have to specify the correct board type you’re using and generate a firmware based on your needs but this is a good start:

I just starting to get this a chance:)

Do I need to use the card on image? Or can I use it the esp directly in the usb?

If not, how should I wiring them?


i have done my homework:P well some:D

now i understand how to flash it and get it in to HA,
but i am a bit unsuer how to wiring it.

i have Photodiode and having AO,DO,GnD, and VCC

just a guess is
gnd= ground
AO = anolog
do= digital
VCC= power

so if think right it sholde ne
gnd to gnd
VCC to 3.3V
do= to a pin like that one u using in the code (pin: GPIO12)

I did it! It works flawlessly
thank you

Hello everybody,
can i use that part too?

I am going to give this a try to, did you get it to work?

BTW, why is the NodeMcu board needed, shouldn’t one esp32 suffice?

This looks like a neat solution, but doesn’t the energy company mind that you have duct-taped something to their meter? It would look awfully suspicious for the person that comes and does periodic readings… :slight_smile:
I suspect the duct tape has an extra role to filter out outside light that might confuse the photodiode…

Hi, I’m desperately trying to get this to work, I have much newer versions of HomeAssistant, so am struggling. Does your YAML go in here?