Blynk.virtualWrite seems to be rather slow

I have ported my Smart Home project from using old Blynk Legacy to Blynk IoT. This was really an easy and quick job to do. It took me a day. The time consumption was to make the new GUI and to set up more than 70 datastreams correctly. I have a Plus subscription, and using an Adafruit HUZZAH32 Feather card. I’m also using Visual Code, PlatformIO with platform = espressif32 and framework = arduino. Now I have a challenge with the Blynk IoT regarding virtualWrite and time consumption. It takes on average 68 milliseconds to complete just one call to virtualWrite, but the first write only takes approx 1 millisecond. I’m using micros() to measure time, see code below. The sample just uses four successive writes in a row. My aim is to be able to run on average 8 virtualWrites every 200 millisecond. Now it takes more than 540 milliseconds to complete. Is this how it should be? Am I doing something wrong here?

void TestBlynk_virtualWrite() ;
void MyTest();
static long my_ctr=0L;

void MyTest() 
{
  Serial.println("TestBlynk_virtualWrite()");
  my_ctr=0L;
  for (int i=0;i<10;i++)
  {
    TestBlynk_virtualWrite();
  }
  Serial.println("Test finished");
}

void TestBlynk_virtualWrite() 
{
  long long us1, us2, us3, us4,us5;
  my_ctr++;
  us1=micros();
  Blynk.virtualWrite(V1, 11);
  us2=micros();
  Blynk.virtualWrite(V2, 22);
  us3=micros();
  Blynk.virtualWrite(V3, 33);
  us4=micros();
  Blynk.virtualWrite(V4, 44);
  us5=micros();
  Serial.printf("#%02ld: Delta usec V1: %lld, Delta usec V2: %lld, Delta usec V3: %lld, Delta usec V4: %lld\n",my_ctr,us2-us1, us3-us2, us4-us3, us5-us4);
}
//=========================

OUTPUT using Blynk IoT, library blynkkk/Blynk@^1.1.0

TestBlynk_virtualWrite()
#01: Delta usec V1: 1363, Delta usec V2: 67194, Delta usec V3: 67880, Delta usec V4: 66905
#02: Delta usec V1: 66495, Delta usec V2: 67222, Delta usec V3: 67535, Delta usec V4: 68241
#03: Delta usec V1: 67189, Delta usec V2: 66982, Delta usec V3: 66851, Delta usec V4: 67033
#04: Delta usec V1: 66828, Delta usec V2: 66793, Delta usec V3: 67387, Delta usec V4: 69201
#05: Delta usec V1: 67314, Delta usec V2: 67184, Delta usec V3: 68106, Delta usec V4: 67863
#06: Delta usec V1: 66759, Delta usec V2: 70468, Delta usec V3: 68816, Delta usec V4: 68910
#07: Delta usec V1: 69243, Delta usec V2: 68759, Delta usec V3: 69551, Delta usec V4: 67110
#08: Delta usec V1: 66424, Delta usec V2: 67458, Delta usec V3: 67834, Delta usec V4: 66990
#09: Delta usec V1: 66853, Delta usec V2: 67913, Delta usec V3: 69434, Delta usec V4: 69254
#10: Delta usec V1: 68779, Delta usec V2: 67383, Delta usec V3: 67137, Delta usec V4: 70250
Test finished

Blynk’s example sketches say…


  // You can send any value at any time.
  // Please don't send more that 10 values per second.

Pete.

Sorry for late respons, but thank you for the feedback. I found this description:

Limitations and Recommendations

  • If you send more than 100 values per second - you may cause Flood Error and your hardware will be automatically disconnected from the server

How is it possible to come even close to 100 values per second?

I think that’s either a typo, or documentation relating to the Legacy local server setup when you could use the server.properties file specify user.message.quota.limit=100 to allow upto 100 messages per second - which was potentially do-able when the device and server were on the same private network.

@Oleksii-QA looks like the documentation needs reviewing here…

https://docs.blynk.io/en/blynk.edgent-firmware-api/limitations-and-recommendations

Pete.

@PeteKnight Thank you. We will check it

1 Like

Documentation changed.

Regards

1 Like