Virtual write speed over bluetooth. Yes loop is clean

I’m attempting to use Blynk as a multi-gauge display for my vehicle, showing engine data. As you might understand the speed of presenting data is essential. Blynk officially states that you should limit your message count to 10 per 1000ms. I’ve done my research and tried various tricks to speed up thing but need more, any advise is welcome. Code is very simple, the virtual write Blynk default sketch can be used as an example. Running on bluetooth and a ESP32 so no network limitations.

I need to execute >100 virtual pin writes every second, 10 different values every 100ms. I’ve tinkered with the BLYNK_MSG_LIMIT to speed things up and switched off debugging just to reduce load but still Blynk will struggle. All the running values will freeze at once sporadically in the Blynk app. Is there anything else that I can change in the BlynkConfig file for the sake of speed?

I think that BlynkTimer limits the number of writes per second.
Try using SimpleTimer instead.

Pete.

… Blynktimer and SimpleTimer are the same - if I read this correctly:

As I understood it, BlynkTimer is a modified version of SimpleTimer that does 3 things differently…

  1. fixes the disappearing Timer ID zero bug
  2. increases the number of allowable timer instances to 16 for each timer object
  3. in some way limits sequential writes to prevent server flooding.

I’ve never tested anything other than the Timer Zero bug, and can confirm that BlynkTimer and SimpleTimer are different in this respect.

I think there was an announcement about these in a library release about 2 years ago, but as I’m writing this on a phone it’s tricky to search for the info. Besides, I still have an hour or so of sunbathing to do before watching the sunset :sunglasses:

Pete.

Seems like I can multi-task with sunbathing and searching, despite Mrs K telling me that I don’t have the correct genes for that stuff…

    • Important : When BlynkTimer struggles to run multiple times (due to a blocked loop), it just skips all the missed intervals, and calls your function only once. This now differs from SimpleTimer , which could call your function multiple times in this scenario.

Pete.

Thanks for the advise, I’ll test the SimpleTimer instead and see how it runs.
I’ll report back!

Don’t believe in what your wife tells you, I rarely do .

1 Like

No difference at all, issues must be elsewhere .

You only mention the Bluetooth in the title… somehow I don’t think Blynk’s BT link is anywhere as fast as WiFi… particularly as it is using the BT link between device and phone, then the phone’s WiFi/cell signal between it and the server, so that is a point of delay right there.

Blynk has implemented some “anti-flooding” methods, so unlikely you can reach that, even with WiFi… but I would recommend comparing what you do have between the ESP32 WiFi vs ESP BT

but I believe the proper value to “disable” the anti-flooding is

#define BLYNK_MSG_LIMIT 0

Hmmm… must have been be difficult for you :stuck_out_tongue: I spent today freezing fingers & toes in the cold and literally watching/waiting for water to boil, in order to fix frozen RV plumbing issues… definitely no multi tasking abilities for web surfing at the same time for me.

1 Like

Attached is a sample of the code that will generate the sporadic freezing symptom, it runs smoothly for about 8-10 seconds and then freeze 1 second, behavior repeats itself continuously . Debug print shows no errors.


#define BLYNK_PRINT Serial

#define BLYNK_USE_DIRECT_CONNECT

#include <BlynkSimpleEsp32_BT.h>


char auth[] = "XXXXX";

BlynkTimer timer;



void myTimerEvent(){

  Blynk.virtualWrite(V2, millis() / 100);

}



void setup(){
  
  Serial.begin(115200);

  Blynk.setDeviceName("Blynk");

  Blynk.begin(auth);

  timer.setInterval(100L, myTimerEvent);
  
}



void loop(){

  Blynk.run();
  timer.run(); 
  
}


WiFi wasn’t really part of my original idea with this project, might give it go to see if any difference .
The server isn’t used as per my understand when you connect directly over bluetooth to the phone as I do , correct?

I commented out the code just to see if that would change things instead of raising the limit as I’ve done too but no difference.


/*
// Limit the amount of outgoing commands per second.
#ifndef BLYNK_MSG_LIMIT
#define BLYNK_MSG_LIMIT      1000 //15 is default
#endif
*/

Sounds like the sort of frequency that the Blynk ping/ heartbeat would occur.
@Gunner, is there an option to change this frequency, or disable it altogether?

BTW, this is the view. from my office today, not a frozen pipe in sight :sunglasses:

Pete.

I like the idea of disabling :slightly_smiling_face:

@PeteKnight Nice view, waves and curves…

Not correct… the server (cloud or local) is likened to the brain of Blynk, it is always needed and always used. With BT, the App must act as a go-between, in comparison to a WiFi device accessing the server directly.

BT is just an older, and now not as common, method of linking older devices (pre ESP… AKA Arduinos with BT, etc).

Yes is is still used and seemingly updated at times, but WiFi based devices are always the better option.

Video of the issue I described.

I stopped watching when my ears where blasted :unamused:

But what I saw was what is expected… too much too fast. Blynk is an IoT app and IoT means internet link, and that means some degree of lag. Adding in BT just adds to the link lag.

For an in car display, you might want to install a local server on an RPi, set up as an access point, and have a dedicated phone/tablet connecting to that server via WiFi (basically NOT connected to or reliant on internet) then use the RPi’s GPIO for sensors and a Blynk client program (NodeJS or Python… Python may be best) running alongside the server. A good RPi, v4 or better, can easily handle both server and client.

Sorry for the background audio, kids watching cartoons.

I understand the fact of this being a IoT solution. Adding additional hardware in the car to host a server is not an option for me at this stage.