-->
Page 1 of 2

nodemcu Possible to use flash button(D3, gpio0) in setup?

PostPosted: Sat Sep 02, 2017 3:56 am
by wcat
Does anyone know what holding the flash button during reset does? I know that the flash button is tied to D3 or gpio0 and that I can use it as button input in loop. I would like to hold it during reset and do something else but does not appear to work or maybe I am not using it correctly.

can the state of the flash button be used during setup?

thanks

Re: nodemcu Possible to use flash button(D3, gpio0) in setup

PostPosted: Sat Sep 02, 2017 10:25 am
by martinayotte
GPIO0 can't be held LOW during setup, otherwise the ESP will go in "upload" mode.
But you can add a delay loop in setup(), let say 5 seconds, and check if button is been pressed AFTER power-up/reset, if it is, then act accordingly.

Re: nodemcu Possible to use flash button(D3, gpio0) in setup

PostPosted: Tue Sep 05, 2017 8:32 am
by ian
There is no need for a delay in setup(). GPIO0 can go low immediately in setup(). But not before.

Re: nodemcu Possible to use flash button(D3, gpio0) in setup

PostPosted: Tue Sep 05, 2017 9:28 am
by martinayotte
If the GPIO0 is read right at the beginning of setup(), there not much chance that a human can press the button that fast, so it is easier to add a delay, if 5 seconds is too much for you, at least make it 1 seconds.