Hello. We try not to reopen old topics here… things keep changing and even old issues may have new solutions.
I have moved your issue into a new topic.
Blynk.begin()
is a blocking command… no connection, no further action. Period.
Normally that was the only option for an Arduino & shield combo, but now Blynk.config()
seems to work with such combos and is non-blocking and will allow the rest of the sketch to keep running without Blynk connection… But you do need to figure out the Wifi connection/reconnection routines for your needs.
I use this startup and reconnection routine with my Mega/ESP-01 combo… seems to work OK.
In pre setup
#include <ESP8266_Lib.h> // ESP-01 Link
#include <BlynkSimpleShieldEsp8266.h> // ESP-01 Link
In my void setup()
wifi.setDHCP(1, 1, 1); //Enable dhcp in station mode and save in flash of esp8266
Blynk.config(wifi, auth, server, port);
if (Blynk.connectWiFi(ssid, pass)) {
Blynk.connect();
}
In void loop()
void loop() {
timer.run();
if (Blynk.connected()) { // If connected run as normal
Blynk.run();
} else if (ReCnctFlag == 0) { // If NOT connected and not already tring 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);
wifi.setDHCP(1, 1, 1); //Enable dhcp in station mode and save in flash of esp8266
Blynk.config(wifi, auth, server, port);
Blynk.connect(); // Try to reconnect to the server
if (Blynk.connectWiFi(ssid, pass)) {
Blynk.connect();
}
}); // END Timer Function
}
}
You will have to look through all that and figure out the bits you want/need.