This text will be hiddenHi, Blyk Team!
In my project sometime happens disconnection from blynk_cloud.
Below I show the simlified fragment of real code of project and output of terminal:
```
#define BLYNK_PRINT Serial
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <WiFiManager.h>
#include <SimpleTimer.h>
WidgetLED led1(V1); //shows state of GPIO5 of esp8266
WidgetLED led2(V2); //shows state of GPIO4 of esp8266
WidgetLED led3(V3); //shows state of GPIO12 of esp8266
WidgetLED led4(V4); //shows state of GPIO13 of esp8266
//Virtual pin V5 of Blynk App is linked with widget Value Display
//which is shows value of parameter state
//Virtual pin V0 of Blynk App is shows the current level
//of WiFi signal
SimpleTimer timer;
char ssid[] = "klg";
char pass[] = "klgklgklg";
char auth[] = "5c774b8297a74ca6a06058c0e6c6b5ba";
const int outputs_esp8266[4] = {5, 4, 12, 13};
unsigned int state = 0; //argument of operator: switch (state)
int rssi;
void setup()
{
Serial.begin(115200);
WiFiManager wifi;
//taking care of wifi connection
wifi.autoConnect("Blynk");
//config blynk
Blynk.config(auth);
while (Blynk.connect() == false)
{
; // Wait until connected
}
Serial.println("Blynk connected");
timer.setInterval(1000L, _main);
for (int i = 0; i < 4; i++)
{
pinMode(outputs_esp8266[i], OUTPUT);
digitalWrite(outputs_esp8266[i], LOW); //HIGH
delay(10);
}
}
void loop() {
Blynk.run();
timer.run();
}
void _main()
{
rssi = WiFi.RSSI();
Blynk.virtualWrite(V0, rssi);
Blynk.virtualWrite(V5, state);
switch (state)
{
case 0:
digitalWrite(outputs_esp8266[0], HIGH);
Blynk.virtualWrite(V1, 200);
state=1;
break;
case 1:
digitalWrite(outputs_esp8266[1], HIGH);
Blynk.virtualWrite(V2, 200);
state=2;
break;
case 2:
digitalWrite(outputs_esp8266[2], HIGH);
Blynk.virtualWrite(V3, 200);
state=3;
break;
case 3:
digitalWrite(outputs_esp8266[3], HIGH);
Blynk.virtualWrite(V4, 200);
state=4;
break;
case 4:
digitalWrite(outputs_esp8266[0], LOW);
Blynk.virtualWrite(V1, 0);
state=5;
break;
case 5:
digitalWrite(outputs_esp8266[1], LOW);
Blynk.virtualWrite(V2, 0);
state=6;
break;
case 6:
digitalWrite(outputs_esp8266[2], LOW);
Blynk.virtualWrite(V3, 0);
state=7;
break;
case 7:
digitalWrite(outputs_esp8266[3], LOW);
Blynk.virtualWrite(V4, 0);
state = 0;
break;
}
}
```
Output of Terminal:
```
*WM: AutoConnect
*WM: Connecting as wifi client...
*WM: Using last saved values, should be faster
*WM: Connection result:
*WM: 3
*WM: IP Address:
*WM: 192.168.1.90
[3131]
___ __ __
/ _ )/ /_ _____ / /__
/ _ / / // / _ \/ '_/
/____/_/\_, /_//_/_/\_\
/___/ v0.4.1 on NodeMCU
[5001] Connecting to blynk-cloud.com:8442
[5081] Ready (ping: 0ms).
[10082] Login timeout
[10082] Connecting to blynk-cloud.com:8442
[10173] Ready (ping: 1ms).
Blynk connected
[16221] Connecting to blynk-cloud.com:8442
[16304] Ready (ping: 0ms).
[23260] Connecting to blynk-cloud.com:8442
[23344] Ready (ping: 1ms).
[82260] Connecting to blynk-cloud.com:8442
[82361] Ready (ping: 1ms).
[88258] Connecting to blynk-cloud.com:8442
[88345] Ready (ping: 1ms).
[95371] Connecting to blynk-cloud.com:8442
[95458] Ready (ping: 2ms).
[146218] Connecting to blynk-cloud.com:8442
[146433] Ready (ping: 1ms).
[152331] Connecting to blynk-cloud.com:8442
[152416] Ready (ping: 1ms).
[157417] Login timeout
[157418] Connecting to blynk-cloud.com:8442
[157504] Ready (ping: 1ms).
[163488] Connecting to blynk-cloud.com:8442
[163578] Ready (ping: 1ms).
[168582] Login timeout
[168582] Connecting to blynk-cloud.com:8442
[168663] Ready (ping: 0ms).
```
As result disconnection on Blynk App customer sees not adequate state of device although device realy works O'k.
I dont think that disconnetion is as result of bad code in this case.
But disconnectiom may be for other reasons - failures of network, load of network, and many others.
Now my questions:
1. Have the errors my code?
2. How can be verify that Blynk.virtualWrite(V3, 0); done succssesful or not? If not then how can be avoid this in code of program?
Thank You.