BLYNK
HOME       📲 GETTING STARTED       📗 DOCS       ❓HELP CENTER       👉 SKETCH BUILDER

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!

4 Likes

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.

Pete.

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

1 Like