[GH-ISSUE #122] Reconnect? #92

Closed
opened 2026-02-28 01:23:22 +03:00 by kerem · 18 comments
Owner

Originally created by @matthuisman on GitHub (Mar 7, 2016).
Original GitHub issue: https://github.com/tzapu/WiFiManager/issues/122

Just wondering how WiFiManager manages WiFi disconnects.
Does it automatically try to reconnect etc?

Originally created by @matthuisman on GitHub (Mar 7, 2016). Original GitHub issue: https://github.com/tzapu/WiFiManager/issues/122 Just wondering how WiFiManager manages WiFi disconnects. Does it automatically try to reconnect etc?
kerem closed this issue 2026-02-28 01:23:22 +03:00
Author
Owner

@matthuisman commented on GitHub (Mar 7, 2016):

I just tried and it doesn't seem to.

Is there any code to make it re-connect.

I would have this in my loop function

void loop(void){
if (WiFi.status() != WL_CONNECTED) {
disconnects++;
Serial.println("Disconnects: "+String(disconnects));
wifiManager.reconnect() ????
return;
}
server.handleClient();
}

<!-- gh-comment-id:193101190 --> @matthuisman commented on GitHub (Mar 7, 2016): I just tried and it doesn't seem to. Is there any code to make it re-connect. I would have this in my loop function void loop(void){ if (WiFi.status() != WL_CONNECTED) { disconnects++; Serial.println("Disconnects: "+String(disconnects)); wifiManager.reconnect() ???? return; } server.handleClient(); }
Author
Owner

@matthuisman commented on GitHub (Mar 7, 2016):

OK.
Using autoconnect again will not work, as that may start the config portal instead of waiting for Wifi.

So, looks like

wifiManager.connectWifi("","");

would be the way to go.

Oh, that's a private function... Bugger..

Might just need to use

WiFi.begin();

<!-- gh-comment-id:193101645 --> @matthuisman commented on GitHub (Mar 7, 2016): OK. Using autoconnect again will not work, as that may start the config portal instead of waiting for Wifi. So, looks like wifiManager.connectWifi("",""); would be the way to go. Oh, that's a private function... Bugger.. Might just need to use WiFi.begin();
Author
Owner

@tzapu commented on GitHub (Mar 7, 2016):

hello,

Usign WiFi.begin() should be fine and work togther with wifi manager.... but... the sdk itself has some auto reconnect functions. it should do it, indifferent of WiFiManager usage, once it s connected

This is my guess, and observations of the esp8266 core and nodes i have online, i have not double checked exactly what is happening behind the scenes

<!-- gh-comment-id:193159034 --> @tzapu commented on GitHub (Mar 7, 2016): hello, Usign WiFi.begin() should be fine and work togther with wifi manager.... but... the sdk itself has some auto reconnect functions. it should do it, indifferent of WiFiManager usage, once it s connected This is my guess, and observations of the esp8266 core and nodes i have online, i have not double checked exactly what is happening behind the scenes
Author
Owner

@tablatronix commented on GitHub (Mar 9, 2016):

it is supposed to

bool ESP8266WiFiSTAClass::setAutoReconnect(bool autoReconnect) {
    return wifi_station_set_reconnect_policy(autoReconnect);
}

Not sure what the sdk default is...
try a WiFi.getAutoConnect()

<!-- gh-comment-id:194530620 --> @tablatronix commented on GitHub (Mar 9, 2016): it is supposed to ``` bool ESP8266WiFiSTAClass::setAutoReconnect(bool autoReconnect) { return wifi_station_set_reconnect_policy(autoReconnect); } ``` Not sure what the sdk default is... try a `WiFi.getAutoConnect()`
Author
Owner

@hemalchevli commented on GitHub (Apr 5, 2016):

I'm facing a similar problem of not reconnecting after power cycle. I'm using on demand configuration with 18 custom parameters(changedWIFI_MANAGER_MAX_PARAMS in header).
As a work around I'll try adding ssid and password as custom parameters and use the following in loop to reconnect
if(WiFi.status() != WL_CONNECTED){ WiFi.begin(ssid,password); }

<!-- gh-comment-id:205629074 --> @hemalchevli commented on GitHub (Apr 5, 2016): I'm facing a similar problem of not reconnecting after power cycle. I'm using on demand configuration with 18 custom parameters(changed`WIFI_MANAGER_MAX_PARAMS` in header). As a work around I'll try adding ssid and password as custom parameters and use the following in loop to reconnect `if(WiFi.status() != WL_CONNECTED){ WiFi.begin(ssid,password); }`
Author
Owner

@tzapu commented on GitHub (Apr 5, 2016):

hi, are you using the latest github version or a release?

<!-- gh-comment-id:205657018 --> @tzapu commented on GitHub (Apr 5, 2016): hi, are you using the latest github version or a release?
Author
Owner

@hemalchevli commented on GitHub (Apr 5, 2016):

I downloaded it via PlatformIO library manager, so it must be a release as far as I know.

<!-- gh-comment-id:205703789 --> @hemalchevli commented on GitHub (Apr 5, 2016): I downloaded it via PlatformIO library manager, so it must be a release as far as I know.
Author
Owner

@tzapu commented on GitHub (Apr 5, 2016):

hi,
jsut released a new version, 0.11 about 1 hour ago.

don t know if it appears on platform io yet. this one has some fixes for connection issues in it

cheers
alex

<!-- gh-comment-id:205706914 --> @tzapu commented on GitHub (Apr 5, 2016): hi, jsut released a new version, 0.11 about 1 hour ago. don t know if it appears on platform io yet. this one has some fixes for connection issues in it cheers alex
Author
Owner

@hemalchevli commented on GitHub (Apr 5, 2016):

I'll manually download it and copy to it to lib folder and check if the issue still persists.
thanks

Great lib by the way!
Cheers!

<!-- gh-comment-id:205707934 --> @hemalchevli commented on GitHub (Apr 5, 2016): I'll manually download it and copy to it to lib folder and check if the issue still persists. thanks Great lib by the way! Cheers!
Author
Owner

@tzapu commented on GitHub (Apr 5, 2016):

thank you very much

<!-- gh-comment-id:205709625 --> @tzapu commented on GitHub (Apr 5, 2016): thank you very much
Author
Owner

@hemalchevli commented on GitHub (Apr 5, 2016):

Okay so I did 10 power cycles, and esp connects every time, and also it does not lose connection with time. Looks like problem solved.
Thanks for the support @tzapu

<!-- gh-comment-id:205719768 --> @hemalchevli commented on GitHub (Apr 5, 2016): Okay so I did 10 power cycles, and esp connects every time, and also it does not lose connection with time. Looks like problem solved. Thanks for the support @tzapu
Author
Owner

@tzapu commented on GitHub (Apr 5, 2016):

no problem, thanks for using it and the feedback
this is great news

<!-- gh-comment-id:205721295 --> @tzapu commented on GitHub (Apr 5, 2016): no problem, thanks for using it and the feedback this is great news
Author
Owner

@Gregauriz commented on GitHub (Sep 20, 2018):

I'm still having a similar issue (not sure it's the right place to put it), It reconnect fine if during the setup it is was able to connect to a wifi (or setup vi the portal have been done). But if during setup nothing is done on the portal and there is no wifi available, there is no way to do a reconnection ? I try to do an autoconnect in the loop but it wasn't able to get a connection because the wifi is in WL_IDLE_STATUS...

So here an example of code :
void setup(){ WiFiManager wifiManager; wifiManager.setConfigPortalTimeout(120); wifiManager.setTimeout(20); wifiManager.autoConnect('XXXXXXXX'); } void loop() { if (WiFi.status() != WL_CONNECTED) { Serial.println("Trying to connected to wifi"); WiFiManager wifiManager; wifiManager.setConfigPortalTimeout(120); wifiManager.setTimeout(20); wifiManager.autoConnect('XXXXXXXX'); } else { // do stuff } }

This code give this in the serial :
tarting WifiManager
*WM:
*WM: AutoConnect
*WM: Connecting as wifi client...
*WM: Using last saved values, should be faster
*WM: Connection result:
*WM: 1
*WM:
*WM: Configuring access point...
*WM: XXXXXXXX
*WM: AP IP address:
*WM: 192.168.4.1
*WM: HTTP server started
*WM:
*WM: AutoConnect
*WM: Connecting as wifi client...
*WM: Using last saved values, should be faster
*WM: Connection result:
*WM: 0
*WM:
*WM: Configuring access point...
*WM: XXXXXXXX
*WM: AP IP address:
*WM: 192.168.4.1
*WM: HTTP server started

I hope to clear enouth ! Feel free to correct me if I'm wrong... I tried to add a WiFi.begin(); but didn't change anything, it's stuck in idle mode...
And I don't want to reset the all ESP....

<!-- gh-comment-id:423221167 --> @Gregauriz commented on GitHub (Sep 20, 2018): I'm still having a similar issue (not sure it's the right place to put it), It reconnect fine if during the setup it is was able to connect to a wifi (or setup vi the portal have been done). But if during setup nothing is done on the portal and there is no wifi available, there is no way to do a reconnection ? I try to do an autoconnect in the loop but it wasn't able to get a connection because the wifi is in WL_IDLE_STATUS... So here an example of code : ` void setup(){ WiFiManager wifiManager; wifiManager.setConfigPortalTimeout(120); wifiManager.setTimeout(20); wifiManager.autoConnect('XXXXXXXX'); } void loop() { if (WiFi.status() != WL_CONNECTED) { Serial.println("Trying to connected to wifi"); WiFiManager wifiManager; wifiManager.setConfigPortalTimeout(120); wifiManager.setTimeout(20); wifiManager.autoConnect('XXXXXXXX'); } else { // do stuff } } ` This code give this in the serial : tarting WifiManager *WM: *WM: AutoConnect *WM: Connecting as wifi client... *WM: Using last saved values, should be faster *WM: Connection result: *WM: 1 *WM: *WM: Configuring access point... *WM: XXXXXXXX *WM: AP IP address: *WM: 192.168.4.1 *WM: HTTP server started *WM: *WM: AutoConnect *WM: Connecting as wifi client... *WM: Using last saved values, should be faster *WM: Connection result: *WM: **0** *WM: *WM: Configuring access point... *WM: XXXXXXXX *WM: AP IP address: *WM: 192.168.4.1 *WM: HTTP server started I hope to clear enouth ! Feel free to correct me if I'm wrong... I tried to add a `WiFi.begin();` but didn't change anything, it's stuck in idle mode... And I don't want to reset the all ESP....
Author
Owner

@tablatronix commented on GitHub (Sep 20, 2018):

new issue please

<!-- gh-comment-id:423259218 --> @tablatronix commented on GitHub (Sep 20, 2018): new issue please
Author
Owner

@Gregauriz commented on GitHub (Sep 20, 2018):

thanks for your quick anwser here is the issue #738

<!-- gh-comment-id:423302413 --> @Gregauriz commented on GitHub (Sep 20, 2018): thanks for your quick anwser here is the issue [#738](https://github.com/tzapu/WiFiManager/issues/738)
Author
Owner

@fzoccara commented on GitHub (Sep 25, 2018):

I'm still having a similar issue (not sure it's the right place to put it), It reconnect fine if during the setup it is was able to connect to a wifi (or setup vi the portal have been done). But if during setup nothing is done on the portal and there is no wifi available, there is no way to do a reconnection ? I try to do an autoconnect in the loop but it wasn't able to get a connection because the wifi is in WL_IDLE_STATUS...

So here an example of code :
void setup(){ WiFiManager wifiManager; wifiManager.setConfigPortalTimeout(120); wifiManager.setTimeout(20); wifiManager.autoConnect('XXXXXXXX'); } void loop() { if (WiFi.status() != WL_CONNECTED) { Serial.println("Trying to connected to wifi"); WiFiManager wifiManager; wifiManager.setConfigPortalTimeout(120); wifiManager.setTimeout(20); wifiManager.autoConnect('XXXXXXXX'); } else { // do stuff } }

This code give this in the serial :
tarting WifiManager
*WM:
*WM: AutoConnect
*WM: Connecting as wifi client...
*WM: Using last saved values, should be faster
*WM: Connection result:
*WM: 1
*WM:
*WM: Configuring access point...
*WM: XXXXXXXX
*WM: AP IP address:
*WM: 192.168.4.1
*WM: HTTP server started
*WM:
*WM: AutoConnect
*WM: Connecting as wifi client...
*WM: Using last saved values, should be faster
*WM: Connection result:
*WM: 0
*WM:
*WM: Configuring access point...
*WM: XXXXXXXX
*WM: AP IP address:
*WM: 192.168.4.1
*WM: HTTP server started

I hope to clear enouth ! Feel free to correct me if I'm wrong... I tried to add a WiFi.begin(); but didn't change anything, it's stuck in idle mode...
And I don't want to reset the all ESP....

Hi @Gregauriz ! thank you very much! this help me a lot..
just one note: "setTimeout" seems to be an alias for "setConfigPortalTimeout" function.

Best.
Francesco.

<!-- gh-comment-id:424464916 --> @fzoccara commented on GitHub (Sep 25, 2018): > I'm still having a similar issue (not sure it's the right place to put it), It reconnect fine if during the setup it is was able to connect to a wifi (or setup vi the portal have been done). But if during setup nothing is done on the portal and there is no wifi available, there is no way to do a reconnection ? I try to do an autoconnect in the loop but it wasn't able to get a connection because the wifi is in WL_IDLE_STATUS... > > So here an example of code : > `void setup(){ WiFiManager wifiManager; wifiManager.setConfigPortalTimeout(120); wifiManager.setTimeout(20); wifiManager.autoConnect('XXXXXXXX'); } void loop() { if (WiFi.status() != WL_CONNECTED) { Serial.println("Trying to connected to wifi"); WiFiManager wifiManager; wifiManager.setConfigPortalTimeout(120); wifiManager.setTimeout(20); wifiManager.autoConnect('XXXXXXXX'); } else { // do stuff } }` > > This code give this in the serial : > tarting WifiManager > *WM: > *WM: AutoConnect > *WM: Connecting as wifi client... > *WM: Using last saved values, should be faster > *WM: Connection result: > *WM: 1 > *WM: > *WM: Configuring access point... > *WM: XXXXXXXX > *WM: AP IP address: > *WM: 192.168.4.1 > *WM: HTTP server started > *WM: > *WM: AutoConnect > *WM: Connecting as wifi client... > *WM: Using last saved values, should be faster > *WM: Connection result: > *WM: **0** > *WM: > *WM: Configuring access point... > *WM: XXXXXXXX > *WM: AP IP address: > *WM: 192.168.4.1 > *WM: HTTP server started > > I hope to clear enouth ! Feel free to correct me if I'm wrong... I tried to add a `WiFi.begin();` but didn't change anything, it's stuck in idle mode... > And I don't want to reset the all ESP.... Hi @Gregauriz ! thank you very much! this help me a lot.. just one note: "setTimeout" seems to be an alias for "setConfigPortalTimeout" function. Best. Francesco.
Author
Owner

@tablatronix commented on GitHub (Sep 25, 2018):

Its not an alias, its deprecated

<!-- gh-comment-id:424539189 --> @tablatronix commented on GitHub (Sep 25, 2018): Its not an alias, its deprecated
Author
Owner

@rodrigok1 commented on GitHub (Jun 8, 2020):

dear All,
Is there any way to find the SSID and password saved by WIFImanger lib?
If so, it will be simple to reconnect in case of a Wi-Fi fall during the program execution.
Can anyone help me or US?
I appreciate!

<!-- gh-comment-id:640584695 --> @rodrigok1 commented on GitHub (Jun 8, 2020): dear All, Is there any way to find the SSID and password saved by WIFImanger lib? If so, it will be simple to reconnect in case of a Wi-Fi fall during the program execution. Can anyone help me or US? I appreciate!
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/WiFiManager#92
No description provided.