Multi devices eventor

I think you need to re-read my comments.

That’s good, because previously you were running a version of local server which was two years out of date, at a time when frequent updates were being released.
What version of local server are you running now?

Bridge isn’t required if you don’t need to transfer data between two devices.

Pete.

I’m using 0.41.17, latest.

I know this, but i want to learn how it work,

Check this example

also, you can check the documentation as well

If i understand, here :

void blynkAnotherDevice() // Here we will send HIGH or LOW once per second
{
  // Send value to another device
  if (value) {
    bridge1.digitalWrite(9, HIGH);  // Digital Pin 9 on the second board will be set HIGH
    bridge1.virtualWrite(V5, 1); // Sends 1 value to BLYNK_WRITE(V5) handler on receiving side.

    /////////////////////////////////////////////////////////////////////////////////////////
    // Keep in mind that when performing virtualWrite with Bridge,
    // second board will need to process the incoming command.
    // It can be done by using this handler on the second board:
    //
    //    BLYNK_WRITE(V5){
    //    int pinData = param.asInt(); // pinData variable will store value that came via Bridge
    //    }
    //
    /////////////////////////////////////////////////////////////////////////////////////////
  } else {
    bridge1.digitalWrite(9, LOW); // Digital Pin 9 on the second board will be set LOW
    bridge1.virtualWrite(V5, 0); // Sends 0 value to BLYNK_WRITE(V5) handler on receiving side.
  }
  // Toggle value
  value = !value;
}

By activate button attached to D9 on device1 i will control V5 on device2 ?

( exemple: D9 attached button on device1 will blink widget Led attached to V5 on device2 ? )

It work on both side ? if i activate button attached to V5 on device2 i will control D9 on device1 ?

Thakns a lot

I don’t believe you can do this.

You should use virtual pins in the Blynk app, it makes life much easier.
Read this…

Also, it’s impossible to make useful comments on Bridge code based on a small snippet from one device.
You need to post the full sketch from both the sending device and the receiving device.

Pete.

It’s sketch from exemple : Blynk Example Browser

I don’t want to setup it now, i just want to know if i suppose it’s ok

If/when you do actually want to use it then if it’s not working you should post both your sending and receiving sketches.

Pete.

Hi !
I’m trying use bridge, first thing :

Creating new project with two devices : MasterBridge and SlaveBridge

Modify sketch :

#define BLYNK_TEMPLATE_ID           "TMPLxxxxx"
#define BLYNK_DEVICE_NAME           "Devices"
#define BLYNK_AUTH_TOKEN            "YourAuthToken"

For this i don’t know wich is good value, from Master ? from Slaves ?

Think token is and devices name is from slave right ?

And for template ?

Or i’ve to make two different project ?


Thanks

So start by explaining exactly what it is that you are trying to achieve with this bridge, why it is being used, and what data is being transferred from one device to another.

Each device needs a unique Auth token, and most likely different templates.

Pete.

I want receive value ( t°, humidity ) from slave to master than master wich can control relay.

OR

I could use each ESP8266 with its own relay management

What’s the better way ?

To be honest, your brief description doesn’t help.

If it’s physically practical to have a single device taking readings and controlling a relay then this would always be my preferred approach.

It’s not always practical to do that - for example when you want to monitor the temperature in a living room but control a boiler that’s located in a basement. In that situation you probably need two devices - one in the living room and the other in the basement - with reading being sent from one to the other.
In this scenario I’d make the device with the sensor attached the slave device, with the master device being the one in the basement which makes all of the decisions about actions based on the readings from the slave and values such as target temperature, auto manual mode, hours of operation etc which come from the app.

That’s the most advice you’re going to get from me, unless you can be bothered to articulate your use-case in much more detail.

Pete.

No matter, sensor and relay on same devices is easy to do and i know how to do that.

I’m here for learn so i learn bridge

It’s for montoring fan : on slave i’ve T° sensor, if T° is more than 30 fan is on, else is less than 29 fan OFF

T° on slave, fan relay on master

I’ve create new project who’s named bridge with two devices : master and slave

I know, but i don’t know witch Template ID, Token and devices name i’ve to put here

I’m looking for this sketch exemple : Blynk Example Browser

Personally, I’d ignore that example. It uses the Bridge widget, and I’m not even sure it ever worked as designed.

Read some of these topics by @Gunner

https://community.blynk.cc/search?q=@gunner%20bridge

Also, if you’re just wanting to learn how Bridge works then I’d suggest sending something simple, like uptime in seconds, from one device to the other.

Pete.

So now bridge work ! Thanks !

Following C++ Blynk (Legacy) - Code Examples for Basic Tasks - #22 by Gunner

Hi !

My bridge is working, now i’ve problem. How i can read Vpin value coming from bridge to start function.

Here is my sketch in void relais i want to read V44 who’s humidity value from device2

#define BLYNK_PRINT Serial

#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>

char auth[] = "xx";
char ssid[] = "xxx";
char pass[] = "xxxx";

BlynkTimer timer;

//
WidgetBridge bridge1(V1);

//
int minRange = 70;
int maxRange = 80;

void setup()
{
  // Debug console
  Serial.begin(9600);


  Blynk.begin(auth, ssid, pass, IPAddress(10, 3, 141, 1), 8080);
  digitalWrite(2 , LOW);
  delay(1000L);
  digitalWrite(2 , HIGH);
}

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

BLYNK_WRITE(V43) { 
  Blynk.virtualWrite(V43, param.asFloat());
}

BLYNK_WRITE(V44) { 
  Blynk.virtualWrite(V44, param.asFloat());
}

void relais ()

{

  if (V44 > minRange)
  {
    digitalWrite(2, HIGH);
  }

  else
  {
    digitalWrite(2, LOW);
  }
}

Thanks

Let’s keep all of your Bridge experiments in one place, rather than creating a parallel discussion in a different topic.

I have no idea what this code is meant to achieve, and it’s doing some very odd things like this…

However, as I said earlier…

Pete.

This is input from sending device. As Gunner on his post : C++ Blynk (Legacy) - Code Examples for Basic Tasks - #22 by Gunner

With gauge on receiving devices i’ve value ( on V44 and V43 ) from sender

Sending sketch :

#define BLYNK_PRINT Serial

#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <DHT.h>

#define DHTPIN 2          // What digital pin we're connected to
// Uncomment whatever type you're using!
#define DHTTYPE DHT11     // DHT 11
//#define DHTTYPE DHT22   // DHT 22, AM2302, AM2321
//#define DHTTYPE DHT21   // DHT 21, AM2301

DHT dht(DHTPIN, DHTTYPE);
// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).

char auth[] = "IlcMe5hpdqwqpsoisIObIkhtNuRRq_k9";


char ssid[] = "indoor";
char pass[] = "indoorwifi";


BlynkTimer timer;

 float h = dht.readHumidity();
  float t = dht.readTemperature();
WidgetBridge bridge1(V1);

void setup()
{
  // Debug console
  Serial.begin(9600);


  Blynk.begin(auth, ssid, pass, IPAddress(10, 3, 141, 1), 8080);

  dht.begin();

  // Setup a function to be called every second
  timer.setInterval(1000L, sendSensor);

 
}

BLYNK_CONNECTED() {
  bridge1.setAuthToken("VsfeTTqiW4sizahXIBbECZSp0NohKEm_"); // Token of the hardware B
}

void loop()
{
  Blynk.run();
  timer.run();
}
void sendSensor()
{
  float h = dht.readHumidity();
  float t = dht.readTemperature(); // or dht.readTemperature(true) for Fahrenheit

  if (isnan(h) || isnan(t)) {
    Serial.println("Failed to read from DHT sensor!");
    return;
  }
  // You can send any value at any time.
  // Please don't send more that 10 values per second.
  Blynk.virtualWrite(V20, h);
  Blynk.virtualWrite(V21, t);
   bridge1.virtualWrite(V43, t);  
  bridge1.virtualWrite(V44, h);  
}

Receiving sketch :

#define BLYNK_PRINT Serial

#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>

char auth[] = "VsfeTTqiW4sizahXIBbECZSp0NohKEm_";
char ssid[] = "indoor";
char pass[] = "indoorwifi";

BlynkTimer timer;

//
WidgetBridge bridge1(V1);

//
int minRange = 70;
int maxRange = 80;

void setup()
{
  // Debug console
  Serial.begin(9600);


  Blynk.begin(auth, ssid, pass, IPAddress(10, 3, 141, 1), 8080);
  digitalWrite(2 , LOW);
  delay(1000L);
  digitalWrite(2 , HIGH);
}

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

BLYNK_WRITE(V43) { 
  Blynk.virtualWrite(V43, param.asFloat());
}

BLYNK_WRITE(V44) { 
  Blynk.virtualWrite(V44, param.asFloat());
}

void relais ()

{

  if (V44 > minRange)
  {
    digitalWrite(2, HIGH);
  }

  else
  {
    digitalWrite(2, LOW);
  }
}

And if you read that post carefully you’ll see that it’s for a bi-directional Bridge, where both devices are both sending and receiving via the Bridge, which isn’t what you said you were trying to achieve.

Change this…

So that you’re serial printing the value that is being recieved on V43 rather than doing a Blynk.virtualWrite with it.

If you’re expecting this to do something with the data received on pin V44 then you’re mistaken…

That’s not how you access the data that is received on a virtual pin.
Read the “using virtual pins to control physical devices” tutorial that I linked to in post #14 for more info.

Pete.

Wich can more can less, step by step, first one directional after bi directional. I don’t know how to change this

I receive two value humidity from V44 and temperature from V43 ineed both
I’s working with gauge attached to V44 and V33.
I don’t understand what you mean

I know, that’s why i ask for…