Timers
How to use timers in code
If you are looking for a Timer Widget (from Blynk Legacy), it's not here. Timer Widget was replaced with "Wait" action in Automations
As you may already know, hardware can send various data types to the Widgets over the Virtual Pin like this:
Don't put Blynk.virtualWrite(V5, sensorData);
in the void loop ()
!
If you put it code into a void loop()
it will execute "gazillion" times. This will spam the Blynk.Cloud with thousands of messages from your hardware. When it happens, Blynk.Cloud will cut off the connection between your hardware and server.
Use Timers
Blynk Library offers a built-in Blynk.Timer feature to send data in intervals. It allows you to send data periodically with given intervals and not interfere with other Blynk library routines.
Blynk Timer
is based upon SimpleTimer Library, a well-known and widely used library to time multiple events on hardware.
BlynkTimer
is included in Blynk library by default and there is no need to install SimpleTimer separately or includeSimpleTimer.h
separately.A single
BlynkTimer
object allows to schedule up to 16 timersImproved compatibility with boards like
Arduino 101
,Intel Galileo
, etc.When a timer struggles to run multiple times (due to a blocked
loop
), it just skips all the missed intervals and calls your function only once. This differs fromSimpleTimer
, which could call your function multiple times in this scenario.
For more information on timer usage, please see: http://playground.arduino.cc/Code/SimpleTimer
This is an example code on how to send data every second with a timer. Check full example sketch here.
A single BlynkTimer
instance can schedule many timers, so most likely you will only need one BlynkTimer in your sketch.
Last updated