add wifi reconnection logic

This commit is contained in:
Hunter 2024-10-08 09:58:46 -04:00
parent 79e52ee404
commit b90df4923d
1 changed files with 9 additions and 0 deletions

View File

@ -51,6 +51,15 @@ void setup() {
} }
void loop() { void loop() {
unsigned int wifiRetryCount = 0;
if (WiFi.status != WL_CONNECTED){
WiFi.reconnect();
while (WiFi.status != WL_CONNECTED){
if (wifiRetryCount++ > 5) return;
delay(1000);
}
}
if (!client.connected()) { if (!client.connected()) {
reconnect(); reconnect();
} }