From 5887dfeea6a4899e8f30ac1435159d760a985642 Mon Sep 17 00:00:00 2001 From: Jonathan Hogg Date: Mon, 7 Mar 2022 09:15:05 +0000 Subject: [PATCH] docs/esp32/quickref: Refine deep-sleep power-saving notes. This attempts to better explain how pull-ups and pull-downs operate in deep-sleep mode. --- docs/esp32/quickref.rst | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/docs/esp32/quickref.rst b/docs/esp32/quickref.rst index 56e765536e..0778425f2f 100644 --- a/docs/esp32/quickref.rst +++ b/docs/esp32/quickref.rst @@ -186,8 +186,7 @@ Notes: * Pins 34-39 are input only, and also do not have internal pull-up resistors -* The pull value of some pins can be set to ``Pin.PULL_HOLD`` to reduce power - consumption during deepsleep. +* See :ref:`Deep_sleep_Mode` for a discussion of pin behaviour during sleep There's a higher-level abstraction :ref:`machine.Signal ` which can be used to invert a pin. Useful for illuminating active-low LEDs @@ -508,6 +507,8 @@ See :ref:`machine.WDT `. :: wdt = WDT(timeout=5000) wdt.feed() +.. _Deep_sleep_mode: + Deep-sleep mode --------------- @@ -527,15 +528,28 @@ Notes: * Calling ``deepsleep()`` without an argument will put the device to sleep indefinitely * A software reset does not change the reset cause -* There may be some leakage current flowing through enabled internal pullups. - To further reduce power consumption it is possible to disable the internal pullups:: - p1 = Pin(4, Pin.IN, Pin.PULL_HOLD) +Some ESP32 pins (0, 2, 4, 12-15, 25-27, 32-39) are connected to the RTC during +deep-sleep and can be used to wake the device with the ``wake_on_`` functions in +the :mod:`esp32` module. The output-capable RTC pins (all except 34-39) will +also retain their pull-up or pull-down resistor configuration when entering +deep-sleep. - After leaving deepsleep it may be necessary to un-hold the pin explicitly (e.g. if - it is an output pin) via:: +If the pull resistors are not actively required during deep-sleep and are likely +to cause current leakage (for example a pull-up resistor is connected to ground +through a switch), then they should be disabled to save power before entering +deep-sleep mode:: - p1 = Pin(4, Pin.OUT, None) + from machine import Pin, deepsleep + + # configure input RTC pin with pull-up on boot + pin = Pin(2, Pin.IN, Pin.PULL_UP) + + # disable pull-up and put the device to sleep for 10 seconds + pin.init(pull=None) + machine.deepsleep(10000) + +Non-RTC GPIO pins will be disconnected by default on entering deep-sleep. SD card -------