Skip to content

Wake up from power.deep_sleep() via UART incoming data? #127

Closed
@microbit-carlos

Description

@microbit-carlos

The main way for CLI/Desktop tools/editors to interact with MicroPython is via serial REPL. When the board is asleep, it will stop responding to serial, so with a programme like this one, the only option is to reflash the micro:bit with MicroPython, as it won't respond to most tools or desktop editors from serial anymore:

import power
power.deep_sleep()

At the time of writing, due to issue #126, the programme above won't go to sleep, but to replicate we can simply add Button A as the only wake up source:

from microbit import *
import power

while True:
    power.deep_sleep(wake_on=button_a)
    display.show(Image.SURPRISED)
    sleep(500)

While this could be obvious for a small programme that basically sleeps, the same can be trigger with other "normal" programmes that might go to sleep for any amount of time, like with data logging.

Should the board wake up via serial?

If the answer is "yes", it could be:

  1. implicitly configured and unchangeable
  2. a new parameter with a default value, e.g. power.deep_sleep(serial_wake=True)
  3. another argument option for the wake_on parameter, i.e. power.deep_sleep(wake_on=(pin1, serial))
    • Should in this case the default be power.deep_sleep(wake_on=serial)?

@dpgeorge

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions