ESP8266 running online and offline, also reconnect when wifi or server connection fails

This sketch is based on an example posted by Gunner with some modifications added in place to make it able to reconnect after Wifi or Server connection failures.
It is able to check if it is a Wifi or a server connection issue and recover it when it is possible
The MCU runs the task every second - It turns the builtin led on and off (allways) and post the millis/1000 to blynk server (only when a connection is available).

I hope someone finds it useful.Feel free to contribute!


Thank you for posting this code. I am trying to make it work, however my problem is I am struggling with the libraries.

Generally my program connects fine with my wireless but at times loses connection therefore I want to implement an automatic reconnect.

My current program includes the following libraries.
#include <ESP8266_Lib.h>
#include <BlynkSimpleShieldEsp8266.h>

I was convinced I had the Arduion ESP8266 core installed, but I the compiler is telling me it cant find the libraries needed for this sketch:
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>

I downloaded the latest Arduino ESP core zip from Github and tried installing it via the Arduino “add zip files” to libraries.

Could it be that I am getting some kind of conflict?

This library is used when you use an ESP-01 or similar as a Wi-Fi modem for an Arduino board such as an Uno or Mega.
In that situation, the ESP core isn’t used, as it’s the Arduino that you’re uploading the code to, not the ESP-01

The example that you’re following is for a stand alone ESP8266. This could be an ESP-01 or more likely people tend to use a NodeMCU or Wemos D1 Mini.

If you’re using a stand alone ESP8266 of some kind then you’re using the wrong library.
If you’re using an Arduino/ESP-01 combination then the example code isn’t meant for your hardware.


1 Like

Pete - thank you for you reply, this info was super helpful for me!


Hello Good Day, I am new to Arduino World. I am looking for the same code snippet for the ESP-01 Module :frowning: I can’t find a way to this on my own. Please help me. Thank you

@Meteor_Ordona I’d suggest that you start a new " need help with my project " topic and provide as much details as possible.

1 Like

The sketch linked to in the original post should work on an ESP-01, the only issue you might find is that the built in LED is on the Tx pin (GPIO1 on the ESP-01 and GPIO2 on the ESP-01S) will need to be correctly defined in the Arduino IDE for it to perform as expected.


1 Like