I try to use that tutorial to count my electric consumption at home: https://esphomelib.com/esphomeyaml/cookbook/power_meter.html#see-also but I get only crazy values reported in HA even some negative ones !
I use a nodemcuv3 board with a basic photoresistor like that for wiring (mine is wired on D1 instead of A1)
Right now sensor shows up in HA but keeps staying at 0 !
I’m confused as photoresistor is analog device and so should be wired on Analog input I guess but example linked on esphomelib website uses a digital input !!
Someone succeeded to get that working ?
Update: tried using A0 as input but still stuck at zero in counter
Hey Vincèn
the same here. Its sounds quite easy. It must be easy, because i found nothing else about errors I us a WeMos D1 mini. Hooked up the sensor on D6 (GPIO12) as mention in the description. Wondering why not A0, tried this as well, same result.
Use a 10KOhm-Resistor and a GL5528-Photoresistor (10-20KOhm Light resistance), but don’t know the frequency of the LED on my built-in Powermeter. Probably i need a other LDR? Have GL5506, GL5516, GL5528, GL5537 and GL 5539. Or have i to try every LDR?
i didn’t follow-up on this as I moved in a new place and I don’t have anymore any counter with such system ! My initial guess was that LDR are too slow to react to detect a pulse flash like that !
From the datasheet the response time is about 30ms worst case so it should be able to react fast enough but it still won’t work the way you have it. See this diagram?
Look at the 3.3V TTL logic level “in low” and “in high” voltages: VIH = 2V , VIL = 0.8V You need to be above and below these voltages respectively for a change in logic level to be registered.
Using the voltage divider equation to calculate your dark and light voltages assuming a 3.3V supply, 10K series resistor and LDR resistance of (from the datasheet) 15K light, 1M dark:
Use a 100K series resistor with the GL5528. It should work.
Vo Light (20K Ohm, worst case): 0.55V = Logic 0
Vo Dark (1M Ohm): 3.0V = Logic 1
Make sure you hook it up with your LDR in the R2 position as shown on that voltage divider calculator page.
You might still have an issue if the intensity of the light is not bright enough to bring the LDR down to at least 32K Ohms. Or if the spectral response is poor as pointed out by nickrout and again you can’t get the light on resistance this low.
You explain in one post how low/high voltage logic works, how LDR’s work, how to calculate the output voltage with voltage divides equation and thus how to choose the right resistances. This post is so valuable… I don’t understand why these guys didn’t thank you…
Hi Tom! I now have a question:
I connected everything with an esp32 and a GL5516. Everything is working and the pulses are counted by the esp. The problem is that it is counting to many pulses I think. Comparing the energy consumption of the energy meter on the wall with my “esp-energy meter” its about the double consumption.
Is there a way to handle this? Or other question: What is causing this?
Sorry, I know you maybe need more information, but I don’t know which one :D…
Here is my Esprit config:
500imp/1000Wh … I think the calculation of the multiplier is right.
Its weird that I see often a “jump” in the counter. For example when I have 3 pulses/min sometimes suddenly it says 6 pulses/min (just for one counting phase) and than continues with the correct 3pulses/min. It looks like these jumps occur more often when there a more pulses.
I’m really thinking about how precise this method of measurement can be. I think you have a lot of know-how in this field, since I saw many posts of you about energy-monitoring. Do you think that wiring up 3 ct clamps (got 3-phase ac in my house) is better than counting pulses? What would you recommend me?
Did you see the note about noise at the bottom of this page:
I find it weird that the cookbook example converts energy to power then back to energy again.
1 pulse = 2Wh of energy in your case, just counting the number of pulses (keeping a tally) and dividing by 2 gives you a total energy used meter. Rather than using the pulse counter sensor that outputs in pulses per min scaling it to get power then feeding that to the energy meter sensor.
Yes, I’ve seen that section with the noise , but didn’t get any different or positive result playing with it. The maximum filter for ESP32 is also just 13us.
I think the „recalculation“ is because people want to know the actual power consumption. Knowing just the consumed energy isn’t telling people what the actual consumption is.
There are a couple of topics in the ESPHome category about CT clamps. People seem to have accuracy issues at the lower power end.
The Shelly EM is simple to interface with home assistant using mqtt. I’ve found it to work really well for power and energy monitoring. Not too expensive either.
Agreed with you @tom_l.
How to set up a pulses counter which will not count the number of pulses per min but simply increment a number?
My power meter does 1 flash for 1 Wh consumed.
And of course, thank you for your explanation here, it is pretty clear.
However, as we want to count the flashes, shouldn’t we put the LDR in the R1 position? I mean, don’t we want to have a logic 1 when there is light?
By the way, the diagram you posted, is it specific for the GL5528 or is it for any LDR?
Hi all,
It works fine for me now.
I placed the LDR GL5528 in R1 position and I used a 10kOhm resistor in R2.
Here is the code I uploaded on a Wemos D1:
# pulse counter for the house main electricity meter. One pulse = one Wh consumed
- platform: pulse_counter
pin: GPIO12
update_interval: 1s
count_mode:
rising_edge: DISABLE
falling_edge: INCREMENT
internal_filter: 29ms
icon: "mdi:flash"
unit_of_measurement: 'kW'
name: 'Power Meter'
filters:
- multiply: 0.06
id: power_meter
accuracy_decimals: 0
- platform: integration
name: "Power consumption"
sensor: power_meter
id: power_consumption
time_unit: h
icon: "mdi:counter"
unit_of_measurement: "kWh"