HI, on my ESP32 i am trying to do the following:
BLYNK_WRITE(V1) {
int pinValue = param.asInt();
digitalWrite(leftLightEnable, pinValue == 0 ? LOW : HIGH);
digitalWrite(rightLightEnable, pinValue == 0 ? LOW : HIGH);
Blynk.virtualWrite(V3, pinValue == 0 ? 0 : 1);
Blynk.virtualWrite(V5, pinValue == 0 ? 0 : 1);
}
which does not work, as the virtualWrite() call inside this crashes the esp32 (forces reboot).
Can anyone explain why?
Then i tried the following as a workaround after deleting the virtualWrite
calls:
BLYNK_READ(V1) {
Serial.printf("App requests V1 state\n");
Blynk.virtualWrite(V3, digitalRead(leftLightEnable) == LOW ? 0 : 1);
Blynk.virtualWrite(V5, digitalRead(rightLightEnable) == LOW ? 0 : 1);
}
But the BLYNK_READ
function never gets called. Shouldn’t this function be called every time a virtual pin’s state changes in the app (or at least the specified pin) ?
I am running a local Blynk server (Docker container on a Synology NAS).
Everything else works so far (turning the lights on/off via app and setting their brightness).
The rest of the code should not be relevant in this case, but i can attach it if anyone needs it for better understanding/etc.
Thanks in advance for any help!