I’m confused by this statement, but I guess that the issues you’re describing are caused by your use of Blynk.run()
without first testing if Blynk.connected()
is true.
It’s not actually necessary to use Blynk.connect()
at all, because when you use Blynk.config(BLYNK_AUTH_TOKEN)
each time Blynk.run()
executes it will attempt to connect to the Blynk server using te default timeout of around 18 seconds.
This means that when you’re using Blynk.config(BLYNK_AUTH_TOKEN)
you have to do a Blynk.connected()
test before executing ‘Blynk.run()` like this…
If (Blynk.connected())
{
Blynk.run();
}
If you don’t do this then you’ll go through the cycle of attempting to connect, waiting for the timeout period, then attempting to connect again if there is no internet connection or if the Blynk server isn’t reachable.
Using Blynk.connect()
allows you to specify a timeout period in milliseconds, but there’s a limit to how low you can go with this timeout. In my experience somewhere around 5000ms (which gives an actual timeout period of around 6.5 seconds) works well, but it does depend on the latency of your internet connection.
It’s also worth knowing that Blynk.connected()
will continue to return true
after the Blynk connection is dropped, until the Blynk heartbeat period has passed and a failed ping occurs. The default timeout is around 45 seconds, so if it’s important to you that you’re aware that the server disconnection has occurred ASAP then you might want to specify a different timeout.
The subject is discussed in more detail in this topic…
Pete.