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.
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 ?
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.
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.
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.
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.
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);
}
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.
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