ESP32 board going often unavailable

Hello,

I am looking for help troubleshooting the following situation:
I have an ESP32 board, ESP-WROOM-32 connected to an HLK-LD2450 sensor and integrated in HA with ESPHome.
Logs and full configuration are below.

However, sometimes at random intervals, the board goes unavailable, rendering any automations configured based off the LD2450 sensor, unreliable.
I have checked and noticed that the ESP32 board disconnects from the router. It comes back after reconnecting the power supply, or on its own after a while.

What I have tried so far:

  • Rewriting the firmware with EWS enabled or disabled
  • Using static or dyamic IP address over DHCP
  • increasing/decreasing the WiFi power saving mode in the firmware
  • enabling/disabling bluetooth

The behavior is consistent, as described, and I am out of ideas about what else I should try.

How long does it stay unavailable/offline for? between 10 seconds to 20 minutes.

What I have not tried:

  • Replacing the board with a new one.

I feel like there is something I am missing, due to lack of experience and knowledge.

What else I have noticed:

  • After not detecting presence for a while, let’s say, when I walk in the room first thing in the morning, it always goes unavailable when it detects me the first time.
  • It is not limited to this behavior, sometimes it just goes offline on its own with me being in the room (around 1 meter away from it, in front of it).
  • Upgrading to ESPHome version 2024.7 has not changed anything.

Logs: dpaste/6U6rj (Python)

Yaml: dpaste/ENGn3 (YAML)

Check that your power adapter is adequate. Sometimes those cheap USB power supplies can be a problem.

Sounds a lot like potential WiFi issues (in general). How far is it from an access point and how congested is your area (as in, are there a lot of different WiFi networks)?

Ask yourself what you are doing in the room that might cause interference. What devices are you switching on while you’re in there?

I’m not joking - had a similar issue with an ESP8266 that would drop out for hours at a time. It didn’t do it frequently, but once it started, it would drop off for about a month or two.

It took me a while to realise that this always seemed to happen when I was playing on my PS4. Experimented a bit and, sure enough, within a few minutes of turning on the console, the ESP would go offline. This despite one being on the 5G network and the other on the 2.4G on a different router, and the fact that they were 2 floors apart.

Problem went away when I switched to the PS5 so I never bothered to figure out exactly why, but I suspect that’s the source of your problem.

Thank you for the replies and suggestions. The sensor sits around 5 or maximum 6 meters away from my router, in direct line of sight (no walls, just door, which most of the times is open). It doesn’t matter if the door is open or closed, the behavior is the same.

I don’t have wifi network congestion in the area, and the channel of my wifi networks (production and IoT) is monitored, so it doesn’t overlap with the neighbor’s. Other WiFi devices are not affected in any way.

The idea of interference could be valid, because the sensor sits in my office, together with my work laptop, phone, personal phone, PS5, printer and other devices you may find in an office. There are also zigbee bulbs in vecinity.

So as an action plan, I would try and move the sensor in the same room, but relocate in the opposite corner and assess the results.
If this does not work, I would put it one day in a totally different room where I know for sure there are not as many devices as in the office (in the beedroom for example).

I’ll come back with results.

Try commenting out or removing the following line from your yaml:

improv_serial:

and also to disable serial logging with the following:

logger:
  baud_rate: 0
1 Like

I am/was also desperate because one of my ESP32s kept crashing.

I tested several power supplies and cables, nothing helped.

Now I have supplied it directly with 5V at PIN => VIN, everything seems to be OK now

This sounds like a sensible proposal. Thank you.
I have reflashed the board considering these recommendation. I need 24 hours to assess the results and I’ll let you know.

@fantangelo - I am using an USB port built into the wall outlet. I have also tried with the charger of my mobile phone and it didn’t make a difference.

The board is powered via its usb-c port.

There are lot of wifi range issues with boards with usb c supply. Try powering through 5v pin.

I can also confirm that the USBC port is inadequate for anything but flashing.

Read through the following thread and see if your ESP32 is the same as these:

I have made this change yesterday and since then I have noticed a significant improvement. 24 hours have not passed, but I am not getting the disconnects as much as I would have previously. There are still here, but further away from each other and only for a couple of seconds. This does not have any impact on the automations that run in that room based on this sensor.

This board is a CP2102. In theory, it should not have the problem described in the article you have linked.
Moreover, I have the LD2450 sensor supplied using the VIN pin of the board. I am not sure if I can use the same pin to power the board itself, or I should use another one, should I decide not to use the USB-C port for supplying current.

Thank you for your help and suggestions. I would wait one more day and than mark your answer as solution.

This is the board I am using.

Yes you can.

Quick update on this topic: It turns out, that the problem was due to a WiFi interference caused by a nearby Xerox B235 printer…
I had a situation when the printer was disconnected for two week and it dawned on me. I have had significant fewer problems, if at all, ever since.