Page 1 of 1

GPIO16, deep sleep and pin interrupt

Posted: Wed Feb 22, 2017 2:50 am
by devnull
My device goes into deep sleep and GPIO16 is connected to RESET in order to enable it to wake up.

But I also need to be able to manually wake up the device before the sleep period has expired using a short/long press button interrupt.

The reason is that a short press triggers the device to go into run mode and a long press triggers setup mode.

I cannot use the reset button as this triggers on the rising edge and I don't think it's therefore possible to detect that the reset button is being held down after the system has restarted.

So, can GPIO16 be also set as a pin interrupt that will force the system to wake up before the sleep period expires or is there another way ??

Re: GPIO16, deep sleep and pin interrupt

Posted: Wed Feb 22, 2017 9:02 am
by deshipu
Unfortunately no, in deep sleep most of the chip is powered down to save energy, only the RTC clock and the reset circuit are active.
You could use an additional small low-power microcontroller, such as an attiny, to handle this.

Re: GPIO16, deep sleep and pin interrupt

Posted: Wed Feb 22, 2017 10:51 am
by devnull
Thanks, but fortunately I found a solution.

Previously, I had a button interrupt, that would detect the length of press while running and save the mode to a json file and then reset the system.

Then, during startup I checked this file to get the mode and took the required action.

Now what I am doing is linking GPIO16 to RESET with a capacitor, and GPIO16 is connected to a reset switch which pulls it low.

This has the effect when the button is pressed of sending a pulse to the reset pin causing a reset, while the GPIO16 pin remains low if kept pressed.

Then it is a simple case of detecting whether GPIO16 is low a few seconds after reset and set the required mode.

Tadah !

Re: GPIO16, deep sleep and pin interrupt

Posted: Fri Apr 21, 2017 3:24 am
by BetterAutomations
Any chance you can post a schematic of that? May be useful for me.

Re: GPIO16, deep sleep and pin interrupt

Posted: Sun Apr 23, 2017 1:08 pm
by devnull
Hi;

It's pretty simple but works just fine:

+ 1uf electrolytic > Reset
- 1uf electrolytic > GPIO16
Momentary Switch A > GPIO16
Momentary Switch B > GROUND


Cheers