More than two ESP's in bridge

Hi Everyone.
Just got an ESP working standalone with Blynk. It’s awesome!

A few questions:
does bridge work for esp modules?
How would i go about connecting more than two esp modules in bridge?

does bridge work for esp modules?

Yeap, it should work.

How would i go about connecting more than two esp modules in bridge?

Try to start from Bridge Example.
Briefly - you need to run ESPs with token. You could use same token for all ESPs or different tokens for every ESP. It doesn’t matter. You have only to make

bridge1.setAuthToken(“token_for_esp_you_want_to_control”);

In case ESPs use same token 1 bridge will send message to all of them.

I am also thinking of using blynk to control one ESP12 on the first floor and another ESP12 on the second floor. If I use the same token, and assign different GPIO to each ESP, do I still need bridge and why? Is it because Blynk is unable to tell how many ESPs are connected? What happens if I don’t use bridge for 2 devices but use the same token with different GPIO for each device? Will it still work?
Thanks.

Yip, I have a rather complicated example running now where i have multiple ESP’s connected the the application, but also communicating between themselves without needing any input from the application.

I.e. The one ESP has a PIR and via the Blynk bridge sends a digitalwrite to another ESP that triggers a relay to turn on a light.

I’ve been traveling and have not had a chance to take a video, will upload it this weekend.

Have a look at this thread: Why nobody uses bridge?

in the code I’m initializing the multiple devices as follows:

// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "PrimaryAuthCode";
//Auth Tokens for any additional projects that you would like to control
char auth1[] = "SecondaryAuth1";
char auth2[] = "SecondaryAuth2";
char auth3[] = "SecondaryAuth3";

//Bridge Widget on virtual pin 1 (not currently required in the app)
WidgetBridge bridge1(0);
WidgetBridge bridge2(1);
WidgetBridge bridge3(2);

@favstuff

If I use the same token, and assign different GPIO to each ESP, do I still need bridge and why?

No. In that case you could control 2 ESP from 1 dashboard without bridge and it will work without any problems.

Cool. We will wait for your video!

Excellent !!!
Just to be sure I did explain clearly, here are 2 examples.

Example1
ESP #1 controls a PIR and is assigned to GPIO4.
ESP #2 controls a small buzzer and is assigned to GPIO5
Both ESPs are assigned the same token using the same dashboard.
When ESP #1 PIR is HIGH, I will turn ESP#2 HIGH to turn on buzzer.
This means checking the state of ESP#1 GPIO 4 to activate ESP#2 GPIO5.

Example 2
ESP#3 controls a light in the bath room and is assigned to GPIO6
ESP#4 controls a light in the study and is assigned to GPIO7
Both ESPs have the same token using the same dashboard.

Am I correct to say I don’t need a bridge for both examples 1 & 2?
Thanks again :smiley:

For example 1 you still need bridge. Otherwise how would server know that you sending command to hardware but not App?
For example 2 - no.

In general - if you want to send commands from one hardware to another without Application interaction you need bridge. In other cases like managing few hardwares via 1 dashboard - you don’t.

1 Like

Example 1: You need it to act as the intermediate, you could use MQTT for this BUT then you would loose the ability to monitor the status via the Blynk application, I have posted the same in another thread, just be careful not to continuously write to the servers while the PIR is HIGH, i did some dirty code using some flags to check if the pin is high and if the signal was sent 1 time.

In this example, you can activate ESP#2 + send a notification to the mobile device running blynk app + send a tweet that movement is detected (This is dependent on the new version for IOS being released soon, Android has this already)

Example 2: Dmitriy answered, no Bridge needed.

Thanks. That makes it very clear now.

Thanks. I’ve been following your posting but unfortunately, I don’t know much about programming. Not sure what MQTT is and I am using iphone. I only know a little bit about arduino IDE but the syntax of Blynx does not seem to have much basic explanation/resources at the moment.
For example; I see this variable quite often
int a = param.asInt();

However, I have no idea what param.asInt() is.
Please note, this is my short coming and has nothing to do with Blynk.
So all my ‘programming’ is trial and error and it doesn’t work most of the time. :blush:

That’s true. Working on it. Right now your could use this. At least something.

I too do not have much MQTT knowledge yet, but i can say i’m quite happy with the functionality blynk is providing already, and looking forward to supporting the team going forward (Even if only to provide some guidance via the forums for now), I think this platform has enormous potential.

Thanks Dmitriy.
I looked at the document but unfortunately don’t understand most of it.
I believe it will get better over time and I hope there is more basic explanation for people who have no programming background (which is why Blynk is so attractive).
Regardless, it’s a good start.
Thanks.

My ESP8266 / NodeMCU board work for
Blynk widget, for example: Button, Slider, Larger Slider, Timer, Joystick, zeRGBa,
Value Display, LED, Gauge, LCD, Graph, Terminal,
Twitter, Push Notifications and Email.

I using 2 ESP8266 / NodeMCU,
board #1 as master and
board #2 as slave.
Why Bridge not work?
Thank you, everybody.


Code for board #1 as master:

//#define BLYNK_PRINT Serial
#include "ESP8266WiFi.h"
#include "BlynkSimpleEsp8266.h"
#include "SimpleTimer.h"

SimpleTimer timer;

char my_auth[]  = "PrimaryAuthCode";
char his_auth[] = "SecondaryAuth";

WidgetBridge bridge1( V1 );

void setup()
{ //Serial.begin( 115200 );
  Blynk.begin( `my_auth`, "Johnson", "qwertyui" );
  while ( Blynk.connect() == false )
  { // wait until connect to Blynk Server
  }
  bridge1.setAuthToken( `his_auth` );
  timer.setInterval( 1000L, `blynk_Another_Device` );
}

static bool GPIO_High = true;
void `blynk_Another_Device`()
{ if ( GPIO_High )
  { `bridge1.digitalWrite( 5, HIGH );`  // 5 / D1 / GPIO5
    //Serial.println( "HIGH" );
  } else {
    `bridge1.digitalWrite( 5, LOW );`  // 5 / D1 / GPIO5
    //Serial.println( "LOW" );
  }
  GPIO_High = !GPIO_High;  // GPIO_High Send_High
}

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

Code for board #2 as slave:

//#define BLYNK_PRINT Serial
#include "ESP8266WiFi.h"
#include "BlynkSimpleEsp8266.h"

char his_auth[] = "SecondaryAuth";

void setup()
{ //Serial.begin( 115200 );
  Blynk.begin( auth, "his_auth", "qwertyui" );
  while ( Blynk.connect() == false )
  { // wait until connect to Blynk Server
  }
  pinMode( 5, OUTPUT );  //  5 / D1 / GPIO5 as ouput pin
}

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

Please follow the forum rules and make your code readable

1 Like

Please help me, I rewrite using </>.
Thank you.

someone really needs to make a how to tutorial on controlling 2 nodemcu boards like this;


.
1st board has some sort of a sensor, or multiple sensors
2nd board has some sort of an alarming module, led, buzzer or relay to control ac outlets…
very simple and clean code for the total beginner.
.
would be very appreciated :slight_smile:
https://codebender.cc/sketch:296878

@vshymanskyy could you please help here. Thanks!

any update here yet.?