I was trying to use one token for 2 esps. One of them are equiped with motion sensor and another with relay board.
At the begining i wrote sketch wich send to vpin V25 fact of changing state of pin4, but my relay module on second esp did not turn on/off. so i desided to write sketch for one esp using virutalpin(just to check whatever virtualpin 25 turns digital pin 5 on or off).
But it was fail! whose sketch below only turn on and off widget state in android app, but not the relay! Please someone help me! What am I doing wrong?
(solution with digitalWrite on pin 5 did not suite for me, cause i need to send V25 remotly to same token and other esp)
Here is some sketch:
char auth[] = “xxxxxxxxxxxxxxxxxxxxxxxxxxxx”;
boolean state0;
void setup()
{
Serial.begin(115200);
Blynk.begin(auth, “”, “”, IPAddress(,,,));
pinMode(4, OUTPUT);
digitalWrite(4, LOW);
pinMode(5, OUTPUT);
digitalWrite(5, LOW);
pinMode(4, INPUT);
}
bool isFirstConnect = true;
BLYNK_CONNECTED() {
if (isFirstConnect) {
Blynk.syncAll();
}
}
BLYNK_WRITE(V25)
{
if (param.asInt() == 1)
{
digitalWrite(5, LOW);
}
else
{
digitalWrite(5,HIGH);
}
}
void loop()
{
if(state0 != digitalRead(4))
{
state0 = digitalRead(4);
Blynk.virtualWrite(V25,state0); // I think the PROBLEM IS HERE))))
}
Blynk.run();
}
If i power 2 my ESPS with same token, remove BLYNK_WRITE(V25) directive and write it on second ESP, the relay module will turn off and on with android app on second esp. So i think the problem is with “virtualWrite”)))