Is multiple bridges between end nodes possible?

I want to send 2 or more integers using bridge function from one end node to another. is it possible to use a code like this?

Where 2 bridges are initialised between the same 2 end nodes.

include <SPI.h>
#include <Ethernet.h>
#include <BlynkSimpleEthernet.h>
#include <SimpleTimer.h>

// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "YourAuthToken";

// Bridge widget on virtual pin 1
WidgetBridge bridge1(V1);
WidgetBridge bridge2(V2);

// Timer for blynking
SimpleTimer timer;

void setup()
{
  Blynk.begin(auth);

  while (Blynk.connect() == false) {
    // Wait until connected
  }

  bridge1.setAuthToken("OtherAuthToken");  //Can these be the same device??
  bridge2.setAuthToken("OtherAuthToken");  //2 bridges to the same end node?

  // Call blynkAnotherDevice every second
  timer.setInterval(1000L, blynkAnotherDevice);
}

int integer1 = 44;  //static value just for testing
int integer2 = 88;  //static value just for testing 
void blynkAnotherDevice()
{  
    bridge1.virtualWrite(V1,integer1);
    bridge2.virtualWrite(V2,integer2);
}

void loop()
{
  Blynk.run();
  timer.run();
}

I can tell you one thing, one Bridge can be linked to multiple devices, a.k.a. same auth token can be used on several “slave” devices. I have two ESP-01’s, one with a LED and one with two Relays. In my code I just use different vpins for the logic on the receiving side.

E.g. ESP-Relay uses Vpins 24 / 25 to switch state and ESP-LED uses Vpin23.

Different bridges linked to the same device is an interesting concept though. I can see some use cases for that.

2 Likes

Yes. Code is correct.

1 Like

Update :
@NickMurray we already have such command.

bridge1.virtualWrite(V2, value1, value2, value3);

I get an error when I try to compile the code, do I need to update my Blynk library maybe?

The error says
No matching function for call to ‘WidgetBridge ::virtualWrite(int, int, int, int)’

Yes. You need to take latest library from the github.

Ok, I have the latest library and it now compiles with no errors.

What do I need in the receiving arduinos code? I have tried as per the photo but don’t have any success yet.

Could you elaborate what exactly is not working?
Put more prints in your code to narrow the problem

Ok, I can only reply from my iPhone at the moment which is a little painfull, but I will try.

I’m trying to send multiple integers on a single bridge using the command
‘’‘bridge1.virtualWrite(V1,33,44,55);’’’

Then on the receiving end I am trying to catch the 3 integers with
‘’‘BLYNK_WRITE(V1) {
Int1 = param[0].asInt();
Int2 = param[1].asInt();
Int3 = param[2].asInt();
}’’’

this doesn’t work for me. Is my receiving code correct?

I have mastered sending one integer successfully but am now trying to send multiple integers in a neat way.

What exactly doesn’t work? We need more info…
Is BLYNK_WRITE(V1) function called?
Is first parameter correctly passed?
What are the values of others?

The BLYNK_WRITE(V1) function is not called.

I did a test with sending a single integer and it is called and works as expected but when sending multiple integers as described above, the function is not called.

@vshymanskyy
I have the latest local server, up to date IOS app, latest Arduino IDE and up to date Blynk Library. I still can’t get the BRIDGE to send more than 1 integer.

It works great just sending a single value but if I try and send multiple values as specified in my previous post the BLYNK_WRITE(V1) function in the receiving end node is not executed.

Does anyone have a Bridge working that sends more than 1 variable? Please post code if you do

I think it goes a little like this:

Device A, Bridge widget on V2, button on V1

BLYNK_WRITE(V1)
{
  Blynk.virtualWrite(v2, 10, 20, 30);
}

Device B:

BLYNK_READ(V2)
{
  value1 = param.asInt[0];
  value2 = param.asInt[1];
  value3 = param.asInt[2];
}

I think it’s something like that and I remember seeing some code somewhere, but not sure where.