Skip to content

Commit 02ece2b

Browse files
committed
docs/esp32: Document gpio_deep_sleep_hold() function.
Document new `esp32.gpio_deep_sleep_hold()` function and explain how to use this in quickref to retain pin configuration during deep-sleep.
1 parent 87dadd3 commit 02ece2b

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

docs/esp32/quickref.rst

+19
Original file line numberDiff line numberDiff line change
@@ -560,6 +560,25 @@ deep-sleep mode::
560560

561561
Non-RTC GPIO pins will be disconnected by default on entering deep-sleep.
562562

563+
Pin configuration on *any* output-capable pin - including output level - can be
564+
retained during deep-sleep by enabling pad hold during deep-sleep and
565+
configuring a pin with pad hold::
566+
567+
from machine import Pin, deepsleep
568+
import esp32
569+
570+
# enable pad hold in deep-sleep
571+
esp32.gpio_deep_sleep_hold(True)
572+
573+
opin = Pin(2, Pin.OUT, value=1, hold=True) # hold output level
574+
ipin = Pin(21, Pin.IN, Pin.PULL_UP, hold=True) # hold pull-up
575+
576+
# put the device to sleep for 10 seconds
577+
deepsleep(10000)
578+
579+
The pin configuration - including the pad hold - will be retained on wake from
580+
sleep. See :ref:`Pins_and_GPIO` above for a further discussion of pad holding.
581+
563582
SD card
564583
-------
565584

docs/library/esp32.rst

+5
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,11 @@ Functions
3030
or a tuple/list of valid Pin objects. *level* should be ``esp32.WAKEUP_ALL_LOW``
3131
or ``esp32.WAKEUP_ANY_HIGH``.
3232

33+
.. function:: gpio_deep_sleep_hold(enable)
34+
35+
Configure whether pin configuration is retained during deep-sleep mode for
36+
held pads. *enable* should be a boolean value.
37+
3338
.. function:: raw_temperature()
3439

3540
Read the raw value of the internal temperature sensor, returning an integer.

0 commit comments

Comments
 (0)