After much struggling, I managed to get into proper Deep Sleep mode on my Feather. A good friend of mine said it was a problem doing so in CPy, but I was stubborn. We have a sensor that takes readings once per hour and posts to the 'net. It is intended for a long-term, battery-operated application. This breakthrough was the key! I hope this will help someone else.
#Real Deep Sleep on the ESP32-S3 Rev TFT
1 messages · Page 1 of 1 (latest)
Here is the code:
########################################
# Author: spencer_webb_nh
# Date: 18-OCT-2023
#
# DeeperSleeper is the function that gets the ESP32-S3 processor into deep sleep
# whence the current consumption is at an absolute minimum. After a
# the specified delay, in seconds, the system reboots.
#
# This knowledge was hard-earned.
#
# Measured results indicate about 18 uA deep sleep current on an
# Adafruit ESP32-S3 Rev TFT Feather board.
#
# Dependencies:
#
# import time
# import board
# import alarm
# import digitalio
# from digitalio import DigitalInOut, Direction, Pull
#
# The function is called simply:
#
# DeeperSleeper(DeeperSleeper_interval)
#
# No code is executed after the above line.
# The system reboots after DeeperSleeper_interval seconds.
#
# Also, in the interest of minimum battery current usage when the Rev TFT is present,
# but not used in the periodic execution,
# the following line should be place right after the imports:
#
# board.DISPLAY.brightness = 0
#
def DeeperSleeper(SleepTime):
print("DeeperSleeper activated. TFT, I2C, NEO powering down normally.")
# Turn off power to the TFT, I2C bus.
TFTpwr = digitalio.DigitalInOut(board.TFT_I2C_POWER)
TFTpwr.direction = digitalio.Direction.OUTPUT
TFTpwr.value = 0
# Turn off power to the NeoPixel.
NEOpwr = digitalio.DigitalInOut(board.NEOPIXEL_POWER)
NEOpwr.direction = digitalio.Direction.OUTPUT
NEOpwr.value = 0
print("")
# Create a an alarm that will trigger SleepTime seconds from now.
time_alarm = alarm.time.TimeAlarm(monotonic_time=time.monotonic() + SleepTime)
# Exit the program, and then deep sleep until the alarm wakes us.
alarm.exit_and_deep_sleep_until_alarms(time_alarm)
# Does not return, so we never get here.
#
# Test code for this function:
#
# print ("Going into deep sleep in 5 seconds for 15 seconds...")
# time.sleep(5)
# DeeperSleeper(15)
#
# buh-bye
############################################
Here is the Git Gist: https://gist.github.com/KineticPrecision/5ba9bbf7cc076f70ba2776146510acc8
Gist
Real Deep Sleep via Circuit Python on the ESP32-S3 - DeeperSleeper.py