BLYNK
HOME       📲 GETTING STARTED       📗 DOCS       ❓HELP CENTER       👉 SKETCH BUILDER

Syncronize a virtual pin by two device on the same Blynk app

Hi everyone,
I’am setting up a new app where 2 device are provided. Device A reads many parameters and upload it to Blynk server on differents virtual pins. Some values are showed in the app, some others not, just stored on virtual pin.
I need to syncronize these values from the device B when I need. I would read values from device B and be able to change it (always from device B).
I tried using a bridge but it doesn’t allow me to refer to the same values.
Any suggestion?

Thank you.

I don’t really understand all of your description, but Bridge is the solution.

Pete.

After some try, I figured out:
If I upload a value from the device A, I can read it from Device A but not from device B.
If I would to read that value from device B, I must upload the value (from device A) doing both Blynk.virtualWrite(V1,x) and bridge1.virtualWrite(V1,x).

Then, if I upload the value from device B, I am able to read it from device A but still not from device B.

How I can do to upload the value from device B on a virtual pin assigned to device A and read it back?

Sorry for the preview post but I didn’t focus it yet.

Thank you

You don’t need to. You already know what value you’ve written to Blynk from Device B - that’s what variables are fore in your sketch.

If you need to verify that the data has been written successfully then you could use Blynk.syncVirtual(vPin) to force the corresponding BLYNK_WRITE(vPin) callback to trigger, but I wouldn’t recommend using this as a matter of course.

Pete.

Thank you @PeteKnight, but I need.
I try to explain:
I save the value “52” into the V1 pin assigned to device A using the device B by the command bridge1.virtualWrite(V1,52).
Then the device A upload the V1 pin to the value “43”.
I would be able to change the value again from my device B.

I need to upload the V1 pin whenever I want.

As soon the device A has upload a new value, I can’t know the value anymore.

I don’t fully understand from that explanation, but it sound like you need to implement a 2-way Bridge, or use Blynk.syncVirtual as I explained before.
There are some examples of multi-way bridges if you search the forum.

Pete.

Thank you @PeteKnight. I try to be more clear.
Actually the project is running on one Blynk app, using 2 device (A and B).
Let’s immagine this example case:

1 - device A (equiped with sensor) saves a value on the virtual pin 1 thanks the command Blynk.virtualWrite(V1, x).

2 - the device B can’t read this value. is ok for you?

3 - So, using also the command bridge1.virtualWrite(V1, x) the device B can read the value x saved on the virtual pin V1.

We can say, using the bridge we will create a mirror copy of each virtual pin.

If I try to modify the value on the V1 using the device B, by the bridge (2-way bridge), I can’t reach the value saved by the device A.

So pass the new value from B to A and have device A do the update.

Pete.