Can't stop ESPHome restarting with weak wifi

Yes I have Google Wifi and it seems that ESPHome had connected to a weaker access point. To remove this as a factor I have now setup a new, single, wifi access point in the garage with a different SSID

Since doing this I have had 5 days of trouble free running but unfortunately today the resets started again. My observations are:

  1. At 12.44 the reported wifi signal strength to the new access point dropped from around -50 to -60.
  2. First outage occurred at 12.51 for ~40 seconds
  3. Device reconnected at 12.52 for around 5 minutes.
  4. Second outage occurred at 12.57 to 13.29 (33 minutes!)
  5. Device crashes with fatal exception 9 two mins later at 13.31
  6. Device is reported “unavailable” until it reconnectts at 13.39
  7. Device crashes again at 13.44 with fatal exception 28
  8. Device back up and running at 13.45

Interestingly, I have setup another ESPHome device next to the troublesome device and so far its been stable.

Thanks, I’ll play with that setting next and see if it changes anything.

1 Like

Interesting. So with the same yaml configs (obviously different names) you get a different mileage?

Are they the same esp’s (dev boards)? Maybe even same batch? Or different boards/devices?

Often most crucial is the antenna design - and that was messed up on the esp-12e modules:


Source: WiFi module-The Difference Between ESP-12E and ESP-12F

Hi,
I have the same problem with MQTT, it reboot at random time even with good WiFi coverage, my config file:

Showing your esphome yaml may help and perhaps a picture of the circuit. What about the power supply?

The board is this one https://www.aliexpress.com/item/4000026433011.html
I’ve flashed ESPHome on it using their doc, it’s powered by 24V output from a 5KWh Solar Inverter, i guess it should be stable supply. The problem is that i can reproduce this if i reboot the router or nearby wifi repeater

If you are using this on HA probably don’t need the web server. It uses a lot of memory and the 8266 doesn’t have much memory. Try removing.

web_server:
  port: 80

Also suggest to set static ip, gateway and subnet

That make sense, does the same apply for captive_portal? would be nice to keep it for easy upgrades

Esphome documents warns you about web server but not captive portal. Leaving out bits of YAML is just part of the process of elimination for these sort of problems.

I thought so but nope. The other ESP device has now started resetting with the same fatal exception when wifi is poor. Today it (pool-doser) experienced two restarts whilst the original device (pool-pump) experienced none… but more on that below…

They are both Sonoff devices and interestingly both seem to have the same ESP8285 chip. I found these photos online which match my models and revisions:


Anyway, Since yesterday, I think I may have made a breakthrough. On both devices I had the fallback AP and captive portal enabled (although I don’t recall ever using them).

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password

  ap:
    ssid: "Pool-Pump Fallback Hotspot"
    password: "my-secret-password"

captive_portal:

I had an idea that the crashes were occuring when the wifi drop outs enabled the ESPHome AP/Captive Portal. Yesterday morning I removed the AP config from one device (pool-pump) and left it on the other (pool-doser). Today I have had two reboots on the doser device and none on the pump… so far :sweat_smile:

I will need another week of running to test my hypothesis properly. But if I am correct, I wonder if there is a bug/issue with the AP/Captive Portal when running on ESP8285 chips in at least two Sonoff models :skull_and_crossbones:

1 Like

In your spare sonoff you could run Tasmota to see if more stable at same time.

The captive Portal is indeed a little heavy on the esp82xx because it internally needs probably the web server component to work :point_down:

Please note that enabling this component will take up a lot of memory and may decrease stability, especially on ESP8266.
Web Server Component — ESPHome

To get a little more in-depth about memory usage (specially now that you have the 2 devices behaving differently) you may use the debug sensor which will inform about heap memory of your esps!

And is your yaml very complex/with a lot’s of compoents anyway or is it rather a simple one?

Both devices have been running with 100% uptime since disabling the fallback AP and captive portal. Even during periods of poor wifi.

So it really does look like the root cause was that the captive portal is too much for the ESP8285 chip in these Sonoff devices.

Rather simple. Basically the following yaml with a couple of scheduled automations (time:) and the captive portal.

3 Likes

thx for the infos.
I have a similar issue with an ESP32 and weak wifi.
It reboots every ~4h.

Did you let the “reboot_timeout: 0s” on api & wifi set?

Now i am trying to deactivate: fallback AP, capacitive portal, webserver & reboot timeout

I know the ESP32 is more powerfull, but i dont know what todo instead of this.

Yes. I set reboot_timeout to 0 but it didnt help.
Enable debug: to see the restart reason and determine if the restarts are expected or unexpected.

thx for the hint,
i have now activated the debug component like described here:

I hope there is some usefull information in the reset reason after the issue occurred, and not just “Software Reset CPU” :slight_smile:

There is just an PowerOnReset in the debug Logs.
Also i was connected ofer wifi to the device with live logs and NO exception or anything. Log just stops!

Here is a possible workaround (set static IP instead of using DHCP): Help with esphome error/rebooting every 2-3 hours - #4 by pOpY

Will post updates in the other thread.

Curious, if you remove AP and captive_portal, is there anyway to update the device other than HA dashboard? Lets say it won’t connect to HA for some reason, and you need to change SSIDs or something along those lines. I have this problem described in this thread with a device, but it’s a switch that I can’t just open and connect to the serial port, so I’ve left captive portal and fall back AP on so if there is a problem with HA or it won’t connect to HA for some reason, I have other ways to connect to the device.

The ESPHome dashboard / add-in is not the HA dashboard. If the device is still visible/connected on the ESPHome dashboard then you can perform an OTA update.

Otherwise if its inaccessible to the network (e.g. SSID change) then you will need to reflash physically or temporarily create a wifi network with the old SSID and credentials.

Sorry to reopen this older thread.

@dbalzan
Would you mind providing details how to do this?

My ESP32 sometimes loses connection to the router in the car (e.g. due to failover switch from public Wi-Fi to mobile data). When I’ve AP and captive portal enabled, it might happen that the ESP remains in AP mode, despite the router’s Wi-Fi is available again.

Therefore, I have removed both AP and captive portal from the ESP32.

Now if it fails to connect, and I want to change something (e.g. SSID, just as elaborated by @techoguy ), how could I “temporarily create a wifi network with the old SSID and credentials”? I don’t really understand this part.

Thanks for your time and help! :heart:

I believe what dbalzan meant is create a temp wifi network to connect to the ESP device. So for example, if you change your wifi SSID the ESP device won’t connect of course, so the only way to fix it, is either connect physically to the ESP device through UART (which in many cases isn’t possible or easy) or you change your SSID wifi back to what it was then when the ESP device connects you can update it OTA to change to the new SSID. Then you can change your SSID to the new one for it to connect. This applies if you just change the PW for your wifi SSID as well.
Beyond that, if your ESP device won’t connect to your Wifi for other reasons, without AP and Captive portal active on the ESP device, there is NO way to connect to the ESP device to update it unless you connect physically to the device. The only other options is to try setting up a different wifi access point with the same SSID and PW to see if the ESP device will connect to it.

1 Like