Widget LED, reconnects when closing app

Hi.

I’m having a problem with the Widget LED, it seems like bug. I can reproduce it in my own sketch and the Widget LED example.

I’m using ESP8266 (01) and Android.

When i’m using the widget LED and run the sketch everynthing is working just as intended, until i close the Blynk app on my android phone.
Then the ESP runs the loop a few more moments before reconnecting to Blynk server. It keeps trying to reconnect every few moments.
Every second time it reconnects to Blynk server, and every other it reconnects to WiFi network.

the log i get from the Example code is:

[16953] LED2: 180
[17497] LED1: off
[17515] LED2: 160
ü!¤<ÖÈ�H·¤äÎÆ­Êø1¤ñþ[226] Blynk v0.2.2-beta
[250] Connecting to MyWiFiSSID
[4372] Connected to WiFi
[4397] Connecting to cloud.blynk.cc:8442
[5220] Ready!
[5434] LED2: 20
[6138] LED2: 40
[6650] LED1: on
[6665] LED2: 60
[6931] LED2: 80
[7196] LED2: 100
[7719] LED1: off
[7736] LED2: 120
[8005] LED2: 140
[8524] LED1: on
[8540] LED2: 160
[8809] LED2: 180
[9076] LED2: 200
[9568] LED1: off
[9585] LED2: 220
[9849] LED2: 240
[10115] LED2: 240
[10633] LED1: on
[10650] LED2: 220
[14227] Sent 0/14
[14245] Connecting to cloud.blynk.cc:8442
[14740] Ready!
[15354] LED1: off
[15372] LED2: 200
[16386] LED1: on
[16403] LED2: 180
[16950] LED1: off
[16968] LED2: 160
[17511] LED1: on
[17527] LED2: 140
[18066] LED1: off
[18084] LED2: 120
ü!¤<Ó€¦äöÎÆ­Êø1¤ñþ[226] Blynk v0.2.2-beta
[250] Connecting to MyWiFiSSID
[2290] Connected to WiFi
[2315] Connecting to cloud.blynk.cc:8442
[2962] Ready!
[3176] LED2: 20
[3880] LED2: 40
[4408] LED1: on
[4424] LED2: 60
[4690] LED2: 80
[4958] LED2: 100

Best regards Christian

Just as a FYI the platform is rebooting.

You would want to copy your code sketch up here not much anyone can do without seeing it.

Also your power clean? You got another one of these chips to test? They are not known to be amazingly stable.

@Spudgunman
Well the bug is the same both in my sketch and in the example for Widget LED. The log i posted was created when running the widget LED example. Code in bottom of reply. The only thing from the Example sketch i changed was:

  • Adding library for ESP8266
  • adding SSID and PASS
  • changing the virtual pin numbers.

Unfortunately at the moment i have no other chip to test. But i don’t think the chip is the problem.
It runs flawless as long as the mobile app is open and connected with the correct Project. As soon as i close the app, or stop the project inside the blynk app, it starts reconnecting.

 /**************************************************************
 * Blynk is a platform with iOS and Android apps to control
 * Arduino, Raspberry Pi and the likes over the Internet.
 * You can easily build graphic interfaces for all your
 * projects by simply dragging and dropping widgets.
 *
 *   Downloads, docs, tutorials: http://www.blynk.cc
 *   Blynk community:            http://community.blynk.cc
 *   Social groups:              http://www.fb.com/blynkapp
 *                               http://twitter.com/blynk_app
 *
 * Blynk library is licensed under MIT license
 * This example code is in public domain.
 *
 **************************************************************
 * Blynk using a LED widget on your phone!
 *
 * App dashboard setup:
 *   LED widget on V1
 *   LED widget on V2
 *
 *
 * WARNING :
 * For this example you'll need SimpleTimer library:
 *   https://github.com/jfturcot/SimpleTimer
 * Visit this page for more information:
 *   http://playground.arduino.cc/Code/SimpleTimer
 *
 **************************************************************/

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

// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "";

WidgetLED led1(2);
WidgetLED led2(3);

SimpleTimer timer;

void setup()
{
  Serial.begin(9600); // See the connection status in Serial Monitor
  Blynk.begin(auth, "SSID", "PASS");
  while (!Blynk.connect()) {
    // Wait until connected
  }
  timer.setInterval(1000, blinkLedWidget);
  timer.setInterval(200, fadeLedWidget);
}

void blinkLedWidget()
{
  if (led1.getValue()) {
    led1.off();
    BLYNK_LOG("LED1: off");
  } else {
    led1.on();
    BLYNK_LOG("LED1: on");
  }
}

void fadeLedWidget()
{
  static int value = 0;
  static int delta = 20;
  value += delta;
  if (value > 255 || value < 0) {
    delta = -delta;
  } else {
    BLYNK_LOG("LED2: %d", value);
    led2.setValue(value);
  }
}

void loop()
{
  Blynk.run();
  timer.run();
}

Seems like a bug. Thanks for reporting.

@vshymanskyy please have a look.

You’re welcome :slight_smile:

Just say if you need any more details or anything.

@Dmitriy hello i try to make a app with led.The progream start and then in serial monitor say :8] Buffer overflow
[213165] Buffer overflow
[213192] Buffer overflow
[213219] Buffer overflow
[213246] Buffer overflow
[213273] Buffer overflow
[213301] Buffer overflow
[213327] Buffer overflow
[213355] Buffer overflow
[213382] Buffer overflow
[213408] Buffer overflow
[213436] Buffer overflow
[213463] Buffer overflow
[213489] Buffer overflow
[213517] Buffer overflow
[213543] Buffer overflow
[213571] Buffer overflow
[233656] Ready (ping: 422ms).
[258277] Login timeout
and then stop. Can you help me?

Please show your code.

//int const lumsus=6;
//int const lumjos=5;
//int const lumstg=10;
//int const lumdre=11;

int o=0;
int prog=0;
int const faderat=5;
int const dl=200;
#define BLYNK_PRINT Serial    // Comment this out to disable prints and save space
#include <ESP8266.h>
#include <BlynkSimpleShieldEsp8266.h>

#include "SoftwareSerial.h" 
SoftwareSerial EspSerial(51, 53); // RX, TX

ESP8266 wifi(EspSerial);

// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "92680b781ff9441a85c3ab1d798a2114";
WidgetLCD lcd(10);

void setup()
{
  
  pinMode(6,OUTPUT);
  pinMode(5,OUTPUT);
  pinMode(11,OUTPUT);
  pinMode(10,OUTPUT);
  pinMode(13, OUTPUT);
  Serial.begin(9600);     // Set console baud rate
  delay(10);
  EspSerial.begin(9600);  // Set ESP8266 baud rate
  delay(10);
  Blynk.begin(auth, wifi, "D-LinkDS", "07439846705a");
}
WidgetLED led1(5);
WidgetLED led2(6);
WidgetLED led3(7);
WidgetLED led4(8);
WidgetLED led5(9);
void fade()
{
  for(int i=0;i<=255;i=i+faderat)
    {
      digitalWrite(6,i);
      digitalWrite(5,i);
      digitalWrite(10,i);
      digitalWrite(11,i);
    }
   for(int i=255;i>=0;i=i-faderat)
    {
      digitalWrite(6,i);
      digitalWrite(5,i);
      digitalWrite(10,i);
      digitalWrite(11,i);
    }
}
void cilic()
{
  for(int i=1;i<=16;i=i+1){
      digitalWrite(5,HIGH);
      delay(dl);
      digitalWrite(5,LOW);
      digitalWrite(10,HIGH);
      delay(dl);
      digitalWrite(10,LOW);
      digitalWrite(6,HIGH);
      delay(dl);
      digitalWrite(6,LOW);
      digitalWrite(11,HIGH);
      delay(dl);
      digitalWrite(11,LOW);
    }
   for(int i=1;i<=16;i=i+1){
      digitalWrite(11,HIGH);
      delay(dl);
      digitalWrite(11,LOW);
      digitalWrite(6,HIGH);
      delay(dl);
      digitalWrite(6,LOW);
      digitalWrite(10,HIGH);
      delay(dl);
      digitalWrite(10,LOW);
      digitalWrite(5,HIGH);
      delay(dl);
      digitalWrite(5,LOW);
    }
    
  }
  void necunoscut1()
  {
  int rando=random(4);
if(rando+1==1){digitalWrite(5,HIGH);
      delay(dl);
      digitalWrite(5,LOW);}
else
  if(rando+1==2){
    digitalWrite(10,HIGH);
      delay(dl);
      digitalWrite(10,LOW);}
      else
      if(rando+1==3){
        digitalWrite(6,HIGH);
      delay(dl);
      digitalWrite(6,LOW);
      }
      else
        if(rando+1==4){
          digitalWrite(11,HIGH);
      delay(dl);
      digitalWrite(11,LOW);
        }

  }
int necunoscut2(){

int rando=random(4);
rando=rando+1;
if(rando==1)fade();
else
if(rando==2)cilic();
else
if(rando==3)necunoscut1();
else
if(rando==4)necunoscut2();
}
BLYNK_WRITE(V0)
{
if(o==0)
{
  prog=0;
  o=1;
  led1.on();
 
}
else
{
  o=0;
  led1.off();
  led2.off();
  led3.off();
  led4.off();
  led5.off();
}
}
BLYNK_WRITE(V1)
{
if(o==1&&prog==0)
{
  prog=1;
  led2.on();
}
else
{
  prog=1;
  led2.off();
}
}
BLYNK_WRITE(V2)
{
if(o==1&&prog==0)
{
  prog=2;
  led3.on();
}
else
{
  prog=0;
  led3.off();
}
}
BLYNK_WRITE(V3)
{
if(o==1&&prog==0)
{
  prog=3;
  led4.on();
}
else
{
  prog=0;
  led4.off();
}
}
BLYNK_WRITE(V4){
if(o==1 && prog==0)
{
  prog=4;
  led5.on();
}
else
{
  prog=0;
  led5.off();
}}


void loop()
{
  delay(200);
  Blynk.run();
  if(o==1){
  if(prog==1)
    fade();
   else
   if(prog==2)
    cilic();
    else
      if(prog==3)
        necunoscut1();
        else
        if(prog==4)
        necunoscut2();}
}

this sketch seems a bit outdated. Could you please check latest library version?

0.3.0 . i try to update it but is doesn`t work

Bibliotec? invalid? în C:\Users\Dominic\Documents\Arduino\libraries\blynk: C:\Users\Dominic\Documents\Arduino\libraries\blynk
Bibliotec? invalid? în C:\Users\Dominic\Documents\Arduino\libraries\blynk: C:\Users\Dominic\Documents\Arduino\libraries\blynk
Directorul/fi?ierul zip specificat nu con?ine o bibliotec? valid?
Bibliotec? invalid? în C:\Users\Dominic\Documents\Arduino\libraries\blynk: C:\Users\Dominic\Documents\Arduino\libraries\blynk
Bibliotec? invalid? în C:\Users\Dominic\Documents\Arduino\libraries\blynk: C:\Users\Dominic\Documents\Arduino\libraries\blynk

The Blynk library contains several 3rd party libraries.
You need to copy them manually to your libraries folder.

The structure should look like this:
~\Arduino\libraries\Blynk
~\Arduino\libraries\BlynkESP8266_HardSer
~\Arduino\libraries\BlynkESP8266_SoftSer
~\Arduino\libraries\SimpleTimer

Please check that you have this structure

i can`t understand what i must do. give me more information

Check that your Arduino "Libraries " folder has the same structure:

~\Arduino\libraries\Blynk
~\Arduino\libraries\BlynkESP8266_HardSer
~\Arduino\libraries\BlynkESP8266_SoftSer
~\Arduino\libraries\SimpleTimer

In file included from G:\programe\blynk\luminite lcd\luminite\luminite.ino:12:0:

C:\Users\Dominic\Documents\Arduino\libraries\Blynk/BlynkSimpleShieldEsp8266.h:14:2: error: #error Sorry, we changed things a little bit. Please check new examples for ESP8266. This is easy to fix :)

 #error Sorry, we changed things a little bit. Please check new examples for ESP8266. This is easy to fix :)

  ^

exit status 1
Eroare de compilare````

i rescribe the sketch and :

[520] Connecting to D-LinkDS
[5641] IP: 192.168.0.108

OK
[5671] Connected to WiFi
[12975] Ready (ping: 448ms).
[36048] Buffer overflow
[36058] Buffer overflow
[36068] Buffer overflow
[36078] Buffer overflow
[36088] Buffer overflow
[36114] Buffer overflow
[36141] Buffer overflow
[36166] Buffer overflow
[36192] Buffer overflow
[36218] Buffer overflow
[36244] Buffer overflow
[36271] Buffer overflow
[36296] Buffer overflow
[36322] Buffer overflow
[36348] Buffer overflow
[36374] Buffer overflow
[36400] Buffer overflow
[36426] Buffer overflow
[36452] Buffer overflow
[36478] Buffer overflow

I try with lcs and the result is the same. the code is:

//int const lumjos=5;
//int const lumstg=10;
//int const lumdre=11;

int o=0;
int prog=0;
int const faderat=5;
int const dl=200;
#define BLYNK_PRINT Serial    // Comment this out to disable prints and save space
#include <ESP8266_SoftSer.h>
#include <BlynkSimpleShieldEsp8266_SoftSer.h>

#include "SoftwareSerial.h" 
SoftwareSerial EspSerial(51, 53); // RX, TX

ESP8266 wifi(EspSerial);

// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "92680b781ff9441a85c3ab1d798a2114";

WidgetLCD lcd(10);
void setup()
{
  
  pinMode(6,OUTPUT);
  pinMode(5,OUTPUT);
  pinMode(11,OUTPUT);
  pinMode(10,OUTPUT);
  pinMode(13, OUTPUT);
  Serial.begin(9600);     // Set console baud rate
  delay(10);
  EspSerial.begin(9600);  // Set ESP8266 baud rate
  delay(10);
  Blynk.begin(auth, wifi, "D-LinkDS", "07439846705a");
}
void fade()
{
  for(int i=0;i<=255;i=i+faderat)
    {
      digitalWrite(6,i);
      digitalWrite(5,i);
      digitalWrite(10,i);
      digitalWrite(11,i);
    }
   for(int i=255;i>=0;i=i-faderat)
    {
      digitalWrite(6,i);
      digitalWrite(5,i);
      digitalWrite(10,i);
      digitalWrite(11,i);
    }
}
void cilic()
{
  for(int i=1;i<=16;i=i+1){
      digitalWrite(5,HIGH);
      delay(dl);
      digitalWrite(5,LOW);
      digitalWrite(10,HIGH);
      delay(dl);
      digitalWrite(10,LOW);
      digitalWrite(6,HIGH);
      delay(dl);
      digitalWrite(6,LOW);
      digitalWrite(11,HIGH);
      delay(dl);
      digitalWrite(11,LOW);
    }
   for(int i=1;i<=16;i=i+1){
      digitalWrite(11,HIGH);
      delay(dl);
      digitalWrite(11,LOW);
      digitalWrite(6,HIGH);
      delay(dl);
      digitalWrite(6,LOW);
      digitalWrite(10,HIGH);
      delay(dl);
      digitalWrite(10,LOW);
      digitalWrite(5,HIGH);
      delay(dl);
      digitalWrite(5,LOW);
    }
    
  }
  void necunoscut1()
  {
  int rando=random(4);
if(rando+1==1){digitalWrite(5,HIGH);
      delay(dl);
      digitalWrite(5,LOW);}
else
  if(rando+1==2){
    digitalWrite(10,HIGH);
      delay(dl);
      digitalWrite(10,LOW);}
      else
      if(rando+1==3){
        digitalWrite(6,HIGH);
      delay(dl);
      digitalWrite(6,LOW);
      }
      else
        if(rando+1==4){
          digitalWrite(11,HIGH);
      delay(dl);
      digitalWrite(11,LOW);
        }

  }
int necunoscut2(){

int rando=random(4);
rando=rando+1;
if(rando==1)fade();
else
if(rando==2)cilic();
else
if(rando==3)necunoscut1();
else
if(rando==4)necunoscut2();
}
BLYNK_WRITE(V0)
{
if(o==0)
{
  prog=0;
  o=1;
  lcd.print(0, 0, "Pornit");
 
}
else
{
  o=0;
  lcd.clear();
}
}
BLYNK_WRITE(V1)
{
if(o==1 && prog==0)
{
  prog=1;
   lcd.print(0, 1, "Fade          ");
}
else
{
  prog=1;
  lcd.print(0, 1, "Comada:        ");
}
}
BLYNK_WRITE(V2)
{
if(o==1 && prog==0)
{
  prog=2;
   lcd.print(0, 1, "Ciclic         ");
}
else
{
  prog=0;
  lcd.print(0, 1, "Comada:        ");
}
}
BLYNK_WRITE(V3)
{
if(o==1 && prog==0)
{
  prog=3;
   lcd.print(0, 1, "Nec1           ");
}
else
{
  prog=0;
  lcd.print(0, 1, "Comada:        ");
}
}
BLYNK_WRITE(V4){
if(o==1 && prog==0)
{
  prog=4;
  lcd.print(0, 1, "Nec2           ");
}
else
{
  prog=0;
  lcd.print(0, 1, "Comada:        ");
}}
BLYNK_WRITE(V5){
if(o==1 && prog==0)
{
 digitalWrite(5,HIGH);
 digitalWrite(6,HIGH);
 digitalWrite(10,HIGH);
 digitalWrite(11,HIGH); 
  lcd.print(0, 1, "Normal         ");
}
else
{
  prog=0;
  lcd.print(0, 1, "Comada:        ");
}}

void loop()
{
  Blynk.run();
  if(o==1){
  if(prog==1)
    //fade();
    digitalWrite(5,LOW);
   else
   if(prog==2)
    //cilic();
    digitalWrite(5,LOW);
    else
      if(prog==3)
        //necunoscut1();
        digitalWrite(5,LOW);
        else
        if(prog==4)
        //necunoscut2();
        digitalWrite(5,LOW);
        else
        if(prog==0)
        {
          digitalWrite(5,LOW);
          digitalWrite(6,LOW);
          digitalWrite(10,LOW);
          digitalWrite(11,LOW);
        }
        }
        else
        lcd.clear();
}

Too many code. The simplest way to find a problem would be to start from begining. So start from empty Blynk example and tell us if it works. If it works - add step-by-step your code and check every time if it works until above error.