I see you have a lot of 1 second delays in many of your BLYNK_WRITE() loops… that WILL cause many issues with disconnections and reliability, etc. (even on an ESP32, which I believe has less picky WiFi timing issues then the 8266… but Blynk still has it’s own timing requirements).
Avoid using delays for more than a few ms in critical needs (like Ultrasonic sensors, etc)… use BlynkTimer routines instead. A bit more coding and fancy placement of functions, but it is NON-Blocking.
@Dmitriy While you are bringing that method up… is there a way to have Blynk.syncAll() do so with small (adjustable?) delays in between each vPin? I have tried that command as is, but since I have so much to sync, it instantly floods the system.
Essentially… massive Buffer Overflow errors and system never recovers until physical reset.
Since I switched to ESP from USB, I have had random disconnections (possibly WiFi congestion at home ). I have managed to code recovery routines that work quite nicely… but I can only manually synchronise a few key vPins at a time, since syncAll just makes it worse.
For some reason, that actually doesn’t correct the problem for me. My project actually has a Blynk.syncAll() button for testing purposes. Whenever I press it after one of my timers doesn’t trigger it syncs, but it doesn’t sync the correct state. For instance, lets say my timer is 6pm HIGH 10pm LOW, at 8pm if I use Blynk.syncAll() after missing a timer trigger it will send LOW again, instead of sending HIGH as it should. Does this indicate that the problem is actually between my phone and the blynk server, rather than my ESP?
Yeah, I know about blynktimer. The only reason those delays are there is because they actually shouldn’t ever be called. Those only happen if for some reason the publish to my MQTT server fails, which should basically never occur.
Thanks for the non-blocking example though. I’ll probably just change it out because it’s good practice.
@Dmitriy It appears that Blynk.syncAll() does not sync timers at all. When I run the command all of my buttons that are configured as switches sync, but my timers do not.
Today the “Bedtime” timer failed to turn off:
BLYNK_WRITE(V19)
{
int pinValue = param.asInt(); // assigning incoming value from pin V1 to a variable
if (pinValue == 1)
{
scarlettAlarm = 1;
bedtimeLED.on();
}
if (pinValue == 0)
{
scarlettAlarm = 0;
bedtimeLED.off();
}
}
This timer should have turned off the bedtimeLED at 4am, but it did not and using syncAll() doesn’t result in any change in the LED even though the rest of the switches will update.
Which is interesting. I assume vr[00]5 means it is reading the vpin and it knows it’s a 1, how do I capitalize on that to make my BLYNK_WRITE(V5) trigger?
Since this thread is really not about the timer failing to trigger anymore, and more about using Blynk.sync() functions with the timer, should I make a new thread? I’d really love to get this resolved.