Okay so that you understand what’s happening, I’ll explain…
In C++, when you do a Blynk.virtualWrite(vPin)
to write data to a virtual pin on the server, the corresponding BLYNK_WRITE(vPin)
callback function is not triggered.
This is a safety feature, to prevent an endless loop being created, and to maintain your sanity, as you’d have constant unwanted BLYNK_WRITE(vPin)
triggers, echoing back the data you’d just sent to the server.
The same is happening in Node-Red. When your ESP device write data to virtual pin 64, it doesn’t trigger the Write node attached to the same virtual pin/auth token combination in Node-Red.
To get the Blynk server to tell you what the value of virtual pin 64 is, you have trigger either a Blynk.SyncVirtual(V64)
in your sketch, or trigger a Sync node attached to pin V64 in Node-Red. You’ve chosen the latter approach.
The “Read” node attached to pin V64 is serving no purpose by the way.
The setup you’ve gone for has the disadvantage described above, and it also has the disadvantage that in the Blynk app/web dashboard the ESP device will appear to be online constantly, even when it’s offline. This is because you have two devices (the ESP and Node-Red) sharing the same auth token. a long as one of them, is connected to the server then that device will appear online.
Thi8s is why I take, and advocate, a different approach.
None of my ESP devices run any Blynk code. Instead, they talk directly to Node-Red via MQTT, and they take their instructions (commands to activate relays for example) from Node-Red via MQTT messages in the opposite direction.
This way, Blynk is totally unaware of my ESP devices. It only knows about the single device that represents the Node-Red connection.
This also overcomes the first issue, as the incoming messages in Node-Red are inbound MQTT messages, not Blynk virtual pin messages.
It’s not a problem using Blynk and Node-Red the way you are, provided you understand the drawbacks and take appropriate precautions. These include adding timeout nodes to alert you when the data from your sensors stops being received, as this probably means that the ESP device has gone off-line.
Also, I wouldn’t use the Node-Red dashboard. It’s better to create another device (the type doesn’t matter) in Blynk, and send the amalgamated data back to that.
Pete.