Hi, I migrated to the new version of BLYNK IOT, I have two wi-fi devices communicating with each other by transferring data, I use the ‘bridge1.virtualWrite’ function.
In the new system I read that this function is no longer working.
I ask you how can I transfer you with the new System.
I seem to have read that you need to use AUTOMATION but it’s not clear to me how to use it-
Thank you
Ciao, sono migrato nella nuova versione di BLYNK IOT, ho due dispositivi wi-fi che comunicano tra loro trasferendo dati, uso la funzione “bridge1.virtualWrite”.
Nel nuovo sisema ho letto che questa funzione non è piu funzionante.
Vi chiedo come posso trasferire darti con il nuovo Sistema.
Mi sembra di aver lettoche bisogna usare AUTOMATION ma non mi è chiaro come utilizzarlo-
Grazie
/*************************************************************
Control another device using Bridge widget!
Bridge is initialized with the token of any (Blynk-enabled) device.
After that, use the familiar functions to control it:
bridge.digitalWrite(8, HIGH)
bridge.digitalWrite("A0", LOW) // <- target needs to support "Named pins"
bridge.analogWrite(3, 123)
bridge.virtualWrite(V1, "hello")
*************************************************************/
// Template ID, Device Name and Auth Token are provided by the Blynk.Cloud
// See the Device Info tab, or Template settings
#define BLYNK_TEMPLATE_ID "TMPLxxxxxx"
#define BLYNK_DEVICE_NAME "Device"
#define BLYNK_AUTH_TOKEN "YourAuthToken"
// Comment this out to disable prints and save space
#define BLYNK_PRINT Serial
#include <WiFi.h>
#include <WiFiClient.h>
#include <BlynkSimpleEsp32.h>
char auth[] = BLYNK_AUTH_TOKEN;
// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "YourNetworkName";
char pass[] = "YourPassword";
// Bridge widget on virtual pin 1
WidgetBridge bridge1(V1);
// Timer for blynking
BlynkTimer timer;
static bool value = true;
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;
}
BLYNK_CONNECTED() {
bridge1.setAuthToken("OtherAuthToken"); // Place the AuthToken of the second hardware here
}
void setup()
{
// Debug console
Serial.begin(115200);
Blynk.begin(auth, ssid, pass);
// You can also specify server:
//Blynk.begin(auth, ssid, pass, "blynk.cloud", 80);
//Blynk.begin(auth, ssid, pass, IPAddress(192,168,1,100), 8080);
// Call blynkAnotherDevice every second
timer.setInterval(1000L, blynkAnotherDevice);
}
void loop()
{
Blynk.run();
timer.run();
}
Your sketch is not going to work with the new Blynk because it’s a Blynk legacy sketch.
You can forward the data between devices using automation without coding. For example,
If you wish you can use the HTTP(S) API to send data from one device to another in a very similar way to the old Bridge functionality. Here’s a working example for the ESP32…