Refreshing blynk led widgets

Hello there, i am using the esp 8266 and working great but i have a problem : when the internet wifi signal is lost for seconds my indicators led widget will also get lost .how can i refresh these virtual pins every 5 minutes any help please.

Using Blynk.syncAll() should restore last settings after disconnect.

@Malek_Alam_Edine Also, please do NOT spam multiple threads with same question… as you did in a another (unrelated) thread. Doing so is good way to get all your questions ignored.

1 Like

Thank you @Gunner for ur help .

hello fellows,
im using wemos d1 wifi shield to controlling 3 outputs , but the real case problem is that i have 6 led widgets set them up as virtual pins.
i used them as indicators to ensure and the outputs are either on or off(1st & 2nd widgets (on/off) ,(3th &4th widgets (on/off) ,(5th & 6th widgets (on/off) ,
So when the network resets(goes offline then gets back online) the shield will reconnect successfully but the indicators will get lost . however , i used reconnectblynk &sync.all function but not working . or will i use physical buttom example:

Here’s my code:

#define BLYNK_PRINT Serial    // Comment this out to disable prints and save space
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <SPI.h>

#include <SimpleTimer.h>

char auth[] = "XXXXXXXXXXXXXXX";
char ssid[] = "FFDFFDl";
char pass[] = "";

const int btnPin = D6;
const int btnPin1 = D7;
const int btnPin2 = D3;
WidgetLED led5(V5);
WidgetLED led3(V3);
WidgetLED led4(V4);
WidgetLED led6(V6);
WidgetLED led7(V7);
WidgetLED led8(V8);
SimpleTimer timer;
boolean  btnState = false;
boolean  btnState1 = false;
boolean  btnState2 = false;

bool isFirstConnect = true;

  if (isFirstConnect) {
    // Request Blynk server to re-send latest values for all pins

 isFirstConnect = false;

  int value = millis() / 1000;
  Blynk.virtualWrite(V3, value);
 int kousa = millis() / 1000;
  Blynk.virtualWrite(V6, kousa);
 int lahme = millis() / 1000;
  Blynk.virtualWrite(V4, lahme);
 int bayd = millis() / 1000;
  Blynk.virtualWrite(V7, bayd);
   int snawbar = millis() / 1000;
  Blynk.virtualWrite(V5, snawbar);
 int KOUSA1 = millis() / 1000;
  Blynk.virtualWrite(V8, KOUSA1);}

void buttonLedWidget()
  // Read button
  boolean isPressed = (digitalRead(btnPin) == LOW);
  // If state has changed...
  if (isPressed != btnState) {
    if (isPressed) {
    } else {
    btnState = isPressed;

void buttonLedWidget1()
  // Read button
  boolean isPressed = (digitalRead(btnPin1) == LOW);
  if (isPressed != btnState1) {
    if (isPressed) {
      led4.on();  ;
    } else {
    btnState1 = isPressed;

void buttonLedWidget2()

  boolean isPressed = (digitalRead(btnPin2) == HIGH);
  if (isPressed != btnState2) {
    if (isPressed) {
    } else {
    btnState2 = isPressed;

void setup()
Blynk.begin(auth, ssid, pass);
pinMode(btnPin, INPUT_PULLUP);
pinMode(btnPin1, INPUT_PULLUP);
pinMode(btnPin2, INPUT_PULLUP);
  timer.setInterval(500L, buttonLedWidget);
  timer.setInterval(500L, buttonLedWidget1);
  timer.setInterval(500L, buttonLedWidget2);


 void loop(){;; 


As I asked before re: spamming with questions in multiple posts… the same goes for creating multiples topics for same issue.

I have merged both topics together and edited your title to closer reflect your issue.

I also edited your code format in your post to make it a bit more readable. Please look back at it to see how it is done for future posting.

I don’t have any ESP devices, so haven’t really needed to use sync, but have you tried without the isFirstConnect…

    // Request Blynk server to re-send latest values for these pins