At risk of taking all my personal time to dissect your every word … I have determined that despite your (initial) title and majority of questions… you are not really asking “how to”… but apparently, and without real clarification, reporting the tested?? results of a bug.
So I will do all that for you (PS, I just volunteer here… not obligated)
@Dmitriy
I have tested and concluded that while using the Timer Widget, It will activate (HIGH) and deactivate (LOW) a virtual pin, on time.
However, if while in-between activation / deactivation, the MCU is rebooted and a sync command for that vPin is called… DEBUG shows the call, but the associated function on the MCU is not actually called.
I even added in a “manual” sync command (triggered by a button) and it also shows as sent in debug, but still no function call.
I previously did this testing in my larger testbench project, with other sync commands present, and determined that they DID work as expected… just not the Timer one.
Here is a dedicated test with three Widgets… Timer on V0, Display on V1 and Button on V2
/* Three Widgets... Timer on V0, Display on V1 and Button on V2 */
#define BLYNK_DEBUG // Advanced diagnostic data... also drasticly slows entire sketch
#define BLYNK_PRINT Serial // This prints to Serial Monitor
#include <ESP8266_Lib.h> // ESP-01 Link
#include <BlynkSimpleShieldEsp8266.h> // ESP-01 Link
ESP8266 wifi(&Serial1); // Pins 18 & 19 on MEGA - For ESP-01 link
char auth[] = "e49d1adeb5xxxxx12f964c3532"; // Blynk App Authorization Code.
char ssid[] = "GunnersZone";
char pass[] = "xxxxx";
char server[] = "xxxxx";
void setup() {
pinMode(6, OUTPUT); // For LED to test timer
Serial.begin(115200); // BLYNK_PRINT data - For Serial Monitor
Serial1.begin(115200); // Set baud rate - For ESP-01 link
Blynk.begin(auth, wifi, ssid, pass, server, 8442); // Connect to Blynk - ESP-01 to Local Server.
Serial.println("Boot Triggering V64 Sync (Timer test)"); // Should have read as V0... remnant vPin from prior test ;)
Blynk.syncVirtual(V0); // Boot Sync of Timer Function
}
void loop() {
Blynk.run();
}
BLYNK_WRITE(V0) { // Timer Function
Blynk.virtualWrite(V1, param.asInt());
Serial.print("Timer vPin State is: ");
Serial.println(param.asInt());
digitalWrite(6, param.asInt());
}
BLYNK_WRITE(V2) { // Manual Sync of Timer Function
if (param.asInt() == 1) {
Serial.println("Manualy Triggering V0 Sync (Timer Test)");
Blynk.syncVirtual(V0);
}
}
Serial Monitor output.
[0]
___ __ __
/ _ )/ /_ _____ / /__
/ _ / / // / _ \/ '_/
/____/_/\_, /_//_/_/\_\
/___/ v0.5.0 on Arduino Mega
[505] Connecting to GunnersZone
[3566] AT version:1.2.0.0(Jul 1 2016 20:04:45)
SDK version:1.5.4.1(39cb9a32)
Ai-Thinker Technology Co., Ltd.
Integrated AiCloud 2.0 v0.0.0.3
Build:1.5.4.1 Jan 10 2017 18:32:04
OK
[8624] +CIFSR:STAIP,"xxxxx"
+CIFSR:STAMAC,"xxxxx"
[8625] Connected to WiFi
[18675] <[02|00|01|00] e49d1adebxxxxx2f964c3532
[18733] >[00|00|01|00|C8]
[18733] Ready (ping: 20ms).
[18734] Free RAM: 7156
[18804] <[11|00|02|00]hver[00]0.5.0[00]h-beat[00]10[00]buff-in[00]1024[00]de
[18870] <v[00]Arduino Mega[00]cpu[00]ATmega2560[00]con[00]ESP826
[18904] <6[00]build[00]Jan 25 2018 18:08:36[00]
[18946] >[00|00|02|00|C8]
Boot Triggering V64 Sync (Timer test) <--- Should read as V0... remnant vPin from prior test ;)
[19017] <[10|00|03|00|04]vr[00]0
[28953] <[06|00|04|00|00]
[29002] >[00|00|04|00|C8]
[39000] <[06|00|05|00|00]
[39042] >[00|00|05|00|C8]
[49032] <[06|00|06|00|00]
[49072] >[00|00|06|00|C8]
[59071] <[06|00|07|00|00]
[59110] >[00|00|07|00|C8]
[59170] >[14|1E]a[00|06]
[59170] >vw[00]0[00]1 <--- Timer Function started here. V0 HIGH for 2 min
[59238] <[14|1E]a[00|06]vw[00]1[00]1 <--- Displaying V0 State in Display
Timer vPin State is: 1 <--- Printing V0 State in Monitor
[69173] <[06|00|08|00|00]
[69228] >[00|00|08|00|C8]
[0] <--- Manual reboot
___ __ __
/ _ )/ /_ _____ / /__
/ _ / / // / _ \/ '_/
/____/_/\_, /_//_/_/\_\
/___/ v0.5.0 on Arduino Mega
[505] Connecting to GunnersZone
[3566] AT version:1.2.0.0(Jul 1 2016 20:04:45)
SDK version:1.5.4.1(39cb9a32)
Ai-Thinker Technology Co., Ltd.
Integrated AiCloud 2.0 v0.0.0.3
Build:1.5.4.1 Jan 10 2017 18:32:04
OK
[8624] +CIFSR:STAIP,"10.10.3.150"
+CIFSR:STAMAC,"5c:cf:7f:3c:b2:08"
[8625] Connected to WiFi
[18668] <[02|00|01|00] e49d1adeb5da462d948a512f964c3532
[18708] >[00|00|01|00|C8]
[18708] Ready (ping: 11ms).
[18709] Free RAM: 7156
[18779] <[11|00|02|00]hver[00]0.5.0[00]h-beat[00]10[00]buff-in[00]1024[00]de
[18848] <v[00]Arduino Mega[00]cpu[00]ATmega2560[00]con[00]ESP826
[18879] <6[00]build[00]Jan 25 2018 18:08:36[00]
[18922] >[00|00|02|00|C8] <--- Bootup sync here.
Boot Triggering V64 Sync (Timer test) <--- Serial print confirmation of sync (again, really was V0)
[18992] <[10|00|03|00|04]vr[00]0 <--- Appears to process... but function NOT called.
[19030] >[14|00|03|00|01]
[19030] >1
[29021] <[06|00|04|00|00]
[29061] >[00|00|04|00|C8]
[39050] <[06|00|05|00|00]
[39089] >[00|00|05|00|C8]
[49087] <[06|00|06|00|00]
[49128] >[00|00|06|00|C8]
[59126] <[06|00|07|00|00]
[59165] >[00|00|07|00|C8]
[69163] <[06|00|08|00|00]
[69203] >[00|00|08|00|C8]
[69422] >[14|04|EB|00|06]
[69422] >vw[00]2[00]1 <--- 1st manual sync.
Manualy Triggering V0 Sync (Timer Test)
[69490] <[10|04|EB|00|04]vr[00]0 <--- Appears to process... but function NOT called.
[69531] >[14|04|EC|00|06]
[69531] >vw[00]2[00]0
[69542] >[14|04|EB|00|01]
[69542] >1
[79520] <[06|00|09|00|00]
[79560] >[00|00|09|00|C8]
[80799] >[14|04|ED|00|06]
[80799] >vw[00]2[00]1 <--- 2nd manual sync.
Manualy Triggering V0 Sync (Timer Test)
[80867] <[10|04|ED|00|04]vr[00]0 <--- Appears to process... but function NOT called.
[80909] >[14|04|EE|00|06]
[80909] >vw[00]2[00]0
[80920] >[14|04|ED|00|01]
[80920] >1
[90900] <[06|00|0A|00|00]
[90954] >[00|00|0A|00|C8]
[100952] <[06|00|0B|00|00]
[100989] >[00|00|0B|00|C8]
[106590] >[14|1E]a[00|06]
[106590] >vw[00]0[00]0 <--- Timer ended, function called.
[106658] <[14|1E]a[00|06]vw[00]1[00]0 <--- Displaying V0 State in Display
Timer vPin State is: 0 <--- Printing V0 State in Monitor
[116600] <[06|00|0C|00|00]
[116640] >[00|00|0C|00|C8]
[126630] <[06|00|0D|00|00]
[126671] >[00|00|0D|00|C8]
[136669] <[06|00|0E|00|00]
[136711] >[00|00|0E|00|C8]
[146710] <[06|00|0F|00|00]
[146759] >[00|00|0F|00|C8]