[GH-ISSUE #97] Access SSID and Password after using On Demand Portal? #73

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

Originally created by @Humancell on GitHub (Feb 9, 2016).
Original GitHub issue: https://github.com/tzapu/WiFiManager/issues/97

Like everyone else says ... awesome library! It worked on the first try.

The way we are writing our app, we're doing our own WiFi connection handling, but want to use your captive portal/On Demand Portal for the configuration. I put a loop in the Setup() that give the user 5-6 seconds to press a button that tells us to call wifiManager.startConfigPortal("Our AP SSID") ... all of this works fine.

If the connection - after configuration - was successful, how can I retrieve the SSID and Password so that we can store it in our other configuration files?

After the user does the Captive Portal configuration, we want to store the configured credentials in our own config files, and then reset the board no matter what. When it reboots, and they do not press the button, our own WiFi connection code will then retrieve the credentials and initiate the WiFi connection.

We don't want to use autoConnect() since we do not want the library to go into Captive Portal mode ever ... unless the user pressed the button during that initial power up 5 seconds.

Does that make sense?

Originally created by @Humancell on GitHub (Feb 9, 2016). Original GitHub issue: https://github.com/tzapu/WiFiManager/issues/97 Like everyone else says ... awesome library! It worked on the first try. The way we are writing our app, we're doing our own WiFi connection handling, but want to use your captive portal/On Demand Portal for the configuration. I put a loop in the Setup() that give the user 5-6 seconds to press a button that tells us to call wifiManager.startConfigPortal("Our AP SSID") ... all of this works fine. If the connection - after configuration - was successful, how can I retrieve the SSID and Password so that we can store it in our other configuration files? After the user does the Captive Portal configuration, we want to store the configured credentials in our own config files, and then reset the board no matter what. When it reboots, and they do not press the button, our own WiFi connection code will then retrieve the credentials and initiate the WiFi connection. We don't want to use autoConnect() since we do not want the library to go into Captive Portal mode ever ... unless the user pressed the button during that initial power up 5 seconds. Does that make sense?
kerem closed this issue 2026-02-28 01:23:16 +03:00
Author
Owner

@Humancell commented on GitHub (Feb 9, 2016):

It does look like you once provided:

//String        getSSID();
//String        getPassword();

But then you commented these public methods out?

<!-- gh-comment-id:181679636 --> @Humancell commented on GitHub (Feb 9, 2016): It does look like you once provided: ``` //String getSSID(); //String getPassword(); ``` But then you commented these public methods out?
Author
Owner

@tzapu commented on GitHub (Feb 9, 2016):

yeah, all they did was call
WiFi.psk() and WiFi.SSID()

Btw, if i understand correctly, you don t need to save them, in your connection management code just put
WiFi.begin() with no params and it will use the last saved values.

I haven't tested, but you could try with

 //exit after config instead of connecting
  wifiManager.setBreakAfterConfig(true);

to exit and trigger a reset. so, semi pseudo code
if trigger pressed

wifiManager.setBreakAfterConfig(true);
wifiManager.startConfigPortal

when config portal returns

ESP.reset()

if no trigger button was pressed

WiFi.begin()

that should do all you mentioned

<!-- gh-comment-id:181730859 --> @tzapu commented on GitHub (Feb 9, 2016): yeah, all they did was call WiFi.psk() and WiFi.SSID() Btw, if i understand correctly, you don t need to save them, in your connection management code just put WiFi.begin() with no params and it will use the last saved values. I haven't tested, but you could try with ``` //exit after config instead of connecting wifiManager.setBreakAfterConfig(true); ``` to exit and trigger a reset. so, semi pseudo code if trigger pressed ``` wifiManager.setBreakAfterConfig(true); wifiManager.startConfigPortal ``` when config portal returns ``` ESP.reset() ``` if no trigger button was pressed ``` WiFi.begin() ``` that should do all you mentioned
Author
Owner

@Humancell commented on GitHub (Feb 10, 2016):

So close!! Thank you for the suggestions ... I'm running into two issues, and am curious if these might be bugs ...

First, I'm following your steps above, and it works ... BUT ... when I call the portal and then the reset I get the following output:

*WM: Handle root
*WM: Request redirected to captive portal
*WM: WiFi save
*WM: Sent wifi save page
*WM: Connecting to new AP
*WM: Connecting as wifi client...
*WM: Connection result: 
*WM: 3

 ets Jan  8 2013,rst cause:2, boot mode:(1,6)


 ets Jan  8 2013,rst cause:4, boot mode:(1,6)

wdt reset

... and then it just hangs forever.

THEN, if I manually reset the ESP, it DOES work ... and connects ok. But then at the end of my processing, I call ESP.reset() again ... and it's almost like the PSK is wiped out. When the ESP restarts I can print the WiFi.SSID() and it's still there ... but it will no longer connect until I re-configure it. I can't find a way to print the stored PSK ... it seems that WiFi.psk() no longer exists?

<!-- gh-comment-id:182194882 --> @Humancell commented on GitHub (Feb 10, 2016): So close!! Thank you for the suggestions ... I'm running into two issues, and am curious if these might be bugs ... First, I'm following your steps above, and it works ... BUT ... when I call the portal and then the reset I get the following output: ``` *WM: Handle root *WM: Request redirected to captive portal *WM: WiFi save *WM: Sent wifi save page *WM: Connecting to new AP *WM: Connecting as wifi client... *WM: Connection result: *WM: 3 ets Jan 8 2013,rst cause:2, boot mode:(1,6) ets Jan 8 2013,rst cause:4, boot mode:(1,6) wdt reset ``` ... and then it just hangs forever. THEN, if I manually reset the ESP, it DOES work ... and connects ok. But then at the end of my processing, I call ESP.reset() again ... and it's almost like the PSK is wiped out. When the ESP restarts I can print the WiFi.SSID() and it's still there ... but it will no longer connect until I re-configure it. I can't find a way to print the stored PSK ... it seems that WiFi.psk() no longer exists?
Author
Owner

@Humancell commented on GitHub (Feb 10, 2016):

I've been sitting here testing and testing ... and the wdt reset issue has simply gone away ... I'm not sure how.

I'm still looking at why the ESP will not reconnect to one of my access points on subsequent ESP.reset() calls ...

<!-- gh-comment-id:182199879 --> @Humancell commented on GitHub (Feb 10, 2016): I've been sitting here testing and testing ... and the wdt reset issue has simply gone away ... I'm not sure how. I'm still looking at why the ESP will not reconnect to one of my access points on subsequent ESP.reset() calls ...
Author
Owner

@tzapu commented on GitHub (Feb 23, 2016):

hi, WiFi.psk(); should really be there ...
could you have an older version of the esp8266 core for arduino?

<!-- gh-comment-id:187543477 --> @tzapu commented on GitHub (Feb 23, 2016): hi, WiFi.psk(); should really be there ... could you have an older version of the esp8266 core for arduino?
Author
Owner

@Humancell commented on GitHub (Mar 15, 2016):

Ok ... this issue is resolved.

  1. Yes. .. I did get the WiFi.psk() to work ... so that is good.
  2. I found out the reset issue finally ... it's related to another issue that is talked about. For some reason the first time the ESP resets after being flashed, it doesn't seem to reset correctly. It works on all subsequent resets!

This is working great!

Can't wait to get the ability to customize the CSS ... I don't want to modify the pages yet so I don't conflict with your changes. Where do I donate?

<!-- gh-comment-id:196678705 --> @Humancell commented on GitHub (Mar 15, 2016): Ok ... this issue is resolved. 1. Yes. .. I did get the WiFi.psk() to work ... so that is good. 2. I found out the reset issue finally ... it's related to another issue that is talked about. For some reason the first time the ESP resets after being flashed, it doesn't seem to reset correctly. It works on all subsequent resets! This is working great! Can't wait to get the ability to customize the CSS ... I don't want to modify the pages yet so I don't conflict with your changes. Where do I donate?
Author
Owner

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

hi, in the latest github version there is the ability of adding custom css, you can use that now

didn t think about donations, would people really do that?

<!-- gh-comment-id:196683539 --> @tzapu commented on GitHub (Mar 15, 2016): hi, in the latest github version there is the ability of adding custom css, you can use that now didn t think about donations, would people really do that?
Author
Owner

@Humancell commented on GitHub (Mar 15, 2016):

Oh excellent! I'll check out the CSS! I was also thinking of having my team see about adding a "spinny" busy icons when you touch a button ...

Donations? I know we would! You've done a great job on this library, and we're about to include it in a part of our open source release of our ESProto sensor prototyping platform. :-)

<!-- gh-comment-id:196910539 --> @Humancell commented on GitHub (Mar 15, 2016): Oh excellent! I'll check out the CSS! I was also thinking of having my team see about adding a "spinny" busy icons when you touch a button ... Donations? I know we would! You've done a great job on this library, and we're about to include it in a part of our open source release of our ESProto sensor prototyping platform. :-)
Author
Owner

@Humancell commented on GitHub (Mar 15, 2016):

BTW ... is there any doc/suggestions on adding custom .css?

<!-- gh-comment-id:196911766 --> @Humancell commented on GitHub (Mar 15, 2016): BTW ... is there any doc/suggestions on adding custom .css?
Author
Owner

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

hi, you can use it like this:

wifiManager.setCustomHeadElement("<style>html{filter: invert(100%); -webkit-filter: invert(100%);}</style>");

docs will be added when i release 0.11

i have never taken contributions so i have no idea how it s best done

i ve setup a patreon page, which is apparently the new "hip" way of doing this from what people say on the interwebs.

i have to stress that I will continue development on this, indifferent of contributions, and that if anyone decides to contribute, no amount is too small, everything goes the way of supporting my programming and new found electronics habit :P .

https://www.patreon.com/tzapulica

<!-- gh-comment-id:197196459 --> @tzapu commented on GitHub (Mar 16, 2016): hi, you can use it like this: ``` wifiManager.setCustomHeadElement("<style>html{filter: invert(100%); -webkit-filter: invert(100%);}</style>"); ``` docs will be added when i release 0.11 i have never taken contributions so i have no idea how it s best done i ve setup a patreon page, which is apparently the new "hip" way of doing this from what people say on the interwebs. i have to stress that I will continue development on this, indifferent of contributions, and that if anyone decides to contribute, no amount is too small, everything goes the way of supporting my programming and new found electronics habit :P . https://www.patreon.com/tzapulica
Author
Owner

@shakirhussain78652 commented on GitHub (Feb 3, 2021):

Hello,
I am new here with not much basic knowledge. I am trying to use this library Auto Connect Non Blocking wifi manager. I need the network Wifi SSID and the password entered by the user at the configuration portal to be stored in variable to be used in the REMOTE XY app.
Please provide me with the code.

// RemoteXY connection settings
#define REMOTEXY_WIFI_SSID "hello" // this is where i want to use the ssid
#define REMOTEXY_WIFI_PASSWORD "123456789" //and password
#define REMOTEXY_CLOUD_SERVER "cloud.remotexy.com"
#define REMOTEXY_CLOUD_PORT 6376

<!-- gh-comment-id:772194915 --> @shakirhussain78652 commented on GitHub (Feb 3, 2021): Hello, I am new here with not much basic knowledge. I am trying to use this library Auto Connect Non Blocking wifi manager. I need the network Wifi SSID and the password entered by the user at the configuration portal to be stored in variable to be used in the REMOTE XY app. Please provide me with the code. // RemoteXY connection settings #define REMOTEXY_WIFI_SSID "hello" // this is where i want to use the ssid #define REMOTEXY_WIFI_PASSWORD "123456789" //and password #define REMOTEXY_CLOUD_SERVER "cloud.remotexy.com" #define REMOTEXY_CLOUD_PORT 6376
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#73
No description provided.