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;
}
}
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