`pulse_meter` with reed sensor: oscillating between two value ranges

I am trying to read my gas meter using a reed sensor. The gas meter is a Honeywell BK-G6 MT.

1 pulse is 0.01m³
I set internal_filter to 3400ms, because the meter supports a max of 10 m³/h
(10m³/h = 1000 pulses/hour = 16.7 pulses / minute = min 3600ms between two raising edges)

I use an ESP32 (az-delivery-devkit-v4) which is overkill but it was lying around.

It seems it’s reading something, but the values are strange from my point of view, it’s oscillating between two “gas consumption speeds”:

image

I think I need to attach a LED to the ESP32 board and make it turn on for each pulse to troubleshoot this and see if there really is two different speeds of gas consumption.

I just wondered if someone had already seen a similar effect with pulse_meter

I use ESPhome 2024.2.1 at the moment.

  - platform: pulse_meter
    name: "gas consumption"
    id: sensor_pulse_meter_gas
    pin:
      number: GPIO25
      inverted: true
      mode: INPUT_PULLUP
    device_class: gas
    state_class: measurement
    accuracy_decimals: 0
    # Honeywell BK-G6 MT: spikes seen, need to be filtered out.
    # Qmax = 10 m³/h
    # 1 imp = 0,01m³
    # Max Rate = 10 m³/h / 3600s / 0,01m³ = 0,27/s = max 1 impulse every 3,6s
    internal_filter: 3400ms
    icon: 'mdi:fire'
    total:
      name: "total gas consumption"
      state_class: total_increasing

actually, better idea, is there a way to draw the GPIO status in parallel? Or do I need to disabled the pulse_meter sensor and create a binary_sensor instead?

So I switched temporarily to a binary sensor. I probably will do the following for easier troubleshooting going forward:

  1. Bridge the GPIO 25 to be able to have both binary_sensor and pulse_meter at the same time.
  2. add a LED that will trigger each time a pulse is detected.

but for now, this is what I see with the binary sensor:

image

This is zoomed out (larger scale of time):
image

So pulses are very regular actually, I count 21 pulses within a two minute window. I would expect the pulse_meter to be at 10 or 10.5 pulses per minute or 0, maybe a brief transition phase before and after, but that’s it. The picture in the first message was taken within one of these “series” hence it should be a solid 10 pulses/min in my view.

I appreciate any pointer on how to troubleshoot this better.

Here’s my ESP8266 config for my electricity meter, fed from a photodiode module looking at the 1/Wh flashing LED.

I have the module output wired to both D2 (binary sensor) and D5 (pulse counter), and the binary sensor operates the LED. internal: true means that HA does not see the binary sensor nor the LED.

switch:
  - platform: gpio
    pin:
      number: D1
      inverted: yes
    name: "Garage sensor box LED"
    id: "box_led"
    internal: true

binary_sensor:
  - platform: gpio
    pin: D2
    name: "Meter pulse mirror"
    internal: true
    on_press:
      then:
        - switch.turn_off: box_led
    on_release:
      then:
        - switch.turn_on: box_led

sensor:
  - platform: pulse_counter
    pin: D5
    unit_of_measurement: 'kW'
    name: 'Power Meter House'
    filters:
      - multiply: 0.06
    id: house_power
    device_class: power

The LED is a super-useful debugging aid: recently, after a couple of years of flawless operation, the power reading dropped right down. I could see straight away from the box LED (in the garage) that it was the pulse input at fault, which led me to the massive spider in the external meter box that had dislodged the magnetically-aligned photodiode.

massive spider in the external meter box that had dislodged the magnetically-aligned photodiode

The concept of “bug” is taking a whole other dimension here…

I have the module output wired to both D2 (binary sensor) and D5 (pulse counter)

Oh, that’s so simple, how did I not think of this?.. Done.

The LED is a super-useful debugging aid

yep, did just that.

ok, so now I can compare binary_sensor and pulse_meter but it still doesn’t make sense to me.

The binary_sensor is super regular, except the first pulse which somehow lasted longer:

image

but pulse_meter shows this:

image

I don’t understand this…

hmmm, so it got better, I also don’t get why:

binary_sensor:
image

pulse_meter:
image

Is there some auto-calibration happening in pulse_meter maybe?

In general I am wondering if pulse_counter wouldn’t be better for such “blocky” pulses. I basically have 10 pulses/min or zero, that’s it. The heater is not modulating the gas consumption it appears, it’s very simple…