Store settings on Blynk server

Hi All,

The general idea is to store some device settings in virtual pins on Blynk server
So steps on device would be following:

  • get settings from Blynk server
  • if settings not present on server use default values and send these values to Blynk server

And im confused a little bit how I could do this
because if I force pin sync to get settings from server with

Blynk.syncVirtual(Args... pins)

It could be that BLYNK_WRITE_DEFAULT or BLYNK_WRITE would not be invoked if value is not stored on server and its not possible to understand is virtual pin value is not stored on server or we just waiting response

Is there some function which could get virtual pin value from Blynk server in sync way? like this:

value = blynk.getVirtual()

Thanks in advance

Hello. You can set the default value to the virtual pin and when you do sync you can check for that default value, so you would know if pin is not yet initialized with your config.

Hi Dmitry,
Thanks for the answer

But it will not solve the problem because if I set default values to virtual pins it will override values stored on server

In general, the question can be reduced to the following: how to update virtual pin on Blynk server ONLY if value for this pin is not stored on server ?

When you create a virtual pin, you set a default value to “0”.

When hardware initially connects to the server and does sync for that pin, pseudo code:

  String val = param.asStr();
  if (val == "0") {
     //here config is not set yet
     //if you send here update to the server
     //this branch will never be executed again, unless you set the "0" manually

In other words - you can use the initial default value of the pin as a flag or indicator that this pin hasn’t a value yet (while formally the value is there).

Do you mean default value in web UI ?
Is it possible to do the same with local Blynk server ?

Setting a default value when creating a datastream is a Blynk IoT feature, not Legacy.

However, why don’t you simply set the variable values to your defaults immediately before you call Blynk.syncVirtual ?


Hi Pete,

Do you mean like this ?

void setup() {;

  Blynk.virtualWrite(Vx, defaultValue); // <-- I think it will override value on the server (in case if it exist)

  value = param.asInt();


  value =  defaultValue;


Yes, it would work for default value on device but the I also need to set default value on server side



Default value should set “Segmented Switch” widget in android app to proper state (otherwise nothing is selected)

Well, your approach is always going to write the default value to the virtual pin.
Better to set your variable to the default value, call the Blynk.syncVirtual then write the result to the pin.


If you hack the server - yes. In Legacy Blynk there is no “default” value feaute. It’s new thing in Blynk IoT.