Is a delay with each virtualWrite normal?

Hi, I just started using Blynk and have been able to integrate it into my project. On the hardware side I’m using a Teensy 3.2 with several sensors plus an Adafruit Bluefruit LE SPI board for Blynk over BLE. There were some issues getting this all working but now I have all the sensors displaying data on my iPhone in the Blynk app using BLE. Looks great, graphing widget is fantastic, and loving what Blynk can do.

So my issue is that whenever I call Blynk.virtualWrite in my Arduino code I notice a delay of about 100 ms. I have 5 virtual pins pushing so I call virtualWrite 5 times. This starts to add up to about half a second delay with each full sensor report. I’ve already spread the virtualWrites so I’m only doing 1 per main loop and then only 1 every 200 ms minimum so only doing about 5 virtualWrites per second so I don’t think I’m flooding. I don’t use any delay() in my own code.

Th reason this delay is a problem is that one of the sensors requires a raw reading at minimum 20 times a second. I was able to get that rate no problem before integrating Blynk, including using the exact same hardware setup but using Adafruit’s BlueFruit app to receive data over Bluetooth locally. But now with Blynk I’m getting only 9 fps which is interfering with my ability to process this particular sensor at the resolution required.

Is this delay for virtualWrite normal? Is there a way to prevent my app from freezing for 1/10th of a second with each call to virtualWrite? I’m thinking this might be a side effect of having to push data through Blynk’s server, or maybe it’s just an issue with Bluetooth LE. Perhaps there’s a setting I’m missing somewhere that prevents Blynk from holding up my app while it waits for the round trip from the server?

Thanks for any help!

There was some form of governor type thing placed in recent library (0.5.0) that prevents most flooding issues, but can cause notable lag wen pushing lots of info.

Local Server can make a drastic difference.

You can also try adding in this command which reportedly disables, or at least reduces, the “governor mode”… though it might only work with Local Server?


Thanks Gunner, I’ll give it a shot. My understanding is flooding is throttled if there are more than 10 pushes a second and as I mentioned I’m only doing 5 per second so I don’t think that’s the issue. Even with only one virtualWrite every second I do notice a small approx. delay of 100ms.

It just seems like each virtualWrite is waiting for a response from the Blynk Server that is pausing the execution of the rest of my code. I don’t mind spreading out the virtualWrites like I’m currently doing since I don’t need high frequency updates on the app, but I do need a high frequency on my hardware’s main loop for that particular sensor. While running, If I disconnect BLE within the Blynk App the software loop on my hardware speeds up to its normal rate.

I’ll also look into setting up a local server, though that’s not something my project can ultimately support. Ideally I’d like the hardware and the Blynk app to work locally over Bluetooth without the need for a server go-between.

Be aware that the server is ALWAYS required, at least for the App side.

Yeah, I know, but a boy can dream, can’t he?