Recorded a nearby lightning strike with ESPHome + PZEM-004T V3

I saw a lightning in the distance, and at the same time one of our RCD tripped :zap:
Fortunately the HASS installation and WiFi router were on a different circuit and kept running :slight_smile:

The PZEM is not specified to measure such high voltages, but I think it can be interesting to post the data here in case someone can provide more insight:

sensor:
  - platform: pzemac
    update_interval: 3s
    voltage:
      name: "Voltaje AC"
      accuracy_decimals: 1
      filters:
        - sliding_window_moving_average:
            window_size: 20
            send_every: 20
            send_first_at: 20
    power:
      name: "Potencia AC consumida"
      filters:
        - sliding_window_moving_average:
            window_size: 2
            send_every: 2
            send_first_at: 2
      accuracy_decimals: 0

Voltage measurement:

21:15:15 -> 235.6
21:16:15 -> 235.6
21:17:15 -> 235.9
21:17:30 -> 266.8
21:19:18 -> 478.5
21:20:18 -> 236.4

(The 17:30 minute mark is bugging me: why would the ESP send values earlier than it should? Can a voltage surge cause that? Is this an interpolation by HASS when the sensor disconnects & later reconnects?) UPDATE: It is! see here

Power measurement:

It read 214W to 216W until 21:17:30, when it read 30.337.052W. Then there is a gap, and at 21:18:28 it read 142.055.264W. Afterwards it was reading 71-60W. Time travelers, you are welcome! :racing_car: :zap:

Unfortunately neither AC current nor AC frequency were enabled, so that’s all the data we have.

There’s a household surge protector - I hope it helped a bit? No electronics seem to have been damaged :smiley:

5 Likes

Reverting the moving average, and assuming the 21:17:30 sample is ficticious/interpolated by home assistant, there could have been an instantaneous measurement of ~5092V (?)
Anyone knows what’s the true maximum voltage that can be read by PZEM-004 V3?

However there’s still the mystery of why there is no sample at 21:18:18. Does someone know how are disconnections handled by HASS/ESPHome?

According to the SD3004’s datasheet, this energy meter uses a voltage divider that goes to an ADC:
Screenshot_20210212_181213

With those resistor values, the maximum theoretical voltage that the device can mesure is 5000V, which is darn close to the estimated measurement.
However, the rest of the circuit wouldn’t stand such high voltages; It’s more likely there simply was an electromagnetic interference and the device went “nuts” :slight_smile: (as well as one of the RCDs)

Maybe the EM pulse was captured by the AC current probe, which is a very large coil.
Screenshot_20210212_183136

However there were plenty of lightning that night, and this only happened with the one that made the RCD trip.

1 Like

Ah, just found these values at https://github.com/esphome/esphome/blob/d238e06f86630c77c7a105590549e55e93104f57/esphome/components/pzemac/pzemac.cpp#L32

Screenshot_20210212_185840

(still think the ADC is internally limited to measuring 5V, this is 5kV after the voltage divider, and 500A for the current clamp coil. not considering RMS though :thinking:)

That first peak is indeed ficticious:

It turns out that’s a (confusing) interpolation that HASS incorporates upon sensor disconnection.

I’ve migrated the data to influxdb and there’s only one “high voltage” sample (remember it’s after a 20 sample moving average though, read comments above)
Screenshot_20210214_232840

That’s cool. Years ago I made a lightening detector for physics class (high school) by connecting a Tesla coil secondary through an op-amp to an A-D converter. Computer would scan the output of the A-D converter via parallel port in a continuous loop and plot the points on a graph. Written in QBasic.

2 Likes