Blynk.syncAll() is not syncing the timer widget output. What I noticed is, for example, if I set the timer widget start at 6pm and stop at 10pm and if there is a power interruption at 7pm, selected output of the widget(virtual/digital) won’t go high(to previous state) after the power restoration. This senario is absolutely working fine for button widget, ONLY issue with timer output.
Do we need to be running under local server in order to benefit from the blynk.syncAll function? I haven’t set up my server yet but am trying to capitalize on the sync all function but am not having enough luck.
Much like @Lavan, I’m trying to avoid any hick ups that can incur if the timer widget’s cycle is unexpectedly hindered, e.g. power going out before or after either high/low data transfers. I followed the link to (https://github.com/blynkkk/blynk-library/blob/master/examples/More/Sync/Sync.ino) and copy/pasted the script into a javascript file through the linux terminal/command. When I attempt to activate/implement the script and function, I get a syntax error message declaring multiple illegal tokens. Is this normal?
BLYNK_WRITE(V0)
{
// You'll get HIGH/1 at startTime and LOW/0 at stopTime.
// this method will be triggered every day
// until you remove widget or stop project or
// clean stop/start fields of widget
timerState = param.asInt();
Serial.print("V0 in sync: ");
Serial.println(timerState);
}
there is no response on Serial neither after boot, network connection, not even if I call every 1 minute
Blynk.syncVirtual(V0);
if I change V pin number to other than timer widget there is respond on serial like for example
BLYNK_WRITE(V16) // slider on V16 to set value
{
moisture_alarm = param.asInt();
Serial.println(moisture_alarm);
}
I noticed that syncing doesn’t work for Virtual Pins that have no representation in widgets in app:
If I write some data by Blynk.virtualWrite(V2, timerState); I can’t sync V2 (syncing doesn’t run BLYNK_WRITE(V2) with confirmation on serial [as in example 2 posts before]) until I add widget on this pin although data is correctly written to server and I can see it using http://blynk-cloud.com/********/get/V2.
Seems like this might be the problem with Timer widget - maybe it doesn’t represent itself in app continuously, only when it changes state.
I also found weird behaviour
/*************************************************************
This runs on NodeMCU.
LED on V4
Timer on V5
/*************************************************************/
#define BLYNK_PRINT Serial
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
char auth[] = "******";
char ssid[] = "*****";
char pass[] = "****";
void setup()
{
Serial.begin(9600);
Blynk.begin(auth, ssid, pass);
}
BLYNK_CONNECTED() {
Serial.println("connected");
//First try this and read serial
Blynk.syncAll();
Serial.println("syncAll");
//Then comment 2 lines above, and uncommet 2 lines below and read serial
//Blynk.syncVirtual(V4, V5);
//Serial.println("syncVirtual V4, V5");
//Then comment 2 lines above, and uncommet 2 lines below and read serial
//Blynk.syncVirtual(V5, V4);
//Serial.println("syncVirtual V5, V4");
}
BLYNK_WRITE(V5) //Timer on V5
{
// You'll get HIGH/1 at startTime and LOW/0 at stopTime.
Serial.println("V5 Timer in sync ");
Serial.print("Got a value: ");
Serial.println(param.asInt());
if (param.asInt() == 0)
{
Blynk.virtualWrite(V4, 0);
Serial.println("LED OFF");
}
else
{
Blynk.virtualWrite(V4, 255);
Serial.println("LED ON");
}
}
BLYNK_WRITE(V4) //LED on V4
{
Serial.print("V4 LED in sync: ");
Serial.println(param.asStr());
}
void loop()
{
Blynk.run();
}
Case 1
[26207] Connecting to blynk-cloud.com:8442
[26569] Ready (ping: 1ms).
connected
s <—— this should be syncAll (???) and then serial doesn’t show anything even when timer changes state
Case 2
[26209] Connecting to blynk-cloud.com:8442
[26437] Ready (ping: 1ms).
connected
syncVirtual V4, V5
V4 LED in sync: 0
<—— no response from BLYNK_WRITE(V5) but serial works
Case 3
[24200] Connecting to blynk-cloud.com:8442
[24480] Ready (ping: 1ms).
connected
syncVirtual V5, V4
V4 LED in sync: 0
<—— no response from BLYNK_WRITE(V5) but serial works
(I don’t know if there is any difference in syncVirtual(V4, V5) and syncVirtual(V5, V4)