Isolate GPIO (not RTC) during deep-sleep

davdav
Posts: 208
Joined: Thu Nov 17, 2016 2:33 pm

Isolate GPIO (not RTC) during deep-sleep

Postby davdav » Wed Jun 05, 2019 11:53 am

Hi everybody,

I have the necessity to isolate some GPIO (not RTC) like GPIO16, GPIO18, GPIO22 and GPIO23 during deepsleep in ESP32-WROOM32D module.

In my case GPIO22 and GPIO23 are outputs and using

Code: Select all

	gpio_hold_en();
	gpio_deep_sleep_hold_en();
I'm able to fix their status during deep-sleep and wakeup stub.


GPIO16 and GPIO18 are used for I2C bus and have external pull-up resistors. Before entring in deep-sleep should I change them to output mode, set high level and hold their status? Or they are automatically isolated from the external resistors?

ESP_houwenxiang
Posts: 118
Joined: Tue Jun 26, 2018 3:09 am

Re: Isolate GPIO (not RTC) during deep-sleep

Postby ESP_houwenxiang » Wed Jun 12, 2019 2:10 am

Hi, davdav
You do not need to reconfigure the GPIO mode before entering deep-sleep. When `gpio_deep_sleep_hold_en` is called, all digital GPIOs will remain in their current state. But after the chip wakes up from deep sleep and calls `gpio_deep_sleep_hold_dis`, all digital GPIOs will be reset to the default mode. In this case, you need to reconfigure the GPIO before this function call.

thanks !!
wookooho

davdav
Posts: 208
Joined: Thu Nov 17, 2016 2:33 pm

Re: Isolate GPIO (not RTC) during deep-sleep

Postby davdav » Wed Jun 12, 2019 9:17 am

ESP_houwenxiang wrote:
Wed Jun 12, 2019 2:10 am
Hi, davdav
You do not need to reconfigure the GPIO mode before entering deep-sleep. When `gpio_deep_sleep_hold_en` is called, all digital GPIOs will remain in their current state. But after the chip wakes up from deep sleep and calls `gpio_deep_sleep_hold_dis`, all digital GPIOs will be reset to the default mode. In this case, you need to reconfigure the GPIO before this function call.

thanks !!
Thank you @ESP_houwenxiang,

In practice, if device wakes-up and I DON'T call `gpio_deep_sleep_hold_dis`, digital GPIO (not RTC) inputs should work as before entering in deep-sleep, right? I.e. in my particular case GPIO16 and GPIO18 will still work as I2C bus. Consider that at every start-up (not regarding if it is a wake up from or a power-on) I init the I2C driver.

However, I will do some test in order to understand how it works, because documentation in my opininon is not so clear regarding the "hold" functionality.

thanks

ESP_houwenxiang
Posts: 118
Joined: Tue Jun 26, 2018 3:09 am

Re: Isolate GPIO (not RTC) during deep-sleep

Postby ESP_houwenxiang » Thu Jun 13, 2019 9:39 am

Yes, all states will remain in the state before sleep. the GPIO can not input or output as you wanted. so, `gpio_deep_sleep_hold_dis` should be called if you want I2C bus works.
wookooho

andrewandroid
Posts: 7
Joined: Sat Dec 26, 2020 7:33 am

Re: Isolate GPIO (not RTC) during deep-sleep

Postby andrewandroid » Sat Dec 26, 2020 7:53 am

Hey davdav and ESP_houwenxiang

Thanks for posting details.

I have exactly the same problem, I believe. Did you get this working?

Here's my setup:
I have three non-RTC GPIO pins (16, 17, 18), and I want them to stay HIGH during deep sleep.

I'm using Arduino IDE:
```
// Stop doing PWM.
ledcDetachPin(16);
pinMode(16,OUTPUT);
digitalWrite(16, HIGH);

ledcDetachPin(17);
pinMode(17,OUTPUT);
digitalWrite(17, HIGH);

ledcDetachPin(18);
pinMode(18,OUTPUT);
digitalWrite(18, HIGH);

gpio_hold_en((gpio_num_t) 16);
gpio_hold_en((gpio_num_t) 17);
gpio_hold_en((gpio_num_t) 18);
gpio_deep_sleep_hold_en();
delay(10000);
esp_deep_sleep_start();
```

Problem:
Pin 16 and 17 go to LOW as soon as I call `esp_deep_sleep_start()`. They should stay HIGH.

Did your IDF code work?

I've read a number of other posts about this topic, and I'm not sure what the problem is.

Would really appreciate any help or hints anyone can give.

Thanks,
Andrew

Who is online

Users browsing this forum: Baidu [Spider], Bing [Bot], Google [Bot] and 104 guests