ESP32 Disconnects

ESP32 WROOM 32 or any 32. won’t update wirelessly and sends status state off then on back and forth. If you let it sit long enough or keep resetting it, it mite work. HA will say unavailable because of the cycling. Am using manual_ip dhcp mac is locked down. requested disconnected then connected successfully back and forth. :frowning:
Anybody have any ideas?
12.4 and I think up to date.

Search this forum for the word ‘unavailable’ and also ‘disconnect’ and you’ll find that this is a pretty common problem not specific to ESP32’s, but to all ESPs whenever there is any kind of imperfection in the network link.
e.g. dropped packets or unusual latency. Try using ‘ping’ against your ESP for a while, and see how many packets are lost. There should be none, but if it’s nonzero, that may be the root cause of your problem, and it’s not necessarily unique to your LAN.
That is, if you can remove the latency and lost packets you would see a dramatic improvement WRT HA connection. I’m convinced that the ESPhome-HA link is too fragile to tolerate even minor net flaws, and needs to be made more tolerant.
So my cards are on the table. But maybe they’ll help you avoid a slew of unnecessary diagnosis work.
(yes, I have an axe to grind, because I’ve been observing this phenomenon for about a year now, but everyone blames power, or bad DHCP, or whatever else there might be. I have seen fragile session layers before, and this one rings all the same bells.)

2 Likes

In the ESPHome code, disable any WiFi power saving especially if this is an always on or plugged in device and not running on a battery. For an ESP32 the default setting is “light” which will cause the WiFi to disconnect, sometimes frequently.

wifi:
  # ...
  power_save_mode: none
2 Likes

The diagnosis-and-corrective attempts usually do start with the WiFi power-saving.
Maybe later followed by suggestions of static IP addresses, DNS rigor, and the like.
Followed soon by “that didn’t work”.
(ask me how I knew)

4 Likes

Any yaml you can present us? Any logs to clarify whats (really) happening?

Do you use ble_tracker for example? Or the esp-idf framework? So many questions… so little answers (@Joe3 their is a post somewhere hidden in this forum how to ask good questions :shushing_face:)

Here is the yaml.

I get “HA Connected successfully” then around 5 seconds later “HA requested disconnected” then back on in 5 seconds. I see this through the uart logger
On the ESPhome dashboard the device shows present and HA status disconnected .
Also never successfully will connect for OTA upload.
Other ESP8266 devices are at the moment solid status on.

esphome:
  name: gar-str-32

esp32:
  board: esp-wrover-kit
  framework:
    type: arduino

# Enable logging
logger:

# Enable Home Assistant API
api:

ota:
  password: "5hrthsgzrZfsytjdndfadba"

wifi:
  ssid: 'ssid'
  password: 'password'
  power_save_mode: none
  
  manual_ip:
    static_ip: 192.168.5.122
    gateway: 192.168.5.1
    subnet: 255.255.255.0
    dns1: 192.168.5.1  
  
  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Gar-Str-32 Fallback Hotspot"
    password: "password"

captive_portal:

binary_sensor:
  - platform: status
    name: gar str 32 status   

A couple of months ago my previously stable ESPHome devices started disconnecting and refusing to update OTA. Eventually I ran a WiFi analyser and found that the channel my router was using was congested so I set the router to a clear channel and everything returned to highly reliable performance.

You might want add a WiFi signal sensor :signal_strength:

A weak WiFi connection is often breaking ota capabilities.

I’ve submitted a feature request for adjustable timeouts to help diagnose and workaround problems like you’re experiencing.
You may wish to add your vote to it.
There are many new feature requests per day, so this one will soon be lost in the flood, I fear, and never be seen. But who knows…

1 Like

Thanks guys, I’ll put the eps32 aside for a few more revisions of esphome. glyndon I feel the same way about things being fragile right now. But this stuff is fun and I usually see fun improvements.
As a comparison my ecobee and myQ stuff is way less reliable then ha lol. But HA is a thousand times funner :slight_smile:
Great suggestion with the WiFi Sensor. I’ll give that a try

I should have also included this link. (It’s to a specific article, not just pointing you at the FAQ list :wink: )
It’s good to know the right people know about this issue. Likewise, confusing that no one’s tackled it yet.

1 Like

What did you do to analyze the network, any suggestions on diagnostic software tools or something like this?

In my recent case (Asus wireless router and access points) resetting the 2.4GHz band to Legacy mode resolved all my ESP8266 and ESP32 connection issues. It seems when Asus-WRT firmware attempts to manage 802.11’n’ connectivity, the ESP / Arduino wifi connection code is very definitely not happy.