WiFiManager: wifiManager.getWiFiPass() returns an empty string

Using ESP32 version 1.0.4 on development branch.

After successful config, calling wifiManager.getWiFiPass(true) consistently returns an empty string.

POST SERIAL OUTPUT !

Code:

    preferences.putString(ATTR_WIFI_SSID, wifiManager.getWiFiSSID(true /*persistent*/));
    preferences.putString(ATTR_WIFI_PASS, wifiManager.getWiFiPass(true /*persistent*/));

    Serial.printf("wifiManager id: %s value: %s\n", ATTR_WIFI_SSID, preferences.getString(ATTR_WIFI_SSID).c_str());
    Serial.printf("**BUG** wifiManager id: %s value: %s\n", ATTR_WIFI_PASS, preferences.getString(ATTR_WIFI_PASS).c_str());
    Serial.printf("**BUG** wifiManager id: %s value: %s\n", ATTR_WIFI_PASS, wifiManager.getWiFiPass(true).c_str());
    Serial.printf("**BUG** wifiManager id: %s value: %s\n", ATTR_WIFI_PASS, wifiManager.getWiFiPass(false).c_str());

Output:

07:07:26.627 -> wifiManager id: wifi_ssid value: exampleSSID
07:07:26.627 -> **BUG** wifiManager id: wifi_pass value: 
07:07:26.627 -> **BUG** wifiManager id: wifi_pass value: 
07:07:26.627 -> **BUG** wifiManager id: wifi_pass value: 
07:07:26.627 -> id: wifi_pass value: SuperSecret valueLen: 40 label: ssid password (to be saved)
07:07:26.627 -> wifiManager parameters saved as preferences

if you have a stack dump decode it: N/A

----------------------------- Remove above -----------------------------

Basic Infos

Hardware

WiFimanager Branch/Release:

  • Master
  • Development

Esp8266/Esp32:

  • ESP8266
  • ESP32

Hardware: ESP-12e, esp01, esp25

ESP Core Version: 2.4.0, staging

  • ESP32 version 1.0.4

Description

wifiManager.getWiFiPass(true); OR wifiManager.getWiFiPass(false); are not returning the SSID password configured.

Settings in IDE

N/A

Additional libraries: N/A

Sketch

See:
https://github.com/flavio-fernandes/persistWifiSetting/commit/5ad667b862638722c2ee032105ed32c535aa1ce7

Debug Messages

N/A

About this issue

  • Original URL
  • State: open
  • Created 4 years ago
  • Comments: 19 (6 by maintainers)

Commits related to this issue

Most upvoted comments

@flavio-fernandes can you drop your code here i take a look and test

hello @gauix4 . My code is here:

https://github.com/flavio-fernandes/persistWifiSetting

You can look at branch issueWifiPass for how I reproduce it.

I am good dealing with this issue now, thanks to your help and @tablatronix .

Much appreciated.

@flavio-fernandes can you drop your code here i take a look and test

wifimanager restores the wifi mode that it was at in your sketch, Your mode is WIFI_OFF

if you call autoconnect we change this automatically, you are not calling it. You will need to set a mode in your sketch in setup, as esp32 does not automatically do this like esp8266. Also as in wm v.0 as it was buggy and clobbered your settings. development now works properly with persistent and will let you go back to your previous “current” wifi settings(non persistent)

Now there might still be a bug, have you tried restarting and then starting wifi or just starting wifi after saving ? and see if it was stored, if its persistent it should then work, unless there is a bug causing saves to not be persistent, but there is not that I know of

@flavio-fernandes @tablatronix

add to wifimanager.ccp

String WiFiManager::getSSID() {
  if (_ssid == "") {
    DEBUG_WM(F("Reading SSID"));
    _ssid = WiFi.SSID();
    DEBUG_WM(F("SSID: "));
    DEBUG_WM(_ssid);
  }
  return _ssid;
  }

  String WiFiManager::getPassword() {
  if (_pass == "") {
    DEBUG_WM(F("Reading Password"));
    _pass = WiFi.psk();
    DEBUG_WM("Password: " + _pass);
    DEBUG_WM(_pass);
  }
  return _pass;
  }


then in wifimanager.h add
    
String        getSSID();
String        getPassword();

arduino code 

WiFiManager wifiManager;
wifiManager.autoConnect("Hello Word");
Serial.println(getSSID());
Serial.println(getPassword());

here you have the return of ssid and password