and want to integrate that into mit HA. There are tons of tutorials out there, but they all seem different in how to configure the service.
What i did is to build a sensor using an reflective sensor shield and mount it that way to get a LOW pulse everytime the inked part of the turning wheel passes that by.
Mounting that was pretty fiddly, and i think it would be much easier and get better results if i did not took a “binary sensor”, where the digital pulse is made of an OpAmp comparator, but to feed the analog voltage into an A/D port of the ESP, but finally i got good looking LOW pulse every turn. The wheel turns 75 times per kWh power used. The sensor is connected to pin “D5”
Now, how to configure the ESP8266 D1 Mini (already adopted) to deal with that data and provide good dashboards?
Should i use pulse_meter or pulse_sensor oder something else? How to setup the params to get a total power used per time period (i’d like to have 1 day, 1 month and total since start of service)
Everything i tried ends with a messy value or no value…
INFO Disconnected from ESPHome API for esphome-web-da8c49.local
WARNING Disconnected from API
INFO Successfully connected to esphome-web-da8c49.local
[20:19:33][D][sensor:126]: 'Stromzähler': Sending state 128.36627 kW with 3 decimals of accuracy
[20:19:33][D][sensor:126]: 'Total': Sending state 0.00200 kWh with 3 decimals of accuracy
[20:24:34][D][pulse_meter:061]: No pulse detected for 300s, assuming 0 pulses/min
[20:24:34][D][sensor:126]: 'Stromzähler': Sending state 0.00000 kW with 3 decimals of accuracy
I really don’t get how this pulse_meter should work…
In the end i’d like to have these graphs and counters:
A graph showing the power usage in kWh h in a one minute resolution during the day (24 hours)
A graph showing the total energy consumed per day (365 days)
A graph showing the total energy consumed per month (respect the calender)
To get the graph 1.) i need to map from pulses/minute coming from the energy meter wheel sensor, into kWh/minute.
The docs tells that “pulse_meter” sensor values are seen as “pulses per minute”. That would mean, one minute is the minimal resolution of the software sensor, right?
So if my electrical sensor would give 1 pulse in a minute, it would put the value 1 into the graph for this minute, if there where 2 pulses it would put value 2 and so on?
Now, the plate on my power meter tells me that if the wheel turned 75 times, electrical work of 1 kWh (1000 Wh) has been consumed, no matter how long it took to turn 75 times. So it generates 75 electrical pulses per kWh.
I built something for the same power meter type, using the approach documented in Tracking gas usage with ESPHome, Home Assistant, and TCRT5000 | Savjee.be (same sensor and code logic, just for the power meter instead of the gas meter).
I tried the pulse_meter as well, but I never got it to run reliably. The new approach works good, for 2 months now.
My first issue was that the reflective sensor (TCRT5000 line tracer shield) could not clearly distinguish between the wheel and it’s colored marking. This shield works by sending constant IR light through one LED and detects it using the IR light-sensor, so it’s basically an analog value coming out of it. To get a digital pulse, there is a LM339 OpAmp used as comparator. Through a potentiometer you set the level of detected IR light to be seen as logical “0” or “1”. So it’s really cheap:
The problem with this sensor is, that it emitts IR light in an 90° angle around the LED, which get’s reflected by the glass of the power meter. To focus it on the wheel-marking, somebody in the web told a trick to remove the plastic housing and put small pipes (e.g. shrink tubes) onto the sending and receiving LED. This way it works much better and more sensitive!
I watched the signal coming from the sensor using an DSO, and it looks good so far: