-
Notifications
You must be signed in to change notification settings - Fork 13.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Wifi does not reconnect, memory leaks when reconnecting #9061
Comments
Code above does not look like the linked WiFiManager .ino file though. You sure it is Core and / or SDK leaking something and not your app / WiFiManager / some other lib?
Arduino/tools/sdk/include/user_interface.h Line 523 in d5eb265
Name would suggest it could not authenticate with the given passphrase and / or auth settings
begin() without parameters usually means SSID & passphrase were already set, either in persistent mode when those are read from flash or without one where those are managed in RAM. Invalid credentials are the most likely explanation for the error above. |
I am using this code in my project OTGateway. I didn’t show the entire code of the project, because it wouldn’t be interesting to you, but part of the code for working with Wifi can be viewed here. I tried removing other code and working only with Wifi, the behavior is the same. It's really strange that I've very rarely been able to reproduce this, meaning it's not permanent. I've been trying to find the reason for more than 2 weeks before creating this issue.
Hmm. SSID and password are stored in flash memory. However, after a reboot or cold start, the ESP successfully connects to the router. For example, calling What advanced tests can I run for you to investigate this issue? Could it be hardware problems? |
Depends on two SDK settings, WiFi has slightly different names for them (see ESP8266WiFiSTA.cpp for the underlying stuff)
The minimal setup would look something like this, without WiFiManager for right now. Loop then never calls anything related to connection management void setup() {
// otherwise, Core turns WiFi off. this reverts to 2.x.x and SDK default STATION opmode
enableWiFiAtBootTime();
// so WiFi.begin(..., ...) puts stuff into flash
WiFi.persistent(true);
// note that persistent() does not affect these two, both values always persist between reboots
if (!WiFi.getAutoConnect()) {
WiFi.setAutoConnect(true);
}
if (!WiFi.getAutoReconnect()) {
WiFi.setAutoReconnect(true);
}
// assume connection already happening. call begin to reset credentials
if (WiFi.waitForConnectResult(10000) != WL_CONNECTED) {
WiFi.begin(MY_SSID, MY_PASS);
}
} I don't see anything suspicious with a simple ping app. Also no difference between SDK versions. 2.2.x and then upgraded to 3.0.5, both seem to work just fine. Heap slowly goes down from 50968 to 47056, but never lower. Disconnection is either by simply covering the antenna, or |
Hi, @mcspr! Happy New Year and thanks for your reply. I am now confused about the situation I described in the first msg. For tests, I’ll try to make the code without all the extra stuff and come back with the results. If you have any ideas why this might be happening, please let me know. Thanks! |
Basic Infos
Platform
Settings in IDE
Problem Description
On some ESP8266 I am seeing a problem with reconnecting to Wifi. At a random moment in time, the ESP loses its connection to the Wifi and I try to reconnect, but the ESP does not connect. I also tried adding the following code before calling
WiFi.begin()
:But this does not give any result. Eventually the memory runs out and the ESP reboots with an exception. Decoding the stacktrace does not give anything, because all the exceptions are related to the inability to allocate memory.
The strange thing is that this does not happen with all ESPs.
I compiled with the flags
-D DEBUG_ESP_CORE -D DEBUG_ESP_WIFI -D DEBUG_ESP_PORT=Serial
and saw something strange:After this, the ESP refuses to connect to Wifi. But after a restart (cold start), the connection works correctly.
MCVE Sketch
https://raw.githubusercontent.com/tzapu/WiFiManager/master/examples/NonBlocking/AutoConnectNonBlocking/AutoConnectNonBlocking.ino
Debug Messages
The text was updated successfully, but these errors were encountered: