(Make) ESP8266 automatically connect to the wifi and blynk servers (after disconnection)

After the router is powered off and restarted, how does eap8266 automatically connect to the wifi and blynk servers?

By reading the documentation and searching the forum for solutions :stuck_out_tongue_winking_eye:

1 Like

I have encountered the same problem. After the router is powered off and restarted, how does eap8266 automatically connect to the wifi and blynk servers? Please help me, thank you very much!

And since you already have a topic about this, please do not post the same question in other, older, topics. Thanks.

PS I moved your post back here.

Thanks a lot, I tried your code, but it doesn’t work. Is there a problem here? " timer.setTimeout(30000L, { . . .

Mainly used these codes:

    1. List item

#define BLYNK_PRINT Serial // This prints to Serial Monitor
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>

char auth[] = “xxxxxxxxxx”;
char ssid[] = “xxxxxxxxxx”;
char pass[] = “xxxxxxxxxx”;
//char server[] = “xxx.xxx.xxx.xxx”; // IP for Local Cloud Server
char server[] = “blynk-cloud.com”; // URL for Blynk Cloud Server
int port = 8080;

int ReCnctFlag; // Reconnection Flag
int ReCnctCount = 0; // Reconnection counter

BlynkTimer timer;

void setup() {
Serial.begin(115200);
pinMode(2, OUTPUT);

WiFi.begin(ssid, pass); // Non-blocking if no WiFi available
Blynk.config(auth, server, port);
Blynk.connect();

}

BLYNK_CONNECTED() {
Serial.println(“Cconnected”);
ReCnctCount = 0;
}

void loop() {
timer.run();

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
}); // END Timer Function
}
}

Why are you reposting the same code I gave you the link for?? And posting it UNformatted as well :roll_eyes:

Blynk%20-%20FTFC

1 Like

I tried your code, but it doesn’t work.

hello , I used their code, but if the channels are active during a disconnection of the network, they are still active, ideally disconnecting the channel from the relay with the network