Using the same button for deep sleep and waking from deep sleep

william.ferguson.au
Posts: 107
Joined: Wed Jan 02, 2019 8:55 am

Using the same button for deep sleep and waking from deep sleep

Postby william.ferguson.au » Wed Jun 05, 2019 3:49 am

I am using a button to put the ESP32 into deep sleep and have also configured that button to wake the ESP32 from deep sleep.

The problem is that when powered up, unless the button press is extremely quick, the ESP32 will go into deep sleep and then immediately wake up.

What options do I have to ensure that

Code: Select all

  esp_sleep_enable_ext0_wakeup(POWER_BT, LOW);  // Allow Power button to wake us up from deep sleep.

isn't triggered by the same button press that put the ESP32 into deep sleep?

boarchuz
Posts: 606
Joined: Tue Aug 21, 2018 5:28 am

Re: Using the same button for deep sleep and waking from deep sleep

Postby boarchuz » Wed Jun 05, 2019 5:07 am

On button press, wait for button release. Then sleep.

You may need to add a brief delay after the release for debouncing, but I doubt it will go to sleep fast enough for that to be necessary.

william.ferguson.au
Posts: 107
Joined: Wed Jan 02, 2019 8:55 am

Re: Using the same button for deep sleep and waking from deep sleep

Postby william.ferguson.au » Wed Jun 05, 2019 12:24 pm

Thanks, that was what I was considering, glad to have it confirmed.
And it seems to have worked a treat.

Who is online

Users browsing this forum: No registered users and 90 guests