Need help with syncing Virtual Pins after a reboot

BLYNK_WRITE(VPIN) can’t be called that way. It’s a callback function which is called by the Blynk library whenever the Blynk server notifies the library that a value on the server has changed. It’s not able to be called by you, and even if it was the results would be meaningless without the value being sent by the server.

but adding a delay() function stops ALL code execution. It stops the Blynk library processing inbound messages from the server telling it that the virtual pin value has changed, it stops the Blynk.run() command executing, and it stops the Blynk.syncVirtual() commands from running.

There are possible other solutions to achieve this, but until you clean-up your code as I described above and show your serial output then I’m not going down that path with our discussion.

Pete.

Pete,

I figured it out. I had an issue with a conversion factor multiplying the stored value on the server giving me an inaccurate total.


void flowmeter() {

  total = total + (a* 0.016);
  trip = trip + (a* 0.016);
  dailyTotal = dailyTotal + (a* 0.016);
  weeklyTotal = weeklyTotal + (a* 0.016);
  monthlyTotal = monthlyTotal + (a* 0.016);

 

  Blynk.virtualWrite(V2, total);
  Blynk.virtualWrite(V3, trip);
  Blynk.virtualWrite(V16, dailyTotal);
  Blynk.virtualWrite(V17, weeklyTotal);
  Blynk.virtualWrite(V18, monthlyTotal);

Its working now. Thanks for the help!

1 Like