I have a circuit designed that has both a 3V and 5V rail, with small sub-circuits hanging off them, along with an ESP-12-Q being used as the brains with custom firmware.
What I want to add is a switch that acts the following manner: -
- If the ESP-12 is OFF, pressing the switch will turn it on (and will also turn on the 5V and 3V slave rails for everything else)
- If the ESP-12 is ON, pressing the switch briefly will merely register as an input (GPIO pulled high or low)
- If the ESP-12 is ON, holding the switch for at least 3 seconds will turn the ESP-12 off, and also everything else
I'm having a little trouble thinking of a way to achieve this. So far my options I've considered are: -
- Make use of deep sleep - This will require hooking the switch through a transistor with the base hooked up to one of the GPIO's. When the transistor is saturated (brought HIGH when ESP-12 is on), it connects the switch to another GPIO and I can programatically detect length of presses. When the transistor is disabled (when the ESP-12 is deep-sleeping through a pull-down perhaps) it connects the switch to the RESET (may need TWO transistors?). I'd also need another two transistors to enable/disable the 3V and 5V rails (also connected to the same GPIO)
- Do something similar with the ENABLE pin instead?
- Do it with the VCC pin?
Are there any elegant solutions to this? I'm a programming person rather than a hardware person but I'm interested in either approach (and thus I'm rusty on what hardware is out there). My board is also teensy tiny so I'm trying to save space on useless components.
Thanks