[GH-ISSUE #245] WiFi credentials entered in captive portal are not remanent upon ESP reset #204

Closed
opened 2026-02-28 01:24:02 +03:00 by kerem · 6 comments
Owner

Originally created by @croisez on GitHub (Nov 18, 2016).
Original GitHub issue: https://github.com/tzapu/WiFiManager/issues/245

Hi,
I use WiFiManager 0.12.0, and esp8266 Arduino board add-on version 2.3.0.
I use a generic esp8266 module (an ESP12-F).

I want to use WiFiManager as fallback when the AP is OFF.
After having entered my SSID and pwd in the captive portal, the ESP switches in STA mode and succeeds in connecting to my AP.

But after that, whenever I reset the ESP (by forcing the RESET to zero), I expect the previously entered credentials to be used, but no. The ESP fails in STA mode and go back to captive portal.

Here is the traces I see on screen, on reboot after the RESET:

*WM:
*WM: AutoConnect
*WM: Connecting as wifi client...
*WM: Using last saved values, should be faster
*WM: Connection result:
*WM: 0
*WM: SET AP STA
...

What is the meaning of Connection result: 0??
Why?

Originally created by @croisez on GitHub (Nov 18, 2016). Original GitHub issue: https://github.com/tzapu/WiFiManager/issues/245 Hi, I use WiFiManager 0.12.0, and esp8266 Arduino board add-on version 2.3.0. I use a generic esp8266 module (an ESP12-F). I want to use WiFiManager as fallback when the AP is OFF. After having entered my SSID and pwd in the captive portal, the ESP switches in STA mode and succeeds in connecting to my AP. But after that, whenever I reset the ESP (by forcing the RESET to zero), I expect the previously entered credentials to be used, but no. The ESP fails in STA mode and go back to captive portal. Here is the traces I see on screen, on reboot after the RESET: *WM: *WM: AutoConnect *WM: Connecting as wifi client... *WM: Using last saved values, should be faster *WM: Connection result: *WM: 0 *WM: SET AP STA ... What is the meaning of Connection result: 0?? Why?
kerem closed this issue 2026-02-28 01:24:03 +03:00
Author
Owner

@croisez commented on GitHub (Nov 18, 2016):

I use now setConnectTimeout(45) to give more chance for a possible connection.
I also have WiFi.persistent(true) in my code.
We see here traces of WifiManager in ESP. I added print out of RSSI during the connection process.
When connection fails, RSSI always stay at value 31, while on success, I get negatives values.

_WM:
*WM: AutoConnect
*WM: Connecting as wifi client...
*WM: Using last saved values, should be faster
*WM: Waiting for connection result with time out
31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,_WM: Connection timed out
_WM: Connection result:
*WM: 0
*WM: SET AP STA
Entered AP config mode
192.168.4.1
*WM: Configuring access point...
*WM: AP IP address:
*WM: 192.168.4.1
*WM: HTTP server started
*WM: Handle root
*WM: Request redirected to captive portal
*WM: Handle root
*WM: Request redirected to captive portal
*WM: Handle root
*WM: Request redirected to captive portal
*WM: Handle root
*WM: Request redirected to captive portal
*WM: Handle root
*WM: Request redirected to captive portal
*WM: Handle root
*WM: Handle root
*WM: Handle root
*WM: WiFi save
*WM: Sent wifi save page
*WM: Connecting to new AP
*WM: Connecting as wifi client...
*WM: Waiting for connection result with time out
31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,-62,-62,-61,-61,-61,-61,-62,-63,-64,-64,-64,-64,-65,-65,-65,-65,-62,_WM: Connection result:
*WM: 3

<!-- gh-comment-id:261550864 --> @croisez commented on GitHub (Nov 18, 2016): I use now setConnectTimeout(45) to give more chance for a possible connection. I also have WiFi.persistent(true) in my code. We see here traces of WifiManager in ESP. I added print out of RSSI during the connection process. When connection fails, RSSI always stay at value 31, while on success, I get negatives values. _WM: *WM: AutoConnect *WM: Connecting as wifi client... *WM: Using last saved values, should be faster *WM: Waiting for connection result with time out 31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,_WM: Connection timed out _WM: Connection result: *WM: 0 *WM: SET AP STA Entered AP config mode 192.168.4.1 *WM: Configuring access point... *WM: AP IP address: *WM: 192.168.4.1 *WM: HTTP server started *WM: Handle root *WM: Request redirected to captive portal *WM: Handle root *WM: Request redirected to captive portal *WM: Handle root *WM: Request redirected to captive portal *WM: Handle root *WM: Request redirected to captive portal *WM: Handle root *WM: Request redirected to captive portal *WM: Handle root *WM: Handle root *WM: Handle root *WM: WiFi save *WM: Sent wifi save page *WM: Connecting to new AP *WM: Connecting as wifi client... *WM: Waiting for connection result with time out 31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,-62,-62,-61,-61,-61,-61,-62,-63,-64,-64,-64,-64,-65,-65,-65,-65,-62,_WM: Connection result: *WM: 3
Author
Owner

@kentaylor commented on GitHub (Nov 18, 2016):

WiFi.persistent(true)
is the default, only specify it in the unlikely event you want
WiFi.persistent(false)

@croisez asks

What is the meaning of Connection result: 0??

0 corresponds to WL_IDLE_STATUS . WL_IDLE_STATUS is an Arduino term and the ESP8266 doesn't exactly match the definition because the number of attempts does not expire in this case. It will wait forever until it sees the AP then attempt to connect.

I guess the 31 means no signal detected? The negative RSSI values are dBm which in your case show a low signal strength suggesting if you were closer to the router you would see different behaviour.

You provide a good example of why I argue that autoconnect is bad . There is discussion on future changes to autoconnect.

<!-- gh-comment-id:261672179 --> @kentaylor commented on GitHub (Nov 18, 2016): `WiFi.persistent(true) ` is the default, only specify it in the unlikely event you want `WiFi.persistent(false) ` @croisez asks > What is the meaning of Connection result: 0?? 0 corresponds to [WL_IDLE_STATUS](https://github.com/esp8266/Arduino/blob/4897e0006b5b0123a2fa31f67b14a3fff65ce561/libraries/ESP8266WiFi/src/include/wl_definitions.h) . WL_IDLE_STATUS is an [Arduino term](https://www.arduino.cc/en/Reference/WiFiStatus) and the ESP8266 doesn't exactly match the definition because the number of attempts does not expire in this case. It will wait forever until it sees the AP then attempt to connect. I guess the 31 means no signal detected? The negative RSSI values are dBm which in your case show a [low signal strength](http://www.metageek.com/training/resources/understanding-rssi.html) suggesting if you were closer to the router you would see different behaviour. You provide a good example of why I argue that [autoconnect is bad](https://github.com/kentaylor/WiFiManager#configuration-portal-initiation-not-automatic) . There is discussion on [future changes to autoconnect](https://github.com/tzapu/WiFiManager/pull/157#issuecomment-260169950).
Author
Owner

@SensorsIot commented on GitHub (Nov 19, 2016):

I have a very similar behavior. I use webupdate and print the ssid and psk before I autoconnect. Even when the ssid/psk are displayed right, it enters quite often in the AP mode. setConnectTimeout(60) did not change this behavior as it enters the AP mode quite quickly.

<!-- gh-comment-id:261721088 --> @SensorsIot commented on GitHub (Nov 19, 2016): I have a very similar behavior. I use webupdate and print the ssid and psk before I autoconnect. Even when the ssid/psk are displayed right, it enters quite often in the AP mode. setConnectTimeout(60) did not change this behavior as it enters the AP mode quite quickly.
Author
Owner

@croisez commented on GitHub (Nov 21, 2016):

Yes @SensorsIot, I also had the situation where the connection could not be done, while the printf of WiFi.SSID() and WiFi.psk() show good values.
But most of the time, printing WiFi.SSID() and WiFi.psk() show empty values.
I suppose that a call to WiFi.begin(ssid,psk) should do the saving-to-eeprom process, and that normally, upon reboot, a call to WiFi.begin() without args should use previously saved credentials, and get success with it.
Is it right?

<!-- gh-comment-id:261920475 --> @croisez commented on GitHub (Nov 21, 2016): Yes @SensorsIot, I also had the situation where the connection could not be done, while the printf of WiFi.SSID() and WiFi.psk() show good values. But most of the time, printing WiFi.SSID() and WiFi.psk() show empty values. I suppose that a call to WiFi.begin(ssid,psk) should do the saving-to-eeprom process, and that normally, upon reboot, a call to WiFi.begin() without args should use previously saved credentials, and get success with it. Is it right?
Author
Owner

@kentaylor commented on GitHub (Nov 21, 2016):

@croisez asks

Is it right?

Yes it is and calling WiFi.begin() after reboot is not useful.

When @croisez says

But most of the time, printing WiFi.SSID() and WiFi.psk() show empty values.

It sounds like the same issue as @hutch120.

<!-- gh-comment-id:261937694 --> @kentaylor commented on GitHub (Nov 21, 2016): @croisez asks > Is it right? Yes it is and calling WiFi.begin() after reboot is not useful. When @croisez says > But most of the time, printing WiFi.SSID() and WiFi.psk() show empty values. It sounds like the [same issue](https://github.com/tzapu/WiFiManager/issues/247) as @hutch120.
Author
Owner

@hutch120 commented on GitHub (Feb 12, 2017):

We are making some progress on this issue over at https://github.com/tzapu/WiFiManager/issues/247

<!-- gh-comment-id:279249910 --> @hutch120 commented on GitHub (Feb 12, 2017): We are making some progress on this issue over at https://github.com/tzapu/WiFiManager/issues/247
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#204
No description provided.