Error in Pulse Meter Sensor?

Hi guys,

I use binary_sensor and pulse_meter for my gas meter. The gas meter gives me a pulse every 10 liters. I count these pulses with a binary_sensor to derive my hourly and daily energy counts. To get the actual power of my gas heating I use the pulse_meter. The inverted time difference between two falling edges is proportional to the power (energy / time).

My setup works perfectly for 99.9% of the time. But in rare cases there is an false extra pulse of the pulse_meter. Has anyone an idea what’s going wrong here?

binary_sensor:
  - platform: gpio
    name: "Live-Impuls"
    id: internal_pulse_counter
    pin:
      number: D7
      mode: INPUT_PULLUP
    filters:
      - delayed_on: 10ms
    on_press:          # Reed-Kontakt geschlossen (Ground)
      then:
        - lambda: id(total_pulses) += 1;
        - output.turn_off: led
    on_release:        # Reed-Kontakt offen (Pullup-Widerstand)
      then:
       - output.turn_on: led
  - platform: pulse_meter
    name: 'Gaszähler Leistung'
    device_class: power
    state_class: measurement
    unit_of_measurement: "kW"
    accuracy_decimals: 3
    pin:
      number: D7
      inverted: true
      mode:
        input: true
        pullup: true
    force_update: true
    internal_filter: 10ms
    internal_filter_mode: EDGE
    timeout: 5min
    filters:
     - lambda: return (0.01 * id(Brennwert) * id(Zustandszahl) * x * 60);

See the false extra transition in the yellow curve between 18:15 and 18:20.

I do not know your hardware. There are other threads here that deal with spikes; and discuss, in addition to pull up resistors, using capacitors. I use a pulse meter for wind and find spikes despite my pull up. Capacitors next.

My HA-Hardware is a RPi 4 with 8MB RAM. My gas meters reed contact input has an RC circuit of 4k7 / 20µF followed by an 74HC14 schmitt trigger to eliminate noise and glitches. I think the signal is okay. Otherwise I would see a binary_sensor state change . . .

Entprellen mit RC-Glied

Known issue, see https://github.com/esphome/issues/issues/3730

Solution at the moment (until the fix is in new esphome version), add the following to your config:

external_components:
  - source: github://pr#4199
    components: [ pulse_meter ]

(You could also use PR 4231) instead according to @Delta1977

1 Like

Thank you for this hint!
I just installed the pulse_meter patch and hope it works fine.

1 Like

Seems to be now included in 2023.2.0:

“Fix broken PULSE_METER esphome#4199 by @cstaahl”

1 Like

I have installed ESPHome update. I will check whether I get less drop outs in pulses.

I just installed ESPHome 2023.2.1 and will report if I find again any missing pulse_meter pulses.

1 Like