Utility Meter false reading spikes

I recently implemented a NodeMCU running ESPHome into my HASS to monitor mains electricity usage. It uses a TSL257 in a 3D printed housing to capture the light pulses from my utility company power meter.

It works well for almost all the time - but every now and again (about once a day) it does something completely weird as shown below:

My mains trip is 80A so there is no way it could have had that much power in that space of time (I’m joking, it is clearly not legitimate!) :wink:

I also have a clamp-on inductive sensor measuring current - it did not show this peak so it is either a spurious burst of flashes from the meter or some kind of electrical interference.

The meter seems to be reading about right - it is not registering any unusual peaks - so what on earth could be causing this?

The drop at 00h00 reflects the daily reset on the counter so is not an error.

Any ideas welcome!

Thanks.

Richard

Configuration.yaml entry:

utility_meter:
  energy_daily:
    source: sensor.mains_power_meter
    cycle: daily
    tariffs:
      - peak
  energy_weekly:
    source: sensor.mains_power_meter
    cycle: weekly
    tariffs:
      - peak
  energy_monthly:
    source: sensor.mains_power_meter
    cycle: monthly
    tariffs:
      - peak

ESPHome code for the NodeMCU (partial):

i2c:
  sda: D2
  scl: D1
  scan: True
#  id: bus_a

ads1115:
## see https://esphome.io/components/sensor/ads1115.html
  - address: 0x48
sensor:
  - platform: pulse_counter
    pin: D8
    unit_of_measurement: 'kW'
    name: 'Mains Power Meter'
#    update_interval: 5s
    internal_filter: 10us
    id: mains_power_meter
    accuracy_decimals: 3    
    filters:
      - multiply: 0.06

  - platform: ads1115
    multiplexer: 'A0_A1'
#    gain: 6.144
    gain: 4.096
    name: "Mains Current"
    update_interval: 1.5s
    unit_of_measurement: "Amps"
    accuracy_decimals: 2
    filters:
      - calibrate_linear:
#          # Map 0.0 (from sensor) to 0.0 (true value)
          - 0 -> 0
          - 0.3 -> 4.5
          - 5.0 -> 50.0
      - sliding_window_moving_average:
          window_size: 5
          send_every: 6

Hi.

I made something similar with a optical pulse counter for my power meter. I used a optical resistor and a small analog to digital signal amplifier/converter.
I had similar problems as you have. Now and then I got these high spikes.

First my sensor case was not dark enough. Take a flashlight and shine on it and see what happens. The second thing I hade to change was that pulse counter filter to millisecond level. My optical resistor was is very noisy.
Last I had to trim my amplifier that converted my optical a signal digital.
Made it much more insensitive.

I don’t know if you have same problems. But I hope you find what is the cause.

/Mattias

Thank you both. I think I have found a solution but am not sure why it works!

I’m now using the integration sensor and it appears to have stopped these spikes.

# https://www.home-assistant.io/integrations/utility_meter/
  - platform: integration
    source: sensor.mains_power_meter
    name: energy_used
#    unit_prefix: k
    round: 3

If anyone can explain why this helps please do as I’m not sure how it does it.

Richard

I use an inductive 4mm sensor with a ESP32 running esphome.
It works, but gives problems, i think especially when the coil stops right under the sensor.
how can i debounce this?
I suppose this is done with the “internal_filter” within ESPhome?
See: https://esphome.io/components/sensor/pulse_counter.html
Though that page says: *“Defaults to 13us. On the ESP32, this value can not be higher than 13us”
Is this because of ESPhome or because of the hardware (ESP32)

any suggestions?