ESP32 wakes up immediately from deep sleep indicating GPIO change

ddenker
Posts: 1
Joined: Sat Aug 19, 2023 12:25 am

ESP32 wakes up immediately from deep sleep indicating GPIO change

Postby ddenker » Sat Aug 19, 2023 12:44 am

Hi I am having a problem that when I go into deep sleep, the ESP32 immediately wakes up saying that a pulled down I/O pin connected to as push button has gone high when it has not. I have written test code with a standard interrupt routine to make sure the external hardware is acting properly and it is. Below is the code I use to go into deep sleep. Note that I want to wake up when the timer expires or the button is pushed. Also, note that while the ESP32 is awake I read from the pin to detect a long press. Thanks for any help you can give. This is on an ESP32 Devkit C.

Code: Select all

#define DEFAULT_WAKEUP_PIN (35)
void do_deep_sleep(int64_t time_to_sleep_in_us)
{
int result;
gpio_config_t config;
printf("Going to sleep for %lld us\n",time_to_sleep_in_us); fflush(stdout);
result = esp_sleep_enable_timer_wakeup(time_to_sleep_in_us);
uart_wait_tx_idle_polling(CONFIG_ESP_CONSOLE_UART_NUM);
reset_gpio(DEFAULT_WAKEUP_PIN);
uint64_t mask = 1;
mask <<= DEFAULT_WAKEUP_PIN;
config.pin_bit_mask = mask;
config.mode = GPIO_MODE_INPUT;
config.pull_up_en = GPIO_PULLUP_DISABLE;
config.pull_down_en = GPIO_PULLDOWN_DISABLE;
config.intr_type = GPIO_INTR_DISABLE;
ESP_ERROR_CHECK(gpio_config(&config));
ESP_ERROR_CHECK(esp_sleep_enable_ext0_wakeup((gpio_num_t)DEFAULT_WAKEUP_PIN,1));
/* Enter sleep mode */
if (result == ESP_OK)
    esp_deep_sleep_start();
esp_sleep_disable_wakeup_source(ESP_SLEEP_WAKEUP_TIMER);
}

User avatar
jiqz--
Posts: 9
Joined: Thu Aug 17, 2023 12:39 pm

Re: ESP32 wakes up immediately from deep sleep indicating GPIO change

Postby jiqz-- » Sun Aug 20, 2023 11:40 pm

What is the value you pass to the

Code: Select all

do_deep_sleep
fuction when you call it?

Also, GPIO35 is an input-only pin so you don't need to give it any internal pull up or down configuration:
GPIO pins 34-39 are input-only. These pins do not feature an output driver or internal pull-
up/pull-down circuitry

Who is online

Users browsing this forum: Baidu [Spider] and 124 guests