Good afternoon, I have an ESP32 with the code below, and it disconnects from the network randomly and does not turn back on. It’s working fine for hours, and then it goes offline.
Logger: aioesphomeapi.connection
Source: runner.py:188
First occurred: 17 de dezembro de 2023 às 18:15:31 (9 occurrences)
Last logged: 00:28:49
esp32-anexo2 @ 192.168.1.***: Connection error occurred: [Errno 104] Connection reset by peer
esp32-anexo2 @ 192.168.1.***: Connection error occurred: Ping response not received after 90.0 seconds
Just to rule it out, you may want to add the following to your WiFi section
A few years ago, when I first started with ESPHome, I had to disable the WiFi power saving in order to keep the ESP32 microcontroller connected reliably.
I had to do the same and remove power saving for all of my ESP32 nodes. Most of them have a signal strength between -52dbm and -64dbm but they would periodically and randomly disconnect then reboot. Once I turned off power saving they stay connected all the time. I did have to disable the web server on one of them as well due to it causing the Wi-Fi stack to lose interrupt timing and cause comms issues. If there’s too much the ESP is doing, it can’t do everything it needs to do when it needs to do it and Wi-Fi comms is one of those things that can’t be delayed or something views it as a hung client or unresponsive client and it either gets kicked off the network or it reboots.
Thanks for the tip. I’ll change it and give you feedback later. I didn’t change this because I had to compare it with another esp32 that has the same configuration and has power_save_mode: in light and I have no problems with that other one. But, as no two esp are alike, you may be right. I’ll try. Thanks
The power_save_mode: NONE does not work with esp32_ble. I had already looked at github and a solution would be to change the Arduino version to 1.0.4, but this version is already from 2018 and gives an error when installing
Did you ever figured out what was your issue? I just acquired 2 of these ESP32 S2 mini and one of them disconnects from wifi and never regain connection. The disconnects are random ranges from 10 mins - a few hours a later. Both of these run the same human sensor and code, but one of them will not say connected to wifi. My wifi signal is steady at -46.
I managed to capture this log when it disconnected.
INFO ESPHome 2024.9.0
INFO Reading configuration /config/esphome/sr-human-sensor.yaml...
INFO Detected timezone 'Asia/Tokyo'
INFO Starting log output from 192.168.1.187 using esphome API
WARNING Can't connect to ESPHome API for sr-human-sensor @ 192.168.1.187: Error connecting to [AddrInfo(family=<AddressFamily.AF_INET: 2>, type=<SocketKind.SOCK_STREAM: 1>, proto=6, sockaddr=IPv4Sockaddr(address='192.168.1.187', port=6053))]: [Errno 113] Connect call failed ('192.168.1.187', 6053) (SocketAPIError)
INFO Trying to connect to sr-human-sensor @ 192.168.1.187 in the background
In your ESPHome wifi: section, have you tried adding “power_save_mode: none” as shown below? I know that this solved the problem of my ESP32 periodically disconnecting a couple years ago.
Yes, I have tried power_save_mode, but it didn’t work. However, removing web_server seems to helped. It’s been 15 hours and the device is still connected.