Blynk.virtualWrite do not update the labeled value

I am updating 2 values in Labeled Value using Blynk.virtualWrite once an hour without using BlinkTimer.
Unfortunately, the first value is updated randomly and the second one, never.

Based on the documentation, it says that a timer should be used however since I am only updating 2 values once an hour I don’t really see the benefits of doing so.

Is there any alternative to virtualWrite, avoiding the use of BlinkTimer in this case?

Is the use of BLINK_READ a better way to avoid the timer?

The alternative to using Blynk timer is to either use a blocking delay, or comparing millis since the last update. BlynkTimer is a far better alternative to either of these.

Are you using deep sleep by any chance?

Pete.

Yes, I am using DeepSleep. Upon reconnection of the WiFi to the AP, I am using the Blynk.config(auth) and get a authorized connection to BlynkServer. Took me sometime to get this sequence right, otherwise I got disconnected from the server often.

Any advise on such a way of operating?

The code structure for deep sleep with Blynk needs to be very different to a normal Blynk sketch.
You should have an empty void loop and not use any BlynkTimers. However, you must execute a Blynk.run after your Blynk.virtualWrites and before deep sleep kicks in.

If you take a look at the “Beehive Connected” project then you’ll see a good example of how to do deep sleep with Blynk.

Pete.

Sorry for the confusion, actually I am using 2 ESP32 in my project, one act has the hub and do not use deep sleep. This is the one that do not update when using Blink.virtualWrite. The loop() only contains Blink.run(). And I did try to have Bllink.run() between the call to virtualWrite without success.
Any other ideas?

And thank you for the deep sleep example anyway, will serve me well in another project ;-).

Why?
The Blynk server should act as the “hub”, as this is where the data is stored.

I think you need to explain a lot more about your project, and share the code that isn’t working if you want us to help you get to the bottom of the problem.

Pete.

Ok. So I have a sensor hub running on an ESP32 collecting the telemetry from various sensors and sending the data to Azure, at the same time to Blink, to be able to display the information easily on mobile devices. I am using a lot of tasks so not easy to share some code. I will try to shrink down the code to the minimum and reproduce the problem.

But basically, once I have receive the data from the sensor, once an hour, I try to send the data to the cloud Blynk server using the virtualWrite. There are a few concurrent tasks on the two core but nothing that should be worrying from my perspective. I try to play with stack size and tasks priority as well as including Blynk.run() in the task without success.

I was simply looking for guidance in such a case, if I was doing something wrong knowing that I do not use the Blinktimer feature which is in my case weird since I do control the flow of data send to Blynk?

I’m still a little confused about the setup.
Is your sensor device (which uses deep sleep) connecting directly to the Blynk server when it wakes up, using its own Auth code?
If so, is it using Bridge code to write the data to the Auth code of the “hub” device to trigger a BLYNK(WRITE(vPin) callback with the sensor readings?

On the device that sleeps, are you using Blynk.begin, or Blynk.config and Blynk.connect ?

Pete.

I am not using Blynk on the sensor at all. Sorry for the earlier confusion about deep sleep. The Sensor hub is all time up. Like listening, receiving data over LoRa, processing the data, sending to Azure, sending to Blynk, listening to the next message, etc…

My guess is that the process of listening for the data from the sensor device, and processing it when it arrives, is blocking the execution of the Blynk processes.
Is your hub device going offline in the Blynk app on a regular basis?
Have you used Blynk.run commands in any non-blynk processes that could be blocking or tying-up your processor time?

Pete.

On the use of the virtualWrite, I do sometimes gets the followings, which according to the log seems to follow the update to Blynk.

Send value 6.3 to Blynk virtual pin (0).
CORRUPT HEAP: Bad head at 0x3ffdafac. Expected 0xabba1234 got 0x3ffdf970
assertion “head != NULL” failed: file “/home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/heap/multi_heap_poisoning.c”, line 214, function: multi_heap_free
abort() was called at PC 0x401302b7 on core 1
ets Jun 8 2016 00:22:57

rst:0x1 (POWERON_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
flash read err, 1000
ets_main.c 371
ets Jun 8 2016 00:22:57

It seems random, can’t find a pattern, but my main issue is still that the first update value happened sometimes and the second call to virtualWrite is never updating the server.

Hi Pete,
I have opted for this strategy since the update are not frequent and it seems to work very well.

    Blynk.config(auth);
    Blynk.connect(10000);
    if (Blynk.connected())
    {
      Blynk.virtualWrite(V0, random(25));
      Blynk.virtualWrite(V1, random(100));
      Blynk.run();
      Blynk.disconnect();
    }

Not following these steps seems to either produce some errors, no update on Blynk server, or after some repetition ESP32 crash such as the one posted here above.
Let me know if this is something that you would discourage me to pursue.
Have a nice day.
Didier

It’s impossible to say, based just on this snippet of code.

Pete.

Where can I send you the entire code?

Didier

Post it here.

Pete.

This code has been working since, you can mark the issue solved. If I can do it myself please let me know how. And thank you for your help. Happy New Year!