In new blynk, is there an alternate for widget bridge for communication between 2 devices?
WidgetBridge bridge1(V10);
You can use Automations to pass data from one device to another, although there are some limitations.
Otherwise take a look at this…
Pete.
#define BLYNK_PRINT Serial
#include "EmonLib.h"
#include <WiFi.h>
#include <WiFiClient.h>
#include <BlynkSimpleEsp32.h>
EnergyMonitor emon; //creates an object to interact with sensor
#define vCalibration 160
#define currCalibration 1
char auth[] = "8QMfHk9qlmr4cUUJKaiKb8u34aVN5LuB";
char ssid[] = "Isabella";
char pass[] = "Isabelladavis";
WidgetBridge bridge1(V10);
BLYNK_CONNECTED()
{
bridge1.setAuthToken("SS7BHmuC-eLuW02dgTpkMCBYv-0tACAv");
}
void setup()
{
Serial.begin(9600);
WiFi.begin();
Blynk.begin(auth, ssid, pass, IPAddress(192,168,45,26));
emon.voltage(15, vCalibration, 1.7);
emon.current(14, currCalibration);
}
void loop()
{
emon.calcVI(20, 2000);
delay(100);
Blynk.virtualWrite(V0, emon.Vrms);
Blynk.virtualWrite(V1, emon.Irms);
bridge1.virtualWrite(V2,emon.apparentPower);
delay(100);
Blynk.run();
}
// Meter B (Consumer side meter )
#define BLYNK_PRINT Serial
//Dependiences
#include "EmonLib.h"
#include <WiFi.h>
#include <WiFiClient.h>
#include <BlynkSimpleEsp32.h>
EnergyMonitor emon;
#define vCalibration 160
#define currCalibration 1
char auth[] = "MFP3HhJC8Yn8UEJV3N2pe_c9etEzFISx";
char ssid[] = "MASTER";
char pass[] = "20042006";
unsigned int Meter_A = 0;
int Relay = 13;
int theft = 0;
int PD ;
WidgetBridge bridge1(V10);
void setup()
{
Serial.begin(9600);
Blynk.begin(auth, ssid, pass, IPAddress(192,168,2,184));
pinMode(Relay, OUTPUT);
emon.voltage(35, vCalibration, 1.7);
emon.current(34, currCalibration);
}
void loop()
{
emon.calcVI(20, 2000);
float Amps = emon.Irms;
Blynk.virtualWrite(V0, emon.Vrms);
Blynk.virtualWrite(V1, Amps);
Blynk.virtualWrite(V2, emon.apparentPower);
delay(100);
Blynk.run();
PD = Meter_A - emon.apparentPower ;
if ((PD >= 10) && (PD >= -10)) {
theft = 1 ;
Blynk.virtualWrite(V3, theft);
digitalWrite(Relay, LOW);
delay(300);
} else {
digitalWrite(Relay, HIGH);
theft = 0 ;
Blynk.virtualWrite(V3, theft);
delay(300);
}
}
BLYNK_WRITE(V1)
{
Meter_A = param.asInt();
delay(100);
}```
//(Is there any way to change this code which i have written for the old version of blynk)
@Isabella Please edit your post, using the pencil icon at the bottom, and add triple backticks at the beginning and end of your code so that it displays correctly.
Triple backticks look like this:
```
Copy and paste these if you can’t find the correct symbol on your keyboard.
Pete.
If you take a look at the ESP32 example in the link I provided then you’ll have a way of emulating the Bridge functionality that existed in Legacy.
Pete.