Chat freely about anything...

User avatar
By Marcus Wahren
#72677 Hi, I'm new here. Sorry if I'm in the wrong thread.

I'm building a battery powered esp-12 button which I'm going to put into deep sleep.

My plan is to use the button to reset my esp and reboot it and next button press will just add a number to a counter (and continue for every button press) until it goes back into deep sleep (20 sec after last button press or so.)

Now I need something to switch my button function from grounding the reset pin while in deep sleep and to ground any other io pin whiles it is booted.

Anyone know of something like that except a coil relay? I want something small..
User avatar
By dataguy
#72882 Hi Marcus

I think this is what you want, it just uses an extra resistor.

Connect both sides of the switch to gpio pins, say 4 and 5, with 5 connected to reset and 4 connected to a resistor to ground (say 4.7 kohm). Then the following may work.

Just before going to sleep set pin 4 output low and pin 5 to input. In this state the reset pin is held high by its internal pullup, and pin 4 will act as a ground.

Pushing the button will ground the reset (via pin 4) forcing the wake up event.
Once awake the first thing your code should do is to set pin 5 output high and pin 4 to input.
Pushing the button will then set pin 4 to high allowing your count of button pushes.

After your 20 second timeout go up to para 3, Just before go.. . etc.

Hope this helps

Best Regards

picclock