#define BLYNK_PRINT Serial
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
char auth[] = "YourAuthToken";
char ssid[] = "YourNetworkName";
char pass[] = "YourPassword";
BlynkTimer timer;
int led = 2;
int button = 3;
void repeat() {
if ((digitalRead(button)) == HIGH) {
digitalWrite(led, HIGH); }
else {
digitalWrite(led, LOW); }
}
void setup()
{
Serial.begin(9600);
pinMode(led, OUTPUT);
pinMode(button, INPUT);
timer.setInterval(1000L, repeat);
Blynk.begin(auth, ssid, pass);
}
void loop()
{
Blynk.run();
timer.run();
}
i need to continue that led & button code even if blynk not connected to server while booting.
my issue is to avoid stuck code while booting while not connected to wifi
This has been covered many times on the forum. A quick search would have revealed the solution.
You are using Blynk.begin, which is a blocking function. You need to handle the WiFi connection yourself, then use Blynk.config and Blynk.connect
Pete.
Could u correct my code as per ur idea and post it here please… will be great help for me…
Regards
Abin
I could, but I’m not going to.
You’ll learn much more by searching the forum for information about the issue and incorporating code examples into your own code.
Pete.
If you took @PeteKnight ’s advice and searched the forum, you would find that it has already been written for you.
While I am not inclined to write if for you either, I will throw you a bone and point you to an example.
#9 Basic “Keeps running without WiFi or Blynk Server connection, but reconnects as soon as they are available” sketch
Simply does what the title says… Flashes the built in LED and sends UpTime data to both App and Serial monitor to show operation either way. Also has a lot of serial print commands to show general operation for troubleshooting… Remove them when you are comfortable that everything works for you.
http://docs.blynk.cc/#blynk-firmware-connection-management
#define BLYNK_PRINT Se…
I already solved by myself. Thanks… for your reply toro-blanco