Flow Sensor seems to generate far too much pulses

Can Anyone help me with my script and understanding of the pulse counter?
I use a WT32-ETH01 with multiple i2c devices and 1 pin for pulse counting in my greenhouse.

All works, but the pulses counted/liter are both off the scale!
The model flow sensor: YF-B1 DIN15 (15MM).
working range: 1-25L/Min

I used 2 variants of script, but give…weird but constant readings!

  # - platform: pulse_meter
  #   pin:
  #     number: 12 # Vervang 4 door het juiste GPIO-nummer
  #     mode: INPUT_PULLUP
  #   name: "Water Flow Frequency"
  #   unit_of_measurement: "Hz"
  #   id: water_frequency
  # - platform: template
  #   name: "Water Flow Rate"
  #   unit_of_measurement: "L/min"
  #   accuracy_decimals: 2
  #   lambda: return id(water_frequency).state / 11.0;

  - platform: pulse_meter
    pin:
      number: 12
      mode: INPUT_PULLUP
    name: "Water Flow Frequency"
    unit_of_measurement: "Hz"
    id: water_frequency
    filters:
      - debounce: 100ms # Debounce filter met een vertraging van 10 milliseconden (probeer eventueel andere waarden)
  - platform: template
    name: "Water Flow Rate"
    unit_of_measurement: "L/min"
    accuracy_decimals: 2
    lambda: return id(water_frequency).state * 60.0 / 660.0;
    update_interval: 5s

Can anyone advise what can be improved?

Here 1 of possible valve outlet values:
|Water Flow Frequency|424.04 Hz||

|Water Flow Rate|38.55 L/min|

According to this: Water Flow Sensor YF-B1

The formula for frequency is

image

So to get flow rate (Q) in L/Min divide the frequency by 11.

  - platform: pulse_meter
    pin:
      number: 12
      mode: INPUT_PULLUP
    name: "Water Flow"
    unit_of_measurement: "L/min"
    id: water_flow
    filters:
      - debounce: 100ms
      - multiply: 0.09090909

However be careful using GPIO 12. See the table lower down on this page: ESP32 Pinout Reference: Which GPIO pins should you use? | Random Nerd Tutorials

Hi Tom,

Thanx for the reply, I wil test this. For now I have a new problem with the same setup to solve first :frowning: . The Flow Sensor works on the same power relay as all the other systems. Parrently it generates a lot of static in the line to trigger input buttons connected to a i2c, generating false inputs. with some help from Google Gemini I learned that it can be wist to put capacitators on the powerline to filter out noice. I will try this I hope that it will not happen again.

Thanx in advance,
Kirelam