WiFiManager: resetSettings(); not working

Basic Infos

Hardware

WiFimanager Branch/Release: Master

Esp8266/Esp32:

Hardware: ESP-12E

Core Version: 2.4.0, staging

Description

Problem description

Settings in IDE

Module: NodeMcu 1,0 (esp-12E module) Additional libraries:

Sketch

#BEGIN
       WiFiManager wifiManager;
        wifiManager.resetSettings();
        delay(4000);
        ESP.reset();
#END

Debug Messages

The resetSettings(); doesn’t bring up the AP. I need to cause the AP to start after a successful connect. This did work on platform 2.7.4, I’m on 3.0.2


About this issue

  • Original URL
  • State: open
  • Created 5 years ago
  • Reactions: 1
  • Comments: 45

Most upvoted comments

    wifiManager.resetSettings();
    ESP.eraseConfig(); 
    delay(2000);
    ESP.reset(); 

This works for me

Hi -

Sorry to revive this old issue…

I ran into the same problem as he original poster, today - trying to use resetSettings() to clear WiFi credentials on a ESP8266 (Wemos D1 mini). I use the library tzapu/WiFiManager@^0.16.0.

When using resetSettings() right before autoConnect() it correctly starts the 192.168.4.1 website etc… but when using resetSettings() to only clear the credentials, and then immediately restart the board without calling resetSettings(), the previous WiFi credentials are loaded and used by autoConnect(). It looks like the resetSettings() didn’t save/clear. Even calling WiFi.disconnect(true) didn’t clear the credentials.

I suspected, maybe it tried to clear the EEPROM information, but was now allowed/ignored. So I tried:

  WiFi.mode(WIFI_STA);
  WiFiManager wm;

  // Clearing WiFi credentials
  WiFi.persistent(true);
  wm.resetSettings();

This was a succes - setting WiFi.peristent(true) works for me!! Looks like the WiFi library defaults to WiFi.persistent(false) - so the resetSettings() never persists the clearing. - OR my cheap ESP8266 board does not follow standards … or …

Anyway - I hope my tip can help somebody else in the same situation.

@tablatronix - Would it be risky to add a WiFi.persistent(true) in the resetSettings() code?

Hi @tablatronix, I have a similar issue, so as you said the code is working fine with this line in the setup void:

WiFi.mode(WIFI_STA);

But it doesn’t work when I move it into a IF statment:

if (digitalRead(TRIGGER_PIN) == LOW){      
        wifiManager.resetSettings();
        delay(500);
        ESP.restart();
        delay(1000);
    }

I’m trying to get the memory erase when I press a button on sturtup. Any suggestion?

My hardware is a ESP8266 Wemos D1 mini Pro