Reboot a digital Pin assigned button

Hey everybody !

I am using 12 button to turn off 12 relays. It is switch buttons, so they remain OFF unless I push them back to ON.

But having to turn them back to ON position is a bit tricky…

Is there a way, like with Blynk.virtualWrite(V27," "); to turn ON/OFF switches ?

So that I put this code into my setup loop and It will automatically switch all my button to ON when a reboot the ESP ?

Thanks a lot !

Yes, you’d write a zero to each switch widget to turn it off.
Doing 12 virtualWrites immediately after each other may cause an issue, so do them in blocks with a short delay between each block.
You’d probably need to do a digitalWrite to each pin as well.

I assume that you’re using an ESP32 so that you have enough pins?

Pete.

1 Like

Thanks pete.

Sorry I forgot the most important …

My 12 buttons are linked to Digital Pins. So they cant be changed with a virtualWrite right ?

I am actually using 12 ESP 8266.

Are you using 12 different devices, with 12 different Auth codes, in your project?

Pete.

Exactly.

But each ESP8266 will do the same thing.

They only deal with one button, always on D0. Only the device target changes.

When I will power off/on the main power supply, all the ESP will turn off, then reboot.

That why I want the setup of each ESP to have something that automatically switch ON all the differents buttons that I could have turn OFF.

So If I do that :

pinMode(16,OUTPUT);
digitalWrite(16,HIGH);

on each of my 12 setup loops codes, all my UI buttons will turn ON a the boot right ?

I also would like them to change color when something else is trigerring (so even if I am not pushing them OFF !). I would like to use Blynk.setProperty, but since its digitals pins buttons, It wont work I guess ?

Thanks again

You need to use virtual pins, they give you everything you need.

Pete.

But a tiny bit more coding as I expected =p

Lets get to work.

Thanks pete !

Not that much more.

GPIO16 (Pin D0 on the NodeMCU) isn’t such a good choice of pin.
If you are able to change it (assuming that its not a pre-built PCB) then there are better choices:

Pete.

So its D1 D2 D5 D6 D7. Not a lot left Oo

Thanks pete !