Hello Blynk Community!
My question is - how I can avoid continuous Blynk connection when my router is offline. My NodeMCU module connects to WiFi, but sometimes my routers hasn’t got internet connection. What I have to do?
Thanks a lot!
Here is a sample code:
void setup() {
Serial.begin(115200);
WiFi.begin(ssid, pass);
int wifi_ctr = 0;
while (WiFi.status() != WL_CONNECTED && attemps > 0) {
delay(500);
Serial.print(".");
Serial.println(attemps);
attemps--;
}
if (attemps <= 0) {
Serial.println(F("Ops! Connection timeout :( Going sleep..."));
ESP.deepSleep(10e6); // 10s
}
Blynk.begin(auth, ssid, pass, ipAddress, port);
}