Can i share data between 2 Wemos D1 R1 using blynk

you used the blynk_write(v10) function?

Blynk.syncVirtual(V10) calls the execution of BLYNK_WRITE(V10)… if you don’t use that function…

And if you used Blynk.virtualWrite(V50,current1); … you must use Blynk.syncVirtual(V50) and BLYNK_WRITE(V50) in wemos B

Blynk.syncVirtual(V10) calls the execution of BLYNK_WRITE(V10)

where should i write the wemos a or b.

p.s thanks for the support you are a life saver :slight_smile:

Wemos A reads the potentiometer value… send it to V10 for example and at wemos B use syncVirtual(10) at loop function and use BLYNK_WRITE(V10) to get the potentiometer value sent from the wemos A

// WEMOS A //

#define BLYNK_PRINT Serial
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>



int current1;

char auth[] = "673cd76cc5044a49a6cb65fb595e4895";
char ssid[] = "PTCL-BB";
char pass[] = "3553C8A8";


void setup()
{
  
Serial.begin(9600);
Blynk.begin(auth, ssid, pass);
  pinMode(A0, INPUT);
  pinMode(D5,OUTPUT);

}



void switchstate(){
current1 = analogRead(A0);
Blynk.virtualWrite(V10,current1);
}


void relaystate(){
BLYNK_WRITE(D5) ;
digitalWrite(D5, HIGH);
}

void relaystate1(){
BLYNK_WRITE(D5) ;
digitalWrite(D5, LOW); 
}



void loop(){



  Blynk.run();
  switchstate();

  if (current1 > 500){
  relaystate();}
  
  if (current1 < 500){
  relaystate1();}
  
  
}

// WEMOS B //

#define BLYNK_PRINT Serial
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>

char auth[] = "673cd76cc5044a49a6cb65fb595e4895";
char ssid[] = "PTCL-BB";
char pass[] = "3553C8A8";


void setup()
{
  
Serial.begin(9600);
Blynk.begin(auth, ssid, pass);
  pinMode(D5, OUTPUT);

}



void loop(){

Blynk.run();
 
Blynk.syncVirtual(V10); 

}


 
BLYNK_WRITE(V10){
 
}



 BLYNK_WRITE(D5) {
    
 int pinValue = param.asInt(); // Assigning incoming value from pin V3 to a variable
 if (V10 > 500) {
    digitalWrite(D5, HIGH); // Turn LED on.
  } else {
    digitalWrite(D5, LOW); // Turn LED off.
 }
}

Is this ok now?

You know the use of this function?

yes i am trying to make the led on wemos b high.

it is working on wemos A .
when the pot value goes high it turns the on board led on

but it is not working on Wemos B

Wemos A

#define BLYNK_PRINT Serial
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>

int PotValue=-1;
char auth[] = "673cd76cc5044a49a6cb65fb595e4895";
char ssid[] = "PTCL-BB";
char pass[] = "3553C8A8";


void setup()
{
  Serial.begin(9600);
  Blynk.begin(auth, ssid, pass);
  pinMode(A0, INPUT);
  pinMode(D5,OUTPUT);
}
void SwitchState()
{
  if (PotValue!=analogRead(A0))
  {
    PotValue=analogRead(A0);
    Blynk.virtualWrite(V10,PotValue);
    digitalWrite(D5, PotValue> 500); //HIGH==TRUE==1
  }

}


void loop()
{

  Blynk.run();
  SwitchState();
}

Wemos B

#define BLYNK_PRINT Serial
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>

char auth[] = "673cd76cc5044a49a6cb65fb595e4895";
char ssid[] = "PTCL-BB";
char pass[] = "3553C8A8";
BLYNK_WRITE(V10)
{
  int pinValue = param.asInt();
  digitalWrite(D5,pinValue > 500);
}
void setup()
{
  Serial.begin(9600);
  Blynk.begin(auth, ssid, pass);
  pinMode(D5, OUTPUT);
}

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

Wemos A Led is turning On / Off But Wemos B Still not working

Check this… i make a mistake before

@Muhammad_Umair Here is a Bridge option example.

And yes, each device has its own AUTH code as that is the recommended way of running multiple devices, even if in the same project (although then I see no reason to use Bridge… just share data via code and variables and/or vPins)

I have two wemos d1’s connecting via bridge. I use two different authorisation tokens which is pretty much how the blynk sketch does it. Give it a try. Logically if both wemos’s are using the same auth code perhaps that is causing the problem.

Wemos b led now high all the time

use some serial.print to check the values sent and received… i’m doing this on my mind without arduino ide XD

Wemos A is sending the Data value to pin 10 i checked in blynk app it is recieveing value but not sure if Wemos b is getting the data correctly

i have Wemos A & B on the same token it that a problem?

:man_shrugging:

I told you to use the bridge for a reason, but as you insisted on using the same token for both …I wrote these codes

it Started Working MAN.

YOU ARE THE BEST MAN!!!
THANKS ALOT

i wanted to use bridge but it seems a little complicated and i am not as good programmer as you are man.

thanks alot again. with a simple serial.print statement it started working on wemos b too

I’ve tried to use to use the bridge between 2 sonoff devices (esp8266 based). After a while both devices just stop communication.