Help me setup and calibrate YF-B10 G1"

Hi everyone.

I’m very unfamiar with esphome lambda

I have YF-B10 G1"

Product Model YF-B10
Rated voltage DC=5V
Thread size : Male 1 inch
Size: 58mm L
Flow rate : 2~50L/min
Flow Pulse: (6*Q-8) Q=L/Min±5%
Max. Working Current : 15mA (DC5 V)
Min. Working Voltage: DC 4.5V
Working Voltage:DC 5V~15V
Load Capacity: =10 mA (DC 5 V)
Operating Working Temperature : -25 Degree centigrade to +60 Degree centigrade
Liquid Temperature: 60
Accuracy : 5%~10%
pressure: >1.75MPa

I know that chatgpt is terrible at these things, but thought I’d 'give it a go

  - platform: pulse_meter
    pin: GPIO13
    id: water_pulses_per_min
    internal: true
    timeout: 2s
    accuracy_decimals: 0

    total:
      name: "Total Water Pulses"
      id: total_water_pulses
      unit_of_measurement: "pulses"
      state_class: total_increasing
      accuracy_decimals: 0

  - platform: template
    id: water_flow_rate
    name: "Water Flow Rate"
    unit_of_measurement: "L/min"
    device_class: water
    state_class: measurement
    accuracy_decimals: 2
    update_interval: 1s
    lambda: |-
      if (isnan(id(water_pulses_per_min).state)) return NAN;
      const float litres_per_pulse = 0.00113f;  // 9 L / 7,962 pulses
      return id(water_pulses_per_min).state * litres_per_pulse;

  - platform: template
    id: total_water_used_from_pulses
    name: "Total Water Used (Pulses)"
    unit_of_measurement: "L"
    device_class: water
    state_class: total_increasing
    accuracy_decimals: 2
    update_interval: 10s
    lambda: |-
      if (isnan(id(total_water_pulses).state)) return NAN;
      const float litres_per_pulse = 0.00113f;
      return id(total_water_pulses).state * litres_per_pulse;

I’ve conducted some water flow tests:

filled 9L in 1:30 minutes

Would be great if someone can provide what I need to put into the config
Much appreciated

No need for a template sensor. Just apply some filters to your pulse sensor.

Q = (Pulses+8)/6 L/min

  - platform: pulse_meter
    pin: GPIO13
    name: Flow Rate
    id: water_pulses_per_min
    timeout: 2s
    accuracy_decimals: 0
    filters:
      - offset: 8
      - multiply: 0.1666666  # L/min from the manufacturer's equation

    total:
      name: "Total Litres"
      id: total_water_pulses
      unit_of_measurement: "pulses"
      state_class: total_increasing
      accuracy_decimals: 0
    filters:
      - multiply: 0.00113  # L, from your calibration

Thanks @tom_l

I’m getting Duplicate key "filters" error

Oops. Indentation issue. Try:

  - platform: pulse_meter
    pin: GPIO13
    name: Flow Rate
    id: water_pulses_per_min
    timeout: 2s
    accuracy_decimals: 0
    filters:
      - offset: 8
      - multiply: 0.1666666  # L/min from the manufacturer's equation

    total:
      name: "Total Litres"
      id: total_water_pulses
      unit_of_measurement: "pulses"
      state_class: total_increasing
      accuracy_decimals: 0
      filters:
        - multiply: 0.00113  # L, from your calibration

Working, let me try

Ah. I was looking at the pulse counter sensor. Not the pulse meter. Use that instead:

it supports filters on the total.