Wifi interference with HC-SR501

I have had numerous false positive triggers of HC-SR501 on an ESP32, unfortunately my research has led me to some weird and wonderful solutions. From running it on 3.3V, soldering items to it, and reducing the Wifi band and tx power. On the latter, I am testing a build with some changes to do just that.

Research - HC-SR501 PIR - stop false positives? - Page 1 - Let's Control It
I solved this with the next solutions:
A: Used a 47uF and 102pF power decompling consensator soldered over the pir power connections at the ESP8266 side.
B: Put the ESP in 802.11G mode instead of 802.11N mode. I think the Rf spectrum will be less in G mode.
C: Put the ESP in wifi STA mode only.
D: Lower the ESP wifi output power to 10dBm.

In main.ino

  //Reduce WiFi interference when using ESP32 using custom WiFi mode and tx power
#  ifdef ESP32
  // https://github.com/jnogues/ESP32-Long-Range-WiFi/issues/4
  // Reset wifi protocol
          Log.error(F("Failed to reset WifiMode." CR));
  #ifdef WifiGMode
    if (esp_wifi_set_protocol(WIFI_IF_STA, WIFI_PROTOCOL_11B | WIFI_PROTOCOL_11G) != ESP_OK) {
      Log.error(F("Failed to change WifiMode." CR));

  #ifdef WifiPower
#  endif

In environments.ini

build_flags =

Anybody else with similar PIR problems and resolutions? I am now also logging the triggers to see if the code made any difference.

1 Like

Been 12 hours with no False triggers, and I continue to monitor.

Not a single false trigger in the past 36 hours :slight_smile:

1 Like

@diepeterpan You are very determined with that motion sensor, mine went in the scrap pile years ago as the internet consensus was that the AM312 was a lot more reliable.

One of many threads - HC-SR501 pir sensor gives false triggers - #5 by martinst - Hardware - Home Assistant Community

So far I am very impressed at the stability since changing the WiFi to G instead of N and lowering the tx power. Not a single false trigger in 60 hours.