Skip to content

SWAN R5: Sleep modes are broken #8977

Open
@bablokb

Description

@bablokb

CircuitPython version

Adafruit CircuitPython 8.2.9 on 2023-12-06; Swan R5 with STM32L4R5ZIY6

Code/REPL

def work():
  led.value = 1
  time.sleep(LED_TIME)
  led.value = 0

while True:
  # do some work
  work()

  # sleep
  if MODE == SPIN:
    next = time.monotonic() + INT_TIME
    while time.monotonic() < next:
      continue
  elif MODE == SLEEP:
    print(f"(normal) sleep for {INT_TIME}s")
    time.sleep(INT_TIME)
  elif MODE == LIGHT_SLEEP:
    print(f"(light) sleep for {INT_TIME}s")
    time_alarm = alarm.time.TimeAlarm(monotonic_time=time.monotonic()+INT_TIME)
    alarm.light_sleep_until_alarms(time_alarm)
  elif MODE == DEEP_SLEEP:
    print(f"(deep) sleep for {INT_TIME}s")
    time_alarm = alarm.time.TimeAlarm(monotonic_time=time.monotonic()+INT_TIME)
    alarm.exit_and_deep_sleep_until_alarms(time_alarm)

Behavior

With light-sleep, I can see the following current (at 3.6V):
swan-timer-light-sleep

So in light-sleep mode, the SWAN needs about 30mA. When the LED is on and the device sleeps normally (during work()), current is only about 16mA.

Deep-sleep is even more broken:
swan-timer-deep-sleep

You can see that the device tries to switch to deep-sleep, but it wakes up again without actually sleeping (note that this is not fake deep-sleep, there was no USB connection). After wake up, you can see the 16mA during work() again, then the try-to-go-to-deep-sleep-and-fail cycle starts over.

Description

No response

Additional information

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions