Deep Sleep with MicroPython

  • Hi, I'd like to press the M5 button on my M5StickC-Plus, do something, turn it off/deep sleep and turn it back on with the 'M5' button, as it is easily accessible. Basically I think this is how one of those Dash buttons used to work.

    I tried with:


    The screen turns off, but the device seems very much alive (I tried issuing commands from the REPL) and, when unplugged, completely discharges in a short period of time (maybe a few hours?)

    Is there a way to do this? I saw there may be something for Arduino, not sure if it works reliably, but I'd be willing to port my code to Arduino to have this functionality.

  • Hello @koichirose

    here is how I managed to get M5StickC Plus into deep sleep using MicroPython:

    p37 = machine.Pin(37, mode = machine.Pin.IN, pull = machine.Pin.PULL_UP)
    p37.irq(trigger = machine.Pin.WAKE_LOW, wake = machine.DEEPSLEEP)

    It wakes up from deep sleep either after 20 seconds or when button A is pressed.