I’m still a bit fuzzy regarding when to use BLYNK_WRITE() in the global area above setup. I am trying to help a new Blynker with a sketch, as we’re building similar projects (hydroponics controller), except he is using a sensor I didn’t get yet and he wants that value to display on the Gauge Widget. I’m using my own larger sketch as a counter reference to the Blynk DOCs, but so far this is my best understanding of things;
BLYNK_WRITE is only used when hardware is to receive value(s) from server/app
When simply forwarding values from hardware to server/app, only Blynk.virtualWrite(Vpin, variableWithValue); is needed
You can simply update your Gauge with Blynk.virtualWrite() whenever you want in your sketch. Thus, your hardware “pushes” data to server/app.
And you can also keep your Gauge updated by “pulling” data from hardware: implement BLYNK_READ function which will be triggered according to your widget settings.
BLYNK_WRITE is about sending data from app to your hardware (say, with a Button widget).
In value widgets you can set frequencies of >= 1 second instead of ‘PUSH’
This however will make the app trigger a function called BLYNK_READ(vPin) on your hardware which you need to implement yourself. Then you can define what is to happen at the given frequency!
Say you have a value widget that you want it to display the return value of the function millis()
Set a value widget to pin V1, with frequency 5 seconds. This will cause the above function to be called every 5 seconds for the time that you are inside of the blynk app and at the project using said widget. And you will se something like this in your value widget every 5 seconds
5000
10000
15000
20000
25000
Etc
When you leave the project or blynk app (correct me someone if I’m wrong here) no more calls are made to the BLYNK_READ function until you reopen your project. Effectively reducing strain on your hardware.
I’d use this in intense applications, there is no need for hardware updating your blynk widgets with value s if you are not logging data/watching the app/project.