[SOLVED] Problem with Blynk/Simpletimer

Nothing to avoid, No WiFi, no Blynk, no flood.

You are really not explaining what the problem is.

I don’t see any sketch with a 0 - 3ms interval.

You might need to build your own system if you wish to work at 0 - 3ms intervals. Averaging your “timer” would be 667 hits per second, which is not acceptable AFAIK.

Look at the Sketch and Pictures.

In the Beginning after the connection the timer is called every 0-3ms even if set to 1second.

If this happens after a reconnect because of some random connection loss as well Blynk will get send data not every second but every 0-3ms which causes flooding.

Gave you the options on your Arduino Github post.

If you lose the connection to Blynk (WiFi down etc):

  1. Reset device
    or
  2. Stop Timers and restart when WiFi reconnects.

Ok restarting the device is no option since there are tasks that cannot be disrupted or delayed. That’s also the case where I need to implement hardware timers / watchdog lateron.

For stop and start there would be connection checks needed before each timer.run which would be a bit messy but maybe an option.

Just testing if random reconnects cause the same problem.

Just checked…

Random disconnects (for example caused by the router getting offline later online again) do not cause this problem. Neither while loosing connection nor while esp reconnects automatically.

Still need to check if the same happens when reconnect is caused by blynk.run.

So this can’t be caused by espressif’s WiFi implementation. Then it would for sure happen at any connect.

So HOPEFULLY this problem will not be a real problem…

But I wonder why this didn’t show up earlier since so many use SimpleTimer along with Blynk.

When reconnection does’n happen automatically by ESP but through Blynk.run the timers are messed up as in the beginning…

So it seems I need to write a timer as well… :(((

Just for others to know:

  1. When WiFi / Blynk connects by command the timers get messed up

  2. ESP will reconnect automatically without command. Then Timers don’t get messed up

  3. A solution I found and tested working would be to encase Blynk.run() in a check if WiFi has been reconnected automatically like this:

    if (WiFi.status() == WL_CONNECTED)
    {
    Blynk.run();
    }

Btw. this would also avoid other timed actions to get delayed by Blynk reconnection

Just checked you don’t need to do this for Blynk.virtualWrite since it doesn’t reconnect when disconnected.

1 Like