Blynk не переподключается при потере связи с роутером

Проблема в том, что стандартный скетч для ESP когда пропадает интернет на роутере после его поднятия не переподключается к роутеру. Скажите куда копнуть то? что то может подключить или прописать еще ? У меня в квартире 8 устройств все отваливаются электричество отключат например в доме следовательно интернет появляется не сразу. Что посоветуете?
Еще вопрос функция Blynk.begin получается если нет коннекта вешайте скетч? а можно как то что то прописать что если не может подключится, то основной скетч бы все равно работал бы. Может есть какое то условия там? Заранее спасибо

See this example.

То есть достаточно добавить мне в код условие по подключению вот это:
if (Blynk.connected()) { // If connected run as normal
Blynk.run();
} else if (ReCnctFlag == 0) { // If NOT connected and not already trying to reconnect, set timer to try to reconnect in 30 seconds
ReCnctFlag = 1; // Set reconnection Flag
Serial.println(“Starting reconnection timer in 30 seconds…”);
timer.setTimeout(30000L, { // Lambda Reconnection Timer Function
ReCnctFlag = 0; // Reset reconnection Flag
ReCnctCount++; // Increment reconnection Counter
Serial.print(“Attempting reconnection #”);
Serial.println(ReCnctCount);
Blynk.connect(); // Try to reconnect to the server
});

Ничего не помогает. Даже такая конструкция не подключается повторно если отключают электричество во всем доме.

void FNC_BLYNK(){
     if (Blynk.connected()){Blynk.run();} 
        else
     if (!Blynk.connected()){
        if (WiFi.status()!=WL_CONNECTED){
           WiFi.begin(ssid, pass);
           count=0;
           while (WiFi.status()!=WL_CONNECTED){
           delay(500);
           count++; 
           if (count >= 10){break;}}} 
        else
        if (WiFi.status()==WL_CONNECTED){
           Blynk.config(auth); 
           Blynk.connect();
           while (!Blynk.connected()){
           delay(500);
           count++; 
           if (count >= 10){break;}}}
     }}

Есть какие то еще предположения почему все ESP не переподключаются к блинку при потере связи?

Mine all reconnect, and with much simpler code then your construction above.

It is all in the code and use of the Blynk.config() and other connection management commands. Examples have already been supplied, and there are many others in this forum.

Вообщем не понятно почему такое происходит но Blynk с вот таким кодом:

void FNC_BLYNK(){
         if (Blynk.connected()){Blynk.run();} 
            else
         if (!Blynk.connected()){
            if (WiFi.status()!=WL_CONNECTED){
               WiFi.begin(ssid, pass);
               count=0;
               while (WiFi.status()!=WL_CONNECTED){
               delay(500);
               count++; 
               if (count >= 10){break;}}} 
            else
            if (WiFi.status()==WL_CONNECTED){
               Blynk.config(auth); 
               Blynk.connect();
               while (!Blynk.connected()){
               delay(500);
               count++; 
               if (count >= 10){break;}}}
         }}

не всегда переподключается, если роутер перезапустить то подключается. В чем проблема то. не ясно. Бывает просто интернет пропадет и потом появится а блинк уже не перезапуститься. Куда копать то?

Скажите вот эта часть:

 Blynk.begin(auth, wifi, ssid, pass);
 Blynk.run();

Делает проверку по роутеру по Вай фай

Blynk is IoT, thus it simply must have a path to the server in order to work. That typical WiFi based path needs, in order…

  • A working router to the internet
  • A WiFi Access Point for the device
  • A WiFi connected MCU/device, running a proper sketch to either sit and wait until connected - (Blynk.begin() handles both WiFi and Server connection).
  • Or code to keep running other code until connected - (Blynk.config() only handles the Server connection).
  • As well as periodically check for connection and attempt reconnection as needed, using various connection management codes.

There are many different ways to accomplish all this, thus no single solution. All you can do is keep playing with the code, setup things like Static IP for the device (as that might be more stable reconnection then DHCP - This can usually be set in the router based on device MAC) and make other power backup options availed for things like the router.