[GH-ISSUE #1455] AP Password gone when using wm.resetSettings #1244

Open
opened 2026-02-28 01:29:12 +03:00 by kerem · 1 comment
Owner

Originally created by @200090 on GitHub (Jul 18, 2022).
Original GitHub issue: https://github.com/tzapu/WiFiManager/issues/1455

WiFimanager Branch/Release: Master

Esp8266/Esp32:

Hardware: ESP32

Description

I'm trying to reset the WiFi Credentials with the hardware button (BOOT) GPIO0. However, after the wm.resetSettings is executed my AP password is gone when the ESP restarts.

Settings in IDE

Module: ESP32 Dev Module

Additional libraries:

Sketch

#include <WiFiManager.h>
WiFiManager wm;

static const int wifiRstBtn = 0;
int btnStatePrev = HIGH;
unsigned long longPressDuration = 2000;
unsigned long btnPressMillis;
bool longPress = false;
const int intervalButton = 50;
unsigned long btnMillisPrev;
unsigned long btnPressDuration;
unsigned long currentMillis;

void setup() {
  Serial.begin(115200);
  pinMode(wifiRstBtn, INPUT);
  WiFi.mode(WIFI_STA);
  wm.setConfigPortalBlocking(false);
  wm.setConfigPortalTimeout(180);
  if(wm.autoConnect("WiFiConfig","password")){
     Serial.println("Connected");
  }
  else{
     Serial.println("Portal Running");
  }
}

void loop() {
   wm.process();
   wifiRst();
}
void wifiRst() {
    if (currentMillis - btnMillisPrev > intervalButton) {
      int btnState = digitalRead(wifiRstBtn);
    if (btnState == LOW && btnStatePrev == HIGH && !longPress) {
      btnPressMillis = currentMillis;
      btnStatePrev = LOW;
    }
    btnPressDuration = currentMillis - btnPressMillis;

    if (btnState == LOW && !longPress && btnPressDuration >= longPressDuration) {
      longPress = true;
      wm.resetSettings();
      ESP.restart();
    }
    if (btnState == HIGH && btnStatePrev == LOW) {
      btnStatePrev = HIGH;
      longPress = false;
    }

    btnMillisPrev = currentMillis;

    }
}
Originally created by @200090 on GitHub (Jul 18, 2022). Original GitHub issue: https://github.com/tzapu/WiFiManager/issues/1455 WiFimanager Branch/Release: Master Esp8266/Esp32: Hardware: ESP32 ### Description I'm trying to reset the WiFi Credentials with the hardware button (BOOT) GPIO0. However, after the wm.resetSettings is executed my AP password is gone when the ESP restarts. ### Settings in IDE Module: ESP32 Dev Module Additional libraries: ### Sketch ```cpp #include <WiFiManager.h> WiFiManager wm; static const int wifiRstBtn = 0; int btnStatePrev = HIGH; unsigned long longPressDuration = 2000; unsigned long btnPressMillis; bool longPress = false; const int intervalButton = 50; unsigned long btnMillisPrev; unsigned long btnPressDuration; unsigned long currentMillis; void setup() { Serial.begin(115200); pinMode(wifiRstBtn, INPUT); WiFi.mode(WIFI_STA); wm.setConfigPortalBlocking(false); wm.setConfigPortalTimeout(180); if(wm.autoConnect("WiFiConfig","password")){ Serial.println("Connected"); } else{ Serial.println("Portal Running"); } } void loop() { wm.process(); wifiRst(); } void wifiRst() { if (currentMillis - btnMillisPrev > intervalButton) { int btnState = digitalRead(wifiRstBtn); if (btnState == LOW && btnStatePrev == HIGH && !longPress) { btnPressMillis = currentMillis; btnStatePrev = LOW; } btnPressDuration = currentMillis - btnPressMillis; if (btnState == LOW && !longPress && btnPressDuration >= longPressDuration) { longPress = true; wm.resetSettings(); ESP.restart(); } if (btnState == HIGH && btnStatePrev == LOW) { btnStatePrev = HIGH; longPress = false; } btnMillisPrev = currentMillis; } } ```
Author
Owner

@tablatronix commented on GitHub (Jul 18, 2022):

Not understanding what the problem is here.

<!-- gh-comment-id:1187598945 --> @tablatronix commented on GitHub (Jul 18, 2022): Not understanding what the problem is here.
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#1244
No description provided.