Can i share data between 2 Wemos D1 R1 using blynk

Hello

I have two Wemos D1 R1 i have programmed the same auth token in both so i can make them both turn on off leds from one app.

but now what i want is that i have attached a potentiometer to one wemos and i want to recieve the reading on the other too.

is it possible ?

Yes, you can do it in different forms…

One of them is

http://docs.blynk.cc/#widgets-other-bridge

What if both the devices have the same token?

You can send the potentiometer value to a virtual pin and in the other wemos you can use http://docs.blynk.cc/#blynk-firmware-blynktimer-blynksyncvirtualvpin to retrieve the updated value using the BLYNK_WRITE function…

i am trying but it isnt working!!

the code in wemos b

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

int current1;
char auth[] = "673cd76cc5044a49a6cb65fb595e4895";
 
char ssid[] = "PTCL-BB";
char pass[] = "3553C8A8";
int yy= 0;
//int LED2 = D3;
int LED3 = D5;

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


void loop(){

  Blynk.run();
 
}


  BLYNK_WRITE(D5) {
    
 int pinValue = param.asInt();
 if (V10 > 500) {
    digitalWrite(LED3, HIGH); // Turn LED on.
  } else {
    digitalWrite(LED3, LOW); // Turn LED off.
 }
}

The Code in Wemos A

#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(A0, INPUT);

  pinMode(D5,OUTPUT);

}



void switchstate(){
  current1 = analogRead(A0);

  Blynk.virtualWrite(V50,current1);

}


void loop(){



  Blynk.run();
  switchstate();

}

Doing this in the setup function only is called 1 time… you must use it at loop function

And use the BLYNK_WRITE(V10) function

i tried in the loop also

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