GPIO16, deep sleep and pin interrupt

All ESP8266 boards running MicroPython.
Official boards are the Adafruit Huzzah and Feather boards.
Target audience: MicroPython users with an ESP8266 board.
Post Reply
User avatar
devnull
Posts: 394
Joined: Sat Jan 07, 2017 1:52 am
Location: Singapore / Cornwall
Contact:

GPIO16, deep sleep and pin interrupt

Post by devnull » Wed Feb 22, 2017 2:50 am

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 ??

User avatar
deshipu
Posts: 1348
Joined: Thu May 28, 2015 5:54 pm

Re: GPIO16, deep sleep and pin interrupt

Post by deshipu » Wed Feb 22, 2017 9:02 am

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.

User avatar
devnull
Posts: 394
Joined: Sat Jan 07, 2017 1:52 am
Location: Singapore / Cornwall
Contact:

Re: GPIO16, deep sleep and pin interrupt

Post by devnull » Wed Feb 22, 2017 10:51 am

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 !

BetterAutomations
Posts: 15
Joined: Mon Mar 20, 2017 10:22 pm

Re: GPIO16, deep sleep and pin interrupt

Post by BetterAutomations » Fri Apr 21, 2017 3:24 am

Any chance you can post a schematic of that? May be useful for me.

User avatar
devnull
Posts: 394
Joined: Sat Jan 07, 2017 1:52 am
Location: Singapore / Cornwall
Contact:

Re: GPIO16, deep sleep and pin interrupt

Post by devnull » Sun Apr 23, 2017 1:08 pm

Hi;

It's pretty simple but works just fine:

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


Cheers

Post Reply