SyncVirtual with a Value Display

I am trying to create a small program that can write a value to a virtual display, go into deepsleep, reset its self, and then on reset read the last written value to the virtual display. (deep sleep for power saving reasons as it runs on a battery) I’m just trying to do simple math on this number (determine if the read number from a physical pin is lower than the last reported number) and if it is, update the number in the virtual display. I know that there are existing functions for this with Blynk_write and Blynk.syncvirtual, but I don’t seem to be able to recall a value from a Value Display for a virtual pin. I have looked over the examples and it works if use a button or slider. Is reading last value from a Value Display possible?

Thanks!

Try something like the following. If param.asInt() doesn’t work for value display use param.asStr() and then use toInt().

// ......
unsigned int someCounter 

void setup() {
  // ......
  Blynk.syncVirtual(V0)
}

BLYNK_WRITE(V0) // Value display widget
{
  someCounter = param.asInt();  // recover value from server
}

void loop() 
{
  // ......
}
1 Like

Thanks! Using param.asStr() and then using toInt() resolved it, I’m able to pull the last sent data from the virtual display. I was pulling my hair out over why it wouldn’t work. Appreciate your help!