Reading virtual pin data once the device restarts

• Hardware model + communication type: NodeMCU V3, WiFi
• Smartphone OS (iOS or Android) + version: Android 11
• Blynk server or local server: local server
• Blynk Library version: v0.6.1

Let’s consider this scenario:
I have a Blynk client running on my NodeMCU v3. There is an LED on the NodeMCU that’s set up using PWM and it’s reading the value 0-102 from virtual pin V0. Everything is working fine, I can control this LED using the Blynk app without problems. However, if the NodeMCU for some reason restarts, the LED isn’t on anymore, as it should be. If I’m not mistaken, the virtual pin value is still stored on the local server. How am I able to REQUEST this value from the server? I don’t want to use the “virtual pin changed event handler” method since it only fires once the pin changes. This one:

BLYNK_WRITE(V0) {
  analogWrite(4, param.asInt());
}

I want to request this value from the server each time the NodeMCU resets. Is that possible?
Like… if I left my “brightness slider” at the value 512, I want the NodeMCU to start and set the LED to that value as soon as it starts. Not after I change the slider.

You call the command Blynk.syncVirual(V0); this forces the server to push the current value of V0 to the hardware and this triggers the BLYNK_WRITE(V0) callback.

You could do this in void setup, after you are connected to Blynk, but a better solution is to use the special BLYNK_CONNECTED callback, which will trigger when the device first connects to the Blynk server, and when any subsequent re-connections occur…

BLYNK_CONNECTED()
{
  Blynk.syncVirtual(V0);
}

Of course, you could have discovered all of this by reading the documentation…

https://docs.blynk.cc/#blynk-firmware-blynktimer-blynk_connected

Pete.

This is EXACTLY what I needed. Thank you very much!