I am using an ESP 12e on a MQTT system. When it first starts up I have wifiManager open an access point so the user can put in the wifi, password, MQTT name and Key. This all works fine.
However every once in a while something happens (like an electrical interrupt) and the ESP 12e starts up and looks for the wifi to connect to but because of the power outage the wifi isn’t up and running yet so it starts the access point. If this occurs while I am away the ESP 12e just sits there in access mode waiting for someone to enter the data until I return home and restart the ESP 12e manually while the wifi is broadcasting.
I am trying to program the ESP 12e to restart after a certain amount of time (6 minutes) when the wifi has had time to start broadcasting again.
I âm using Arduino IDE.
I have tried this.
previousMillis2 = millis();
if (WiFi.status() == WL_DISCONNECTED) {
if (millis()-previousMillis2 >= 360000){
Serial.print(millis());
Serial.println("Reset..");
ESP.restart();
}
wifiManager.autoConnect("ACCESSPOINT");
}
I have also tried this
previousMillis2 = millis();
if (WiFi.status() == WL_DISCONNECTED) {
wifiManager.autoConnect("FloWT2");
delay(180000);
if (millis()-previousMillis2 >= 179999){
Serial.print(millis());
Serial.println("Reset..");
ESP.restart();
}
}
Is this the wrong way to go about this or have I just done something wrong with my code.
If someone could help me with this I would really appreciate it. Thanks in advance.