Reconectar blynk

Bueno, lo intente en mi ESP8266 y resulta que vuelve a reconectarse normalmente.
Luego lo intente en mi ESP32 y este no se reconecta automaticamente, tengo que reiniciarlo para que vuelva a conectarse a internet. en la comunicacion serial dice esto:

[117147] Connecting to blynk-cloud.com:80
[122148] Connecting to blynk-cloud.com:80
[127149] Connecting to blynk-cloud.com:80
[132150] Connecting to blynk-cloud.com:80
[137151] Connecting to blynk-cloud.com:80
[142152] Connecting to blynk-cloud.com:80
[147153] Connecting to blynk-cloud.com:80
[152154] Connecting to blynk-cloud.com:80
[157155] Connecting to blynk-cloud.com:80
[162156] Connecting to blynk-cloud.com:80

Permanece diciendolo hasta que lo reinicias, asi que supongo que debe ser un problema en la placa.

Blynk.begin(auth, ssid, pass); is a blocking function, and may not allow your program to run if there is a problem with internet during start-up (and possibly after). It is better to use the Blynk.config(auth); to establish connection. This allows your program to continue to operate if the wifi sgnal is lost.

Take a look at this example, I have used it in many of my projects with great success. Although, I do not run any esp32’s. All of my projects are based off of the esp8266.

Hope this helps.

Claro, eso fue lo que hice para solucionarlo, como mostré en el primer código que subí, yo lo que decia es que con mi esp8266 funciona perfecto, se reconecta cuando vuelve el internet, pero en mi ESP32 eso no sucede, se queda intentando reconectar.

If that fixes it, then I would go with that approach. It probably has something to do with the BLYNK library, as I believe it was developed prior to the ESP32. I do not think that there will ever really be a fix from the BLYNK staff for the current BLYNK 1.0 version. It may be fixed in the BLYNK 2.0 version, but don’t hold your breath for BLYNK 2.0 as the developers have been silent about its release date for a very long time.

1 Like

Hola Luciano. Te consulto. Si te funcionó el código que pusiste. Yo lo copie en el mio pero no tuve caso. Yo mis datos los ingreso mediante el wifimanager. Me pasa lo mismo que a vos que si se cae el wifi o se desconecta por cualquier motivo el módem la única solución es ir y tocar el reset de la placa. En mi caso un wemos d1 mini. Que me recomendás?

Hola @Gonzalo_Robles disculpa la demora hacía demasiado que no entraba al foro de blynk, mirá yo al final opte por usar la librería Blynk_WM y logré solucionar los problemas, está misma maneja la reconexión automática del ESP32 y quedó funcionando perfecto. Saludos

could you upload an example with Blynk_WM.Thank you

Hi, could you solve your problem … I have the same mess and I can’t solve it … the strange thing is that it happens to me with some routers

I think you shoud copy you connect code like in setup() in your “void reconnectBlynk()”.
Your “void reconnectBlynk()” can’t work if wifi connection is lost but only in case of just a blynk connexion lost. I had the same issue and i wrote this function which is called like your “void reconnectBlynk()”… See below for example !
The delay control with break is used to avoid being blocked in the connection phase if it is not possible to connect.

void connectWifi() 
{
  unsigned long blynkTimeout = 4000;    // Temps donné pour la connexion
  unsigned long blynkStart = millis();

  Serial.println("Connecting Wifi/Blynk");

  while (!Blynk.connected())
  {
    WiFi.begin(ssid, pass);
    Blynk.config(auth);
    Blynk.connect(); 

    if (millis()>blynkStart+blynkTimeout) break;
  }

  Connected2Blynk = Blynk.connected();
}