Add explicit wifi reconnection settings

This commit is contained in:
Tanner Collin 2024-07-01 13:10:10 -06:00
parent 8b22554c94
commit a6befca199

View File

@ -114,6 +114,8 @@ void setup() {
delay(500); delay(500);
Serial.print("."); Serial.print(".");
} }
WiFi.setAutoReconnect(true);
WiFi.persistent(true);
Serial.println(""); Serial.println("");
Serial.println("[WIFI] Connected to the network"); Serial.println("[WIFI] Connected to the network");
@ -155,6 +157,7 @@ void loop() {
if (WiFi.status() != WL_CONNECTED) { if (WiFi.status() != WL_CONNECTED) {
Serial.println("[WIFI] Lost connection. Reconnecting..."); Serial.println("[WIFI] Lost connection. Reconnecting...");
WiFi.disconnect();
WiFi.begin(SECRET_SSID, SECRET_PASS); WiFi.begin(SECRET_SSID, SECRET_PASS);
return; return;
} else if (!mqttClient.connected()) { } else if (!mqttClient.connected()) {