The timer widget works great, but I have an arduino + Esp that’s on 24/7. I have lights set to come on between 7 am and 7 pm, but if there is an arduino reboot anywhere in that time, the timer switch that was previously turned on is reset in the code. Any thoughts on a workaround?
Surely the workaround is the sync feature, no?
I do have sync turned on… I should also mention I’m using local server 12.6
So the state of the lights is on, when the Arduino reboots the lights should come back on, (assuming you have the lights hooked up to the Arduino).
Maybe explain the problem a little more.
Here’s how I have it coded. Any thoughts?
bool manualLightSwitch = false;
bool timerLightSwitch = false;
BLYNK_WRITE(6) // Manual override for Timed Switch
{
manualLightSwitch = param.asInt();
}
//Timed Switch
BLYNK_WRITE(8) {
timerLightSwitch = param.asInt();
}
void lightControl()
{
// If timer is on and timer is running, turn lights on or if manual override is on
if ((timerLightSwitch) || (manualLightSwitch))
{
digitalWrite(lightRelay, HIGH);
}
else
{
digitalWrite(lightRelay, LOW);
}
}
What I would do in the Timer function is set some widget that operates with sync high or low (led, value display etc). With simple timer I would monitor this widget at intervals and syncing will take care of the rest.
But if the system reset… Would the value being sent by the timer widget (and subsequently the widget) change to a 0/false value?
The timer widget only sends a high at on time and a low at off time. That is why you should set a flag in a ‘syncable widget’ in the timer on / off function,. AFAIK timer doesn’t sync.
hi Costas. I am just wondering if you can help me out with my project, i am stuck with the blynk timer widget. Everytime my esp reboots the relay triggers high irrespective of the time i set in the widget. I am using the digital button and syncall in an esp standalone sketch and using a cloud witty board for my project.
If it’s the more common, active LOW relay, then your system is running as expected (most ESP pins boot LOW).
sync is for virtual pins not digital pins, unless you have added the appropriate code to your sketch.
is there any way to sync the timer widget with the hardware so the is works according to the inputs that i feed on my app and stays that way in case of esp reboot ?
Yes you can do all that.
Active high or low?
i want relay to be at low state after reboot and also sync it with my timer widget .
Is your relay active HIGH or active LOW?
it is active high.
Does it matter if you get a twitch from the relay on reboot?
If it does, run a none Blynk sketch that tells you the state of every pin on reboot.
Then use one of the LOW pins for the relay.