How to get value [virtual pin V ] Save data in local variable

I using ESP8266 to count the production quantity of the machine, I save the count value to [Datastreams v3 : integer] .
In one case I wanted to update that value through the UPDATE API method. I then want to get that updated value assigned to a local variable on the ESP8266.
Can I do this with Blynk? Please help me
This is part of my program:

  ledState = param.asInt();
  digitalWrite(ledPin, ledState);
  counter = counter + 1;   // make counter when push buttom
  Blynk.virtualWrite(V3, counter);   // send [counter] to V3      [counter] => V3         
  //>>>opposite, i want to send and save data from web (manual API) to [counter]      V3 => [counter ] 

@PhongVo please edit your post, using the pencil icon at the bottom, and add triple backticks at the beginning and end of your code so that it displays correctly.
Triple backticks look like this:


1 Like

Thank you Mr Pete
I can do it .

So are you saying that you want to update the count using two different methods?
If so, are you reading the current count via the HTTP(S) API, adding one to this value then re-uploading the result via the API?

If so, then you need to use a similar method with your sketch, get the current value by calling Blynk.syncVirtual(vPin) and incrementing this value before writing the result back to the vPin.

If this isn’t the scenario then you need to explain what it is in MUCH more detail.


Sorry my English is not very good so I caused confusion for you !!!

Yes, that’s right ( by Blynk App method and manual API Update method )
After i update manually i want to read that updated value and assign back to local variable in ESP8266 chip.
The problem you describe is exactly what I want to do.
But I’m having a problem in how to get the value of Vpin and assign it to the [Counter] variable.

   Blynk.virtualWrite(V3, counter);   : ESP8266  Update to Server Blynk   > I get it
   Blynk.virtualWrite(counter, V3); : I don't know how to do it

It’s done with the BLYNK_WRITE(V3) callback function. But this has to be triggered with a Blynk.syncVirtual(V3) command.


1 Like

Idid it .
Thank you so much !!