-
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 automatic reconnection not working in 2.4.0 but works in core 2.3.0 #4397
Comments
have you tried the handler instead of polling? theres an event callback when ESP is connected and gets an IP, and another event callback when its disconnected. obviously you shouldnt call reconnectMQTT from the callback, but you can set a bool in the callback and when your loop() hits itll disable the bool after running reconnectMQTT |
@tonton81 The code here works well and going very fast through the main loop so there is no polling issue. The purpose of this bug report issue is for the WiFi handling in the esp core 2.4.0 that was working fine in previous version 2.3.0 in order to fix the current core release. WiFi is not reconnecting like it should in the newer release. But I note your disconnect handler use for a future project, thanks for the input. |
@jplavoiemtl please erase all flash, and try with latest git. |
@devyte Ok I can give it a try. How can I erase all flash using a Windows computer? A good tutorial somewhere? |
i presume with esptool, igor suppost to add a new feature regarding that, to erase everything, or just some parts when flashing |
@tonton81 In the mean time of erasing flash, I'll try the latest git on a brand new Wemos D1 mini board with the latest git in Arduino IDE and report my findings shortly. |
@jplavoiemtl erase flash with esptool-ck. |
@tonton81 Test done with a brand new Wemos board and Arduino IDE esp8266 core 2.4.0. Problem is still there, no WiFi re-connection after I interrupt WiFi on my router. I see WL_DISCONNECT value of 6 and the module is not getting back online with WiFi. Installed core 2.3.0 and there is no re connection problem, it works fine with this older core. So this seems to confirm the bug. I used a brand new board instead of erasing flash because I'm not to familiar with erasing flash and lost a full day on this WiFi issue yesterday. I'm open to try erasing flash later today or tomorrow. |
@tonton81 Finally I did what you suggested and erased flash on module. I get the same problem or bug on esp core 2.4.0. Reverting to core 2.3.0 works fine. |
Is it same as already reported? |
@jplavoiemtl as I said, please try latest git, not release 2.4.0. |
@devyte trying to install the latest git. After restarting Arduino where do I go to see if I'm using this git? In boards manager for esp8266 I only see 2.3.0-rc2 and previous versions. How can I use the git? Here are the steps I did: Linux build status
cd hardware
cd esp8266/tools
Now what? |
@jplavoiemtl you can ever have only one version of a package installed, and that holds for git. That means that, if you install git, you also have to uninstall whatever version you installed from the board manager. Then restart IDE, then rebuild/retest. |
@devyte Using ESP.getCoreVersion(), ESP.getSdkVersion() etc to print out to serial I get:
Does this makes sense for core? Then I erased flash, uninstalled core 2.3.0 from boards manager then rebuild/retest. |
I use my own connection retaining manager in my applications which basically among others disconnects and reconnects the WiFi using the disconnect() and begin() methods and then waits for the status() to return the WL_CONNECTED (3) state. In 2.4.0 if I disconnect() then begin() I always get status WL_DISCONNECTED (6) even though the WiFi is actually reconnected since I can access the module via the WiFi network. WiFi.localIP() also returns 0.0.0.0 ip. |
Could you please provide a simple sketch that reproduces the issue ? |
|
It is not happening if the AP disappears. It is happening if you call WiFi.disconnect() and then WiFi.begin() to reconnect. Just try this simple sketch
Connection in setup() is successful and gives status 3. If you disconnect then reconnect (with the same credentials) then status is always 6. |
Thanks, I could reproduce. I added this at the end of
and now it works as expected. I don't know if we can call that a workaround or if it is a normal behaviour. I understand it was working with core-2.3 but the sdk has changed since then. You may also try to call |
@jplavoiemtl you are not calling |
@d-a-v yes I'm not calling Since it's always 6 in core 2.4 it never reconnects to MQTT. This is why I like using core 2.3 because the WiFi status seems to work better and I get 3 like it should and I can reconnect to MQTT normally... void loop() { //If MQTT client is not connected and wifi is connected if (otaMode == true) { client.loop(); |
I tried the .persistent (false) method but it didn't make any difference. The thing is that Wifi actually recconects even though status and IP are not updated. I can still reach my devices via the Wifi. So is there a workaround if someone needs to disconnect from and reconnect to the same AP? |
@babylonx hopefully they will fix that Wifi status not updated issue. In my case Wifi status is important because if Wifi is truly not present and I try to reconnect to my MQTT broker, there are errors and the module stops running. So it's important to have a reliable Wifi status to prevent that. |
Does the other "workaround" work (not calling I tried WiFiManager's This is the modified loop in the example:
|
(edited) See the interactive sketch below (STA mode). Once ESP running with PC successfully pinging,
Now, with ESP running and pinging, and switching the AP off,
So to summarize
|
Nice sketch I need to change to to compile
ooh add |
I cannot reproduce this. pulling and retesting |
ohh it is not merged, I need to pull in 4706b55 |
ohh ok , I see I am not even connecting to my router now, so I gotta figure out whats going on. |
ok erase flash seems to have sorted it out |
yeah i seem to be having connection issues now with ap not found.
basic sketch
|
Must be that other bug corrupting some memory, Ill test one thing at a time and come back to this. |
@tablatronix Good point with memory corruption. We've noticed the following: being built with Arduino IDE, and 2.4.0 the issue with wrong connection status pops-up. But the same code being built with Platformio reconnects perfectly. The only difference I see is the link order and map file. So very likely to be memory corruption issue. |
@devyte I always use the portable setup for Arduino IDE because the regular setup is quite nasty. Users can run dozens of these portable versions (2.30, 2.40-rc2, 2.4.0, master etc) all at the same time whilst they are waiting for the next release. |
I use platformio, I can change it on the fly. |
@tablatronix, a bit off-topic, but can you point me how to use git version with platformio? |
http://docs.platformio.org/en/latest/platforms/espressif8266.html#stable-and-upstream-versions
So maybe its no longer needed, in latest version of pio, I have not tested that yet. You used to have to use that https://github.com/platformio/platform-espressif8266 |
@jplavoiemtl Is this still relevant with 2.4.1 ? |
I think my issue turned out to be NVS , when I erased NVS, I have not encountered this again. |
@d-a-v I tested with the new 2.4.1 core and it is now working fine. My issue looks to be fixed here. Thank you. |
I am using 2.4.1 core and the latest git commit and also enabled the WiFi debug. So on Wifi disconnection (note: I don't turn off the router I just turn off the internet connection in my router) and on reconnection it is still not connecting. In debug I am getting 'wifi evt: 7', what does this mean? |
@Nakul93 |
@pfabri just search/read the documentation... https://docs.platformio.org/en/latest/projectconf/section_env_general.html |
@Pablo2048 |
Most people fork the platformio repo and manually pull from espressif, pio is working on a way to pull versioning from espressif instead if their useless versioning releases. I have had some success with pulling staging and manual git checkouts in platform |
@tablatronix Many thanks! |
Basic Infos
Hardware: ESP-12E
Core Version: 2.4.0
Description: bug found in esp8266 core 2.4.0
Here is a bug I found in esp core 2.4.0 that was not there in core 2.3.0. The esp does not reconnect automatically to WiFi while using WiFiManager. When my esp is running it connect to WiFi no problem. I have a WiFi status of 3 which is connected. Serial.println(WiFi.status());
Then I deactivate WiFi in my router to simulate a WiFi problem. After I reactivate WiFi on the router, the esp does not reconnect to WiFi. I check status at 1 second intervals and I get 6 for a WL_DISCONNECT
The problem is not related with WiFiManager. To solve it I had to revert back to esp core 2.3.0 and the WiFi reconnects fine and WiFiManager works like a charm.
Quick fix: revert to previous core 2.3.0
I hope it will be resolved in the next version. In the mean time, if someone experience the same problem with core 2.4.0, revert to core 2.3.0 as a quick fix.
Settings in IDE
Module: NodeMCU 1.0 (ESP-12E)
Flash Size: 4MB
CPU Frequency: 80Mhz
Flash Mode:
Sketch
Basic WiFiManager and very simple code to initialize WiFi in setup()
Very little in the main loop checking WiFi which is the purpose of WiFiManager.
The text was updated successfully, but these errors were encountered: