Skip to content
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

question where are credintials stored #1699

Open
ear9mrn opened this issue Jan 8, 2024 · 1 comment
Open

question where are credintials stored #1699

ear9mrn opened this issue Jan 8, 2024 · 1 comment

Comments

@ear9mrn
Copy link

ear9mrn commented Jan 8, 2024

Can anyone tell me where/how the credentials (ssid, password) are stored for esp32?

A little googling suggests this is done by wifi library but it is not clear. I could not find anything in this code to suggest where they come from once stored.

I tried the following (using preferences library) but came up blank. Either this is not the correct method of the variable names are not correct. Any guidance would be helpful as I would like to use the same or similar method for some other parameters for a project.

`
#include<Preferences.h>
Preferences preferences;

String ssid;
String password;

void setup {

preferences.begin("credentials", false);

ssid = preferences.getString("ssid", "");
password = preferences.getString("password", "");

Serial.println(ssid);
Serial.println(password);

}
`

Thanks,

Pete.

@tablatronix
Copy link
Collaborator

tablatronix commented Jan 8, 2024

They are stored in NVS by ESP32, you can read them using the WM funcs

    // check if the module has a saved ap to connect to
    bool          getWiFiIsSaved();

    // helper to get saved password, if persistent get stored, else get current if connected    
    String        getWiFiPass(bool persistent = true);

    // helper to get saved ssid, if persistent get stored, else get current if connected
    String        getWiFiSSID(bool persistent = true);

But they are only available when wifi is init on the esp32, so you have to start wifi first.
set .mode(STA) etc.

I have open issues researching how to get them without turning wifi on.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants