Strange spikes from meter with GLOW

Hi

I have a strange problem with the power input on the new Energy system, I am using ESP32 with the code from GLOW, all works perfect exept that some strange spikes occur 1 og 2 times pr. 24 hours

sensor:
  - platform: pulse_meter
    name: '${friendly_name} - Power consumption'
    unit_of_measurement: 'W'
    state_class: measurement
    device_class: power
    icon: mdi:flash-outline
    accuracy_decimals: 0
    pin: ${pulse_pin}
    on_value:
      then:
        - light.turn_on:
            id: led_red
            flash_length: 400ms
    filters:
      # multiply value = (60 / imp value) * 1000
      # - multiply: 60
      - lambda: return x * ((60.0 / ${pulse_rate}) * 1000.0);

Any tips to avoid this ??

Regards Erik L

1 Like

Hi, I am having the same problem. Huge spikes at random every so often. Did you find a fix for this? I have a pulse rate of 3200. I am using a Wemos D1 Mini.

Just an idea from someone that stumbled on to this thread and never used this kind of sensor:
Does it correlate to times you go into the room with the meter or sunset/sunrise? If your photodiode is not sufficiently isolated every flash of light (like turning on light in the basement) can be counted as a pulse. Some meters with transparent covers over the body can make this particularly difficult. Try covering sensor area with black tape and lowering it’s sensitivity. Also make sure that you wiring is solid and does not create pulses when moved. (EMI could also be a thing if your wires are long)

Thanks, I will give that a go. The wires are only 4cm long in the box. I have a RED LED to repeat the blink to another sensor also, I’ll try disconnecting that and see if it helps. I put some filler in the box after I took this picture to prevent the RED LED from trigering the photodiode also but did not help. The unit is in an enclosed meter box with no light getting in.

I checked the ESPHome page regarding the pulse_sensor that I am using for this project and found I needed to configure an internal_filter of 100ms to prevent these spikes.

This is the page I followed to create the project.

I tried all sorts of things.

In the end I swapped GPIO’s.

I was using GPIO12 on an ESP32 and have swapped to GPIO26.

This sorted it for me.

3 Likes

I tried all of the suggestions on this thread and others to try and combat the spikes I was getting. For some reason none of them helped. I went so far as to have multiple ESPs connected to the photodiode board, an arduino to buffer and clean the pulse signal, different power sources, and even tested the ESPs with a signal generator.

I found that the spikes would only occur when the ESP was connected and powered near the smart meter itself. I was able to remove the spikes completely (at least after a day of testing…) by moving the ESP further away from the smart meter…

I assume the GSM signal from the smart meter is interfering with the ESP and causing this glitch, as at least for me the spikes were periodic and at the start of every hour.

I have the exact same problem. For a moment I thought it was resolved in the esp home update I got yesterday but then I got a spike today as well.

sensor.home_assistant_glow_power_consumption,143,2024-07-05T10:15:51.216Z
sensor.home_assistant_glow_power_consumption,154,2024-07-05T10:16:14.621Z
sensor.home_assistant_glow_power_consumption,162,2024-07-05T10:16:36.775Z
sensor.home_assistant_glow_power_consumption,163,2024-07-05T10:16:58.880Z
sensor.home_assistant_glow_power_consumption,164,2024-07-05T10:17:20.833Z
sensor.home_assistant_glow_power_consumption,245734,2024-07-05T10:17:20.869Z
sensor.home_assistant_glow_power_consumption,162,2024-07-05T10:17:43.065Z
sensor.home_assistant_glow_power_consumption,164,2024-07-05T10:18:05.036Z
sensor.home_assistant_glow_power_consumption,167,2024-07-05T10:18:26.571Z
sensor.home_assistant_glow_power_consumption,168,2024-07-05T10:18:47.964Z
sensor.home_assistant_glow_power_consumption,169,2024-07-05T10:19:09.232Z

Since the spike value is way out of scale I guess it’s som kind of EMC related.

I gave up with glow, having run it for several years had to add filters etc in yaml and it worked perfectly but would eventually fail again - the potentiometer would move slightly by itself (maybe moisture or heat related?) and I would get spikes again. Got sick of having to adjust it, so ended up going with a Shelly EM dual clamp meter put it in my mains box, one clamp on main power feed and one on HWC and works with zero issues. Cost a bit more but it’s very accurate and just works.

If you want to stick with glow, this worked for me (you may want to adjust the max value)

sensor:
 # WiFi signal
  - platform: wifi_signal
    name: "${friendly_name} - WiFi Signal"
    update_interval: 120s
    
  # Pulse meter
  - platform: pulse_meter
    name: '${friendly_name} - Power Consumption'
    id: sensor_energy_pulse_meter
    unit_of_measurement: W
    state_class: measurement
    device_class: power
    icon: mdi:flash-outline
    accuracy_decimals: 0
    pin: ${pulse_pin}
    internal_filter_mode: 'PULSE'
    internal_filter: 5ms
    on_raw_value:
      then:
        - light.turn_on:
            id: led_red
        - delay: 0.1s
        - light.turn_off:
            id: led_red
    filters:
      # multiply value = (60 / imp value) * 1000
      # - multiply: 60
      - lambda: return x * ((60.0 / id(select_pulse_rate).state) * 1000.0);
      - lambda: |-
            float MIN_VALUE = 0.0;
            float MAX_VALUE = 18000.0;
            if (MIN_VALUE <= x && x <= MAX_VALUE) return x;
            else return {}; 
      # Update the sensor with an average every 10th second. See
      # https://github.com/klaasnicolaas/home-assistant-glow/#reduce-the-amount-of-data-the-sensors-produce
      # for more information.
      - throttle_average: 100ms
      - filter_out: NaN

    total:
      name: '${friendly_name} - Total Energy'
      id: sensor_total_energy
      unit_of_measurement: kWh
      icon: mdi:circle-slice-3
      state_class: total_increasing
      device_class: energy
      accuracy_decimals: 3
      filters:
        # multiply value = 1 / imp value
        # - multiply: 0.001
        - lambda: return x * (1.0 / id(select_pulse_rate).state);

        # Update the sensor once per 0.1 kWh consumed, or every 5th minute, whichever happens sooner.
        # See https://github.com/klaasnicolaas/home-assistant-glow/#reduce-the-amount-of-data-the-sensors-produce
        # for more information.
        #- delta: 0.01
        #- heartbeat: 300s

  # Total day usage
  - platform: total_daily_energy
    name: '${friendly_name} - Daily Energy'
    id: sensor_total_daily_energy
    power_id: sensor_energy_pulse_meter
    unit_of_measurement: kWh
    icon: mdi:circle-slice-3
    state_class: total_increasing
    device_class: energy
    accuracy_decimals: 3
    filters:
      # Multiplication factor from W to kW is 0.001
      - multiply: 0.001