Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ESP32S3 Sleep Behaviour using PinAlarm #5973

Closed
atctwo opened this issue Feb 2, 2022 · 1 comment · Fixed by #6144
Closed

ESP32S3 Sleep Behaviour using PinAlarm #5973

atctwo opened this issue Feb 2, 2022 · 1 comment · Fixed by #6144
Assignees
Labels
bug esp32-s3 espressif applies to multiple Espressif chips power
Milestone

Comments

@atctwo
Copy link

atctwo commented Feb 2, 2022

CircuitPython version

Adafruit CircuitPython 7.2.0-alpha.1-278-ga04cd6444 on 2022-02-02; ESP32-S3-DevKitC-1-N8R2 with ESP32S3

Code/REPL

import alarm
import board
import digitalio
import neopixel
import time

np = neopixel.NeoPixel(board.NEOPIXEL, 1)

while True:
    np[0] = (50, 50, 50)
    time.sleep(1)
    np[0] = (0, 0, 0)

    # Create a an alarm that will trigger 5 seconds from now.
    time_alarm = alarm.time.TimeAlarm(monotonic_time=time.monotonic() + 5)
    pin_alarm = alarm.pin.PinAlarm(pin=board.IO2, value=False, pull=True)

    # Do a light sleep until the alarm wakes us.
    print("sleeping...")

    alarm.light_sleep_until_alarms(pin_alarm, time_alarm)
    #alarm.exit_and_deep_sleep_until_alarms(time_alarm, pin_alarm)

    print("woken up by", alarm.wake_alarm)

Behavior

There are no error messages, although PinAlarm doesn't appear to wake the ESP32 up. The ESP32 always prints "sleeping..." and goes into sleep mode with no issues. After sleeping, when using light sleep, and the button connected to the pin is pressed, nothing happens. When using deep sleep, the "fake deep sleep" message on the serial console appears when the button is pressed, then it stays in sleep mode (the code doesn't re-run, and nothing else happens). The message it prints is:

Press any key to enter the REPL. Use CTRL-D to reload.
Pretending to deep sleep until alarm, CTRL-C or file write.

Description

No response

Additional information

  • the last commit that sleep seems to work without problems for me is 993e51e
  • the next commit after that (f6cf15d) crashes the ESP32S3 on boot, which happens for each commit until 8bae6af, on which the sleep problems occur
  • I guess whatever causes this problem was introduced between 993e51e and 8bae6af?
  • I'm using switches with external pull-down resistors, but i've also tried this with internal pull-up resistors
  • From what I can tell, disconnecting USB from a computer / preventing "fake sleep" doesn't help.
  • The example above uses a TimeAlarm at the same time as PinAlarm. TimeAlarm wakes the ESP32 up fine, and PinAlarm doesn't work whether a TimeAlarm is set up or not
    • when I was testing the code with a PinAlarm and a TimeAlarm together, and the pull ups on the PinAlarm incorrectly configured (with internal pullups and external pull downs), TimeAlarm did some strange things. It wouldn't wake up at the specified time, but when the PinAlarm pin was pressed, it wouldn't wake up straight away, but would then wake up at the specified time (or immediately if that time has already passed)
@atctwo atctwo added the bug label Feb 2, 2022
@tannewt tannewt added esp32-s3 espressif applies to multiple Espressif chips power labels Feb 3, 2022
@tannewt tannewt modified the milestones: Long term, 7.2.0 Feb 3, 2022
@dhalbert dhalbert modified the milestones: 7.2.0, 7.x.x Feb 14, 2022
@tannewt tannewt self-assigned this Mar 7, 2022
@tannewt
Copy link
Member

tannewt commented Mar 11, 2022

Looks like the wake from pin failure in light sleep or fake deep sleep was an IDF bug that has been fixed: espressif/esp-idf@41e452e

I'll update the IDF to fix it.

Deep sleep is broken as described in #6090

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug esp32-s3 espressif applies to multiple Espressif chips power
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants