BLYNK
HOME       📲 GETTING STARTED       📗 DOCS       ❓HELP CENTER       👉 SKETCH BUILDER

Read value from bridge?

Hi friends. I need to reading the humd and temp value of Nodemcu 1 to Nodemcu 2. but I can’t reading the value from the Nodemcu 1. I want to showing the humd+temp to V125. here my sketch:

Nodemcu 1 sender:

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

char auth[] = "eoL0UKzvBBEIhsbFH5shIiqn1jw3D80v";
char ssid[] = "MikroTik Tesla";
char pass[] = "12345678";
char server[] = "10.5.51.5";

WidgetBridge bridge1(V100);

BlynkTimer timer;
DFRobot_SHT20 sht20;

BLYNK_CONNECTED()
{
  bridge1.setAuthToken("yOXPQ12Lpju7po5qUm54jJfW7dALv-Rh");
}

void setup()
{
  Serial.begin(9600);
  Blynk.begin(auth, ssid, pass, server, 8080);
  sht20.initSHT20();
  delay(100);
  sht20.checkSHT20();
  timer.setInterval(2000L, TH);
  timer.setInterval(30 * 1000, reconnectBlynk);
}

void TH()
{
  float humd = sht20.readHumidity();
  Blynk.virtualWrite(V127, humd);
  bridge1.virtualWrite(V127, humd);

  float temp = sht20.readTemperature();
  Blynk.virtualWrite(V126, temp);
  bridge1.virtualWrite(V126, temp);
}

void reconnectBlynk() {
  if (!Blynk.connected()) {

    Serial.println("Lost connection");
    if (Blynk.connect()) {
      Serial.println("Reconnected");
    }
    else {
      Serial.println("Not reconnected");
    }
  }
}

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

Nodemcu 2 receiver:

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

char auth[] = "yOXPQ12Lpju7po5qUm54jJfW7dALv-Rh";
char ssid[] = "MikroTik Tesla";
char pass[] = "12345678";
char server[] = "10.5.51.5";

WidgetBridge bridge1(V100);

BlynkTimer timer;

BLYNK_CONNECTED()
{
  bridge1.setAuthToken("eoL0UKzvBBEIhsbFH5shIiqn1jw3D80v");
}

int humd = (V127);
int temp = (V126);

void setup()
{
  Serial.begin(9600);
  Blynk.begin(auth, ssid, pass, server, 8080);
  timer.setInterval(2000L, TH2);
}

void TH2()
{
  Blynk.virtualWrite(V125, humd + temp);
}

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

thanks.

I think you have made a couple of errors, check the docs here:

It’s been a while since I used bridge, just scanning through you don’t need to set another bridge auth token in the 2nd sketch (hide your auth tokens by the way).

And you need two BLYNK_WRITE’s in the 2nd sketch to receive the incoming data from the 1st sketch (one for temp, one for humidity).

In Arduino IDE:
File>Examples>Blynk>Widgets>Bridge

1 Like