Virtual Pin Zeroer

It would be really nice to have a button/widget that could set all of the virtual pins in a blynk sketch to zero- it would be nice to be able to do this from the app, but it would be nice if we could call it in our code.

My beef is that if I send a 1 / 0 over bridge every 20 seconds, and pull the plug on the controller that’s sending these values, the receiving controller can get stuck with a 1.

in setup just put:

Blynk.virtualWrite(Vx, 0)

in setup and it zeros all the pins you list.

at least that is what i do… but i am not sure how it relates to your bridge example though…

1 Like

That will definitely work… wish there was an easier way :slight_smile:

@zeeko @Dave1829 let’s say that, I have 2 nodemcu in the 1st one I control 4virtual and 4 physical pins beside I want to control 2nd as well like 1st one is it possible to do that. controlling 2nd one via virtual pins?

You can send virtualWrites as well as digitalWrites over bridge. See the example sketch for details.

UPDATE:

I kind of figured out a hacky way to do this for anyone that’s curious- and this is somewhat local server specific-

If you do a simple one-time for-loop in your BLYNK_CONNECTED portion of your code:

for (int i = 0; i < 100; i++) {
Blynk.virtualWrite(i,0);
}

You can clear out any old values stored in the server. I DEFINITELY don’t recommend doing an i from 0 to 100 on the cloud :innocent: or you’ll likely get the boot.

To further elaborate on my issue, I have several controllers each linked to their own water valve. When they need water, the valve opens, and they send a 1 signal to a far away ESP. The esp is constantly adding up 1’s coming from the rooms, and if they are >0, the water PUMP turns on. If the room doesn’t need water, it sends a 0, and if all of the rooms are NOT requesting water, the pump turns off. If say, one of the rooms gets messed up, the pump might end up running for a very long time- I don’t want that.

So in my code, I have something like, if pump is running for X amount of time, run the for loop code and clear all of the values.

isn’t Blynk.syncVirtual helpful?

@zeeko can you provide basic master and slave codes so I can alternate them