I have a button with two isolated tracks. I want to be able to wake up esp from deepSleep with this button, and also detect that it was clicked. So i can't connect it to reset, because esp won't work if i don't release a button. And if it's not at deepSleep, it will reset, and i don't want it. How to do this?
-
Can you post code that you have so far? Also, what do you mean by "two isolated tracks"?– MichaelTCommented Oct 14, 2018 at 18:07
-
Connect the button, with a pull-up to a GPIO. Also connect the button via a small capacitor to the reset pin. The arduino boards use the same trick to reset the ATMega328 via the USB to serial chips DTR-pin.– GerbenCommented Oct 14, 2018 at 18:18
-
I don't have any code that would relate to this functionality yet. By "two isolated tracks" i mean that this button has 4 pins, and 2 paths are isolated, so you can connect two separate things to same button. One path will wake up ESP, and second will be connected to one of GPIOs. Will thing with capacitor also reset it when it's running? I want it only to reset once at sleep, and don't do it while working.– TheLastGimbusCommented Oct 14, 2018 at 18:33
-
Could you please draw me it in paint or something?– TheLastGimbusCommented Oct 15, 2018 at 21:00
-
Possible duplicate of Deep Sleep Reset with Shock Sensor– Juraj ♦Commented Oct 25, 2019 at 4:19
2 Answers
Use some other pin to hold RESET HIGH or to disconnect the button from RESET while the esp8266 is not running.
simulate this circuit – Schematic created using CircuitLab
I asked on EE SE for the missing part of the circuit.
You can't stop deepSleep, all you can do is reset the board so connect the button to the reset pin and make the appropiate set-up:
- Connect a pullup resistor (10k) in RST
- Connect the button from RST to GND
When you push, RST has GND so the ESP gets reseted.
Remember that deepsleep only works for about an hour so you have to contemplate this situation, too, maybe with a static variable...
EDIT Thanks Juraj for the comment: "from SDK API "system_deep_sleep(0): there is no wakeup timer; in order to wake up, connect a GPIO to pin RST; the chip will wake up by a falling-edge on pin RST."
-
from SDK API "system_deep_sleep(0): there is no wakeup timer; in order to wake up, connect a GPIO to pin RST; the chip will wake up by a falling-edge on pin RST."– Juraj ♦Commented Oct 16, 2018 at 12:21
-
the reference assumes the esp8266 is used as 'coprocessor' for a main MCU, because it wasn't designed to be used standalone. so the mentioned GPIO pin is a pin of the main MCU– Juraj ♦Commented Oct 16, 2018 at 13:46