EspHome Device Randomly Disconnects from Wi-Fi

While I built my Air Gradients a while ago, there was a bug with their wifi connections that I’ve been chasing for a while. They drop off the network and don’t reconnect, forcing me to hard reboot them by cutting power to get them to reconnect. I think I’ve finally figured how to get them to at least be mildly stable and keep them from disconnecting for days at a time.

This type of problem looks to be pretty common with lots of chatter around it, and people encountering different ways to solve their problems. I tried a few different things and while none solved it completely, all combined they made the WiFi connections much more stable.

Set 2.4Ghz Channel Width to 20mhz

I found some posts stating that setting the channel width to 20mhz for the 2.6ghz spectrum would give better stability to the esp devices. This does limit bandwidth of the network, but all my high bandwidth devices are 5ghz capable, so I’m not worried if my 2.4ghz network is slower.

Set Power Saving Mode to None

The next step I found in looking for my workaround was to set the WiFi power saving mode to none. I found that action in the home assistant forums.

wifi:
power_save_mode: none

Arduino Version

Another potential solution, setting the Arduino library version to the latest version to hopefully avoid a bug in an older version.

esp8266:
board: esp01_1m
framework:
version: latest

Auto Reboot

Finally, the cream of the crop in janky fixes, just setting up the esp to auto reboot every day. It can’t stay disconnected for multiple days if it reboots and reconnects on reboot right?

time:
- platform: sntp
id: sntp_time
on_time:
- seconds: 0
minutes: 30
hours: 4
then:
- switch.turn_on: restart1

switch:
- platform: restart
name: "rf_bridge restart"
id: restart1
internal: true

Other Suggestions

I ran into a few other suggestions online that I didn’t end up making use of in my quest. I’ve included them below for completeness and so others can make use of it.

WiFi protocol

I saw some suggestions that using wireless G networking would give better stability to esp devices on the network. It was suggested that they didn’t have great support for wireless N, or a bug in the implementation.

WiFi Channel

I have seen some posts about 2.4ghz WiFi channels 12 through 14 being bad to use with esp devices due to the higher frequency range. Their radios may not be able to reach those frequencies, looking in the unifi network configuration for my access points however, those channels aren’t available, so I don’t have to worry about this potential pitfall.

Conclusion

I wish I could get down to the root cause of the disconnects, but this will have to do as a mitigation of the effects of the disconnects and keeping devices from requiring a reboot to reconnect to WiFi and home assistant. My devices are staying connected, with only short disconnects. I also kept the auto reboot as a just in case to make sure things didn’t fall off the network for days at a time.

Leave a Reply