First how many wires from the meter pickup unit? 2 or 3, Any information on what is needed to dive the pickup for a good clean signal of pulses versus noise on the lines (ripple voltages) that can be counted as pulses? That some what important.
Since you not using their electronics to drive/count (says up to 200 ft of cable), I doubt you can even go that far. Your electronics might have to be up very close. A oscilloscope would be a great help to see the signal.
Thank you for your reply. The meter has two wires coming out of it. The manufacturer has said “we recommend no more than 20mA and 24V for reading the pulse on all our water meters. So please use a resistor to limit the current, otherwise the reed switch could be damaged.”
I’m still learning about all of this stuff. The water meter does not use electricity. What might cause ripple voltages? I’ve tried two different USB power blocks/cables. Could using USB as the power source for the ESP32 board cause this problem?
I will post in the manufacturer’s forum to see if I can get more information about what is needed to drive the pickup of a clean signal of pulses. Any ideas from you would be appreciated. I don’t have an oscilloscope.
Depending on the manufacturer, USB power adapters are not the cleanest in DC voltage output. Do you have something heftier? Like a old AP power supply that you could change out the barrel end for a USB end or look for a USB with a barrel input.
But what is needed by the MELIFE ESP-32S to operate?
I don’t see this mentioned: Are you sure your pullup and inverted settings are correct? If the part generating the pulses go low (normally open) when it pulses, this it’s fine, but it could be the other way around, in which case the pin is floating when there’s no pulse (also, it can damage your controller). If you have a multimeter, use a low flow rate and the continuity tester to check which way around your pulses are generated.
Thank you Pieter. I’m not sure if the pullup and inverted settings are correct. I added those settings after initially getting the continuous pulses and reading the ESPHome documentation that says:
Blockquote Wiring
If you want to count pulses from a simple reed switch, the simplest way is to make use of the internal pull-up/pull-down resistors.
You can wire the switch between a GPIO pin and GND; in this case set the pin to input, pullup and inverted:
I’ll ask the water meter manufacturer about how the pulses are generated.
I’m on a water well and know that the well pump is off most of the time, but the ESP32 board is picking up many pulses per minute. I suspect something, besides water flow, is generating the pulses. I don’t know anything electrical engineering but the suggestion from @lordwizzard about ripple voltages is something I plan to investigate.
One problem solved! It seems that the continuous pulse readings were caused by the power supply for the ESP32 board. I was using a mobile phone charging block and cable to power the ESP32 board. I am now using the USB port out of my laptop computer to power the ESP32 board. Now, I only get pulses when the well pump is drawing water out of our well.
Can anyone help me understand the ESP32 code better? What is the function of each of the sections named plateform:pulse_counter, platform: pulse_meter, platform: pulse_meter and platform:template? My calculations seem to be off. One pulse from my water meter should equal approximately 0.075 gallons. Home Assistant is showing water meter readings that don’t make sense.
This should help to explain at least the difference between the pulse counter and pulse meter: Pulse_counter vs pulse_meter - ESPHome - Home Assistant Community (home-assistant.io). In short, you probably need only one of them. Since the template sensor uses the pulse counter value (and neither of the two pulse meters below), you can probably just keep that one.
This looks like an unintended duplication, because these have the same name:
You should probably remove the first, since the second is the more complete definition (that is if you want to use this at all). The effect of the current situation is that you are probably seeing both sensor.water_pulse_meter and sensor.water_pulse_meter_2 on the HA side.
@parautenbach below is what the manufacturer had to say about the pulse mechanism of the water meter. After reading it, do you have any thoughts on whether the pullup and inverted settings are correct?
Our water meters have a basic, non-powered, Reed Switch, 2-wire, open/close pulse output. Your device will need to put a low voltage on the line and sense when the circuit closes at the water meter end. One close of the circuit = 1/10th cubic foot of water.
We recommend no higher than 20mA and 24V for reading the pulse on all our water meters.
The smallest dial on the water meter - the dial with the finest granularity - measures down to .01 cubic feet. The pulse is generated every time this dial goes around (so every 0.1 cubic feet).
The pulse frequency and width on the water meters are variable. This is due to the fact that the pulse is generated by a Reed switch that is closed via a magnet on one of the water meter dials. If the magnet were to stop rotating when the switch was closed, the pulse width would be infinitely wide until the dial moved again. Conversely, the faster the dials spin the shorter period of time the contact is closed.
Given this, your settings are correct. The pull-up in this case is to give the circuit a way to let the current flow and dissipate the energy when the circuit is closed (otherwise the 3.3V is directly connected to ground at the time of the pulse, which will make sparky stuff). When the circuit is open, you want the pin to sit at high (3.3V).
Thanks for linking to the post about pulse counter vs pulse meter. After reading that post a number of times and the ESPHome documentation about those sensors, I still don’t see significant differences between those two sensors. As you had previously mentioned compared to Pulse Meter, Pulse Counter seems to have more flexibility with its configuration variables. In the end, aren’t both of those sensors just outputting pulses/minute? Then, by using filters one can convert the pulses per minute to other units such a gallons, liters, kW, etc?
It seems you were right in that I only needed one of the sensors. Based on a post in another thread (Water usage sensor - #3 by mightybosstone) this is the code that I’m currently using.
Thanks for taking the time to help me understand. When I get more time, I’ll run a few tests to better understand the differences in those two sensors. The confusing thing for me is that the ESPHome documentation for those two sensors is identical in a number of respects. For example, the documentation for the Pulse Counter sensor says:
Converting units
The sensor defaults to measuring its values using a unit of measurement of “pulses/min”.
Yes, it’s confusing at first, but it’s really just this: Pulse counter aggregates over a period and sends that to HA (a value based on an interval). The pulse meter sends on every pulse (an immediate value when the pulse occurs). Both count pulses.
Let’s say a pulse counter sends data every minute. Let’s also assume this is our sequence of pulses (format minutes and seconds). Let’s also say this is unitless (just a count).
00:05
00:12
00:26
00:38
00:40
00:59
At one minute, the pulse counter will report 6 pulses/min (just the total of pulses in that minute). The pulse meter will report 3.2 pulses/min at that point in time (the time between the last and second last pulse is 19 seconds apart).
How can I confirm the volts and amps that my ESP32 is using to sense the pulses on my meter? Per the information below from the water meter manufacturer, there are recommended voltage and amperage limitations for the sensing circuit.
Our water meters have a basic, non-powered, Reed Switch, 2-wire, open/close pulse output. Your device will need to put a low voltage on the line and sense when the circuit closes at the water meter end. One close of the circuit = 1/10th cubic foot of water.
We recommend no higher than 20mA and 24V for reading the pulse on all our water meters.
The smallest dial on the water meter - the dial with the finest granularity - measures down to .01 cubic feet. The pulse is generated every time this dial goes around (so every 0.1 cubic feet).
The pulse frequency and width on the water meters are variable. This is due to the fact that the pulse is generated by a Reed switch that is closed via a magnet on one of the water meter dials. If the magnet were to stop rotating when the switch was closed, the pulse width would be infinitely wide until the dial moved again. Conversely, the faster the dials spin the shorter period of time the contact is closed.
You would need to use a VOM (Volt Ohm Meter). Put it on VDC in a range or auto to measure the DCV applied to the module (from the positive side to the negative/ground). For current you need to put the meter in Current mode in the appropriate mA range or auto. Then you need to put the meter in series in the circuit.
They have them at Lowe’s, Home Depot, etc. Do not go cheap. You may need it on other projects.