Why nobody uses bridge?

Hi community,

I’m periodically watching logs and see that at the moment nobody uses bridge at all… So I wonder - why is that? Is that unnecessary feature? Is that lack of documentation? Is that too complex?

Please share your thoughts.

2 Likes

Probably lack of documentation. I’m not even sure what it is supposed to be/do. I remember looking at a code example, but there wasn’t enough information there to tell me what it was supposed to be doing.

5 Likes

Thanks! Working on this! :slight_smile:

3 Likes

Bridge is a great function, i funded the campaign especially for this function… But i’m not a programmer, then I have already problems with the virtual pin…
When the virtual pin will have no more secrets for me i will try that function.

Blink is a fantastic platform for development, the only problem is I’m not a programmer but an electrical designer of building automation.
But don’t worry, you are doing a great job!

3 Likes

Im not a backer, so I did not know this function existed. You should publish a wiki-like page that lists all the features and functionality of Blynk. So, what does it do?

1 Like

@deejayspinz

Bridge allows you to send commands to another device via Blynk Server using device token.
Pseudo code:

Bridge bridge(1);
bridge.setAuthToken(another_device_token);
bridge.digitalWrite(13, HIGH);

Ok guys, thank you for responses so will work on making more docs and feature decriptions.

5 Likes

I would love to play with the bridge function, but doesnt that need a bridge widget?
In the example scripts it says:

WidgetBridge bridge1(1);

So i assumed i needed the bridge widget.

@BasPeter

Right now bridge widget (in app) not needed, we implemented it without it, until app. development is behind schedule. Later we will add in to app so it would be much simpler to use in arduino code.

@BasPeter

if (Blynk.connect()) {
bridge1.setAuthToken(“OtherAuthToken”);
}

this part will go away when UI widget will be ready.

1 Like

Okay, i became curious and started experimenting with bridge.
I would like to use it on a raspberry pi B+.
I installed everything on the pi and it is up and running… but now i have to implement bridge somewhere.

I figured i should change the main.cpp file.

WidgetBridge bridge1(1);

int main(int argc, char* argv)

{
const char *auth, *serv, *port;
parse_options(argc, argv, auth, serv, port);

Blynk.begin(auth, serv, port);
   if (Blynk.connect()){
   bridge1.setAuthToken("My arduino auth code");

}

while(true) {
    Blynk.run();
       BLYNK_WRITE(2) { bridge1.digitalWrite(7,HIGH); }
       BLYNK_WRITE(3) { bridge1.digitalWrite(7,LOW; }
}
return 0;

}

So i changed it to this.
But it gives these errors:
‘WidgetBridge’ does not name a type
bridge1 was not declared …
BLYNK was not delared …

I am not really good with the raspberry pi and linux.

How should i do this? Is this even possible yet?

I just havent had time yet… just got my one ethernet connected audrino right now… setting up my Pi devices this evening and starting my home automation project.

So I’ve been working on some Arduino + ESPs as well as some standalone ESP8266-EVB boards, in isolation they are all working 100% in their own “Projects” in the app, however, I am not able to get the one to activate the relay on the other board.

Below is a copy of the code on my “Primary” board, I added a test LED Widget that activates in the same code that should be sending the command to the second board, this seems to be working as the LED responds when the button is pushed (Although there is a 2-3 second delay that I need to figure out), however the second board is not responding.

If I run the secondary board’s project in the app the button triggers the relay on GPIO5 as expected.

Edit: Edited out the code for the DHT22 just to clean it out for now

#include <ESP8266.h>
#include <SPI.h>
#include <Ethernet.h>
#include <BlynkSimpleShieldEsp8266.h>
#include <WidgetBridge.h>

// Set ESP8266 Serial object
#define EspSerial Serial

ESP8266 wifi(EspSerial);

//Token from My Primary Project
char auth[] = "Primary Token";

WidgetBridge bridge1(1);

void setup()
{
  EspSerial.begin(115200);  // Set ESP8266 baud rate
  delay(10);

  Blynk.begin(auth, wifi, "SSID", "PWD");

  if (Blynk.connect()) 
    {
      //Token from my secondary project
      bridge1.setAuthToken("Other ESP8266-EVB Token"); //copied from the Email to ensure accuracy
      }
} 

BLYNK_WRITE(0) 
{
  int a = param.asInt();
  if (a == 0) 
    {
        //Try trigger relay on other ESP GPIO5
        bridge1.digitalWrite(5, LOW);
    //Activate LED Widget on Primary Display for Testing
        Blynk.virtualWrite(10, LOW);
    } 
  else 
    {
    //Try trigger relay on other ESP GPIO5
        bridge1.digitalWrite(5, HIGH);
    //Activate LED Widget on Primary Display for Testing
        Blynk.virtualWrite(10, HIGH);
      }
}

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

@Bobbo_SA

Could you please also post code of second board? Also please send me your email via private message so I could check your logs for some kind of error if any.

1 Like

HI D,

The second board is very “simple” from the examples, :slight_smile: This is on a ESP8266-EVB board, that has a relay on GPIO5, the app has a button set to pin GP5

//#define BLYNK_PRINT Serial    // Comment this out to disable prints and save space
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <SPI.h>

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

void setup()
{
  Serial.begin(115200);
  Blynk.begin(auth, "SSID", "PWD");
}
void loop()
{
  Blynk.run();
}
1 Like

Hm… Same here. Look like a bug. Thank you for reporting!

Bug? On which side, the ESP or Arduino side? Would I be better off using the ESP as the primary board (And connect the Application to this one) and then use it to communicate to the Arduino based devices?

It is Blynk library bug most probably. So right now no difference what to make primary.

1 Like

In general, a wiki documenting everything properly would help a lot :smile:

2 Likes

@Bobbo_SA

My mistake… I was checking on 13 LED that doesn’t work with Ethernet shield. Checked with other pin - all works fine. So something wrong with your setup. @vshymanskyy maybe you see something wrong?

1 Like

Made some minor coding changes and tried to add in a second Bridge but still not getting a response from either “slave” devices. Both LEDs on the virtual pins work (although delayed):


#include <ESP8266.h>
#include <SPI.h>
#include <Ethernet.h>
#include <BlynkSimpleShieldEsp8266.h>
#include <WidgetBridge.h>

// Set ESP8266 Serial object
#define EspSerial Serial

ESP8266 wifi(EspSerial);

char auth[] = "PrimaryToken";
char authN[] = "ESP8266#1Token";
char authP[] = "ESP8266#2Token";


WidgetBridge bridge1(1);
WidgetBridge bridge2(2);

void setup()
{
  EspSerial.begin(115200);  // Set ESP8266 baud rate
  
  Blynk.begin(auth, wifi, "SSID", "PSK");

  if (Blynk.connect()) {
  bridge1.setAuthToken(authN);
  bridge2.setAuthToken(authP);
  }
}



BLYNK_WRITE(0) {
  int a = param.asInt();
  if (a == 0) {
    bridge1.digitalWrite(5, LOW);
bridge1.virtualWrite(5, LOW);
    
    } else {
    bridge1.digitalWrite(5, HIGH);
bridge1.virtualWrite(5, HIGH);
    
    }
  Blynk.virtualWrite(10, a);
 }

BLYNK_WRITE(1) {
  int a = param.asInt();
  if (a == 0) {
    bridge2.digitalWrite(5, LOW);
    } else {
    bridge2.digitalWrite(5, HIGH);
   }
  Blynk.virtualWrite(11, a);
 }

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

All 3 work in their own “projects”, but still not getting a response from either from the Bridge, although you can see the Primary device recieving and sending data.