Hi. Why virtualWrite(V10, “hello”); run only one time in BLYNK_CONNECTED ?? I made some function which work in timer tick in device A and this function send to virtual pin message " hello" but its no working. I try to paste virtualwrite metod in BLYNK_CONNECTED and its work. So why same function not work in timer func??
Hello. Please post your code.
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <TimeLib.h>
#include <WidgetRTC.h>
SimpleTimer smptimer;
int watchdogcounter = 0;
#define ResPin 2
boolean stringESPComplete = false;
String fullESPString = "";
WidgetBridge bridge1(V10);
//Уголок личных данных; -P
// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "Mycode";
// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "AP";
char pass[] = "passw";
WidgetRTC rtc; // инициализируем виджет часов реального времени
BlynkTimer timer; // инициализируем таймер
WidgetTerminal terminal(V0);
WidgetLED stateTXLED(V3);
bool isFirstConnect = true;
BLYNK_CONNECTED()// Если установили связь первый раз, то синхонезируем все виджеты
{
if (isFirstConnect)
{
Blynk.syncAll(); // синхонезируем все виджеты
delay(2000);
Serial.println("Blynk CONNECTED ");
// Составляем строки с временем и датой и добовляем их к сообщению
bridge1.setAuthToken("DeviceBAuthCode");
terminal.println("System start");
terminal.flush();
//this code work in widget terminal on device B i see this message
bridge1.virtualWrite(V10, "{\"tin\":17,\"tout\":20,\"prs\":127}");
isFirstConnect = false;
}
}
void setup()
{
Serial.begin(9600);
WiFi.begin(ssid, pass);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("");
Serial.println("WiFi connected");
Serial.println("IP address: ");
Serial.println(WiFi.localIP());
Serial.println("Try connecting to Blynk server ");
Blynk.config(auth); // in place of Blynk.begin(auth, ssid, pass);
Blynk.connect(3333); // timeout set to 10 seconds and then continue without Blynk
while (Blynk.connect() == false)
{
delay(500);
Serial.print("#BLYNK TRY CONNECT..#");
// Wait until connected
}
rtc.begin();
setSyncInterval(1 * 60);
timer.setInterval(3000L, blynkAnotherDevice);
}
static bool value = true;
void blynkAnotherDevice() // Here we will send HIGH or LOW once per second
{
// Send value to another device
if (value) {
bridge1.virtualWrite(V10, "HI"); // Sends 1 value to BLYNK_WRITE(V5) handler on receiving side.
}
else {
bridge1.virtualWrite(V10, "BYE"); // Sends 0 value to BLYNK_WRITE(V5) handler on receiving side.
}
// Toggle value
value = !value;
}
oid loop()
{
Blynk.run();
timer.run(); // Запускаем таймер
}
//Device B part
//Bridge
BLYNK_WRITE(V10)
{
String pinData = param.asString();
terminal.println("------------------");
terminal.println(pinData);
terminal.println("------------------");
terminal.flush();
}
What about this vidget?? It possible send message to another device?