Hi @wellsy, thank you for posting those specs. I have been unsuccessful in finding them myself, beyond the fact that it generates 27 pulses per litre, so that info was super handy.
I think a lot of the work you’re describing has already been done in ESPhome. The reason I say this is that simply by hooking the sensor up to the board and defining it in the yaml (ie: this is a pulse counter) I was getting pulses per minute back from it. I did not have to count total pulses myself, or measure time - it was already kicking back the data as “pulses per minute”, so it seems that a lot of the hard word has already been done. The number it’s producing directly correlates with how fast it’s spinning, it’s not an increasing total.
This being so, converting that data into L/hr was achieved with a very basic lambda. Here’s my config, which @Puneit_Thukral may also find useful:
sensor:
- platform: pulse_counter
pin: GPIO5
name: "Pulse Counter"
update_interval: 5s
filters:
- lambda: return (x / 27.0) * 60.0;
unit_of_measurement: "L/hr"
The update interval is too quick for practical everyday use (more data than I want) but perfect for testing now. I will reduce it to the default of 60s when I deploy it. The sensor filter divides the incoming pulse rate by 27 (because we know it’s 27 pulses per litre) and then multiplies by 60 to get the value per hour.
That appears to be all that’s needed to get this to work in ESPhome. Truly, this software is a marvel.