Pulse counter not giving the count I expect

Hi. I am trying to use the ‘pulse counter’ on a ESP32. I have my input connected to pin D34, and I have reasonable looking pulses - inverted, around 35ms wide - a sharp fall, but a bit of a curved rise. A voltage level of 3.3V dropping to ground. The pulses are occurring approx every 1.25sec - so around 0.8Hz- or 50 pulses / min.

The problem is ESPHome is reporting 180-300 pulses / min as displayed on HA. Scope pics and YAML below.

Any pointers to my problem much appreciated :slight_smile:


 - platform: pulse_counter
    pin: 
      number: GPIO34
      mode:
        input: true
      inverted: true
    count_mode:
      rising_edge: DISABLE
      falling_edge: INCREMENT
    name: "${friendly_name} Elec Fence Pulse Counter" 
    id: esp32_water_pump_mon_Elec_Fence_Pulse_Counter
    filters:
       - skip_initial: 3
       - debounce: 200ms
    update_interval: 5s
    total:
      unit_of_measurement: 'pulses'
      name: "${friendly_name} Elec Fence TOTAL Pulse Counter"

Hummmm… solved by cleaning up the trailing edge of the pulse… However I would think this could be solvable in software (YAML) configuration?