get_wake_status() with Deep Sleep shield



  • I'm trying to figure out the logic of the get_wake_status() function after going for a deep sleep or hard reset.

    I assume that according to the code of the deepsleep library, the wake value from the returned dictionary would be different depending on wether it's a boot from power on or after the timer has expired, right?

    However, I always get a value of 16, no matter what.

    Has anyone tested this functionality?



  • @rskoniec Thanks, it helped debugging. If I unplug the power completely it shows the POWER_ON_WAKE, but if I do a manual reset (button pressed) it says TIMER_WAKE. I reckon it's a bit confusing.

    I couldn't see the values after connecting the USB and reconnecting to the console, so I assumed a manual reset would be treated as a POWER_ON_WAKE.



  • Did you try something like this?

    from deepsleep import DeepSleep
    
    ds = DeepSleep()
    
    # get the wake reason and the value of the pins during wake up
    wake_s = ds.get_wake_status()
    print(wake_s)
    
    if wake_s['wake'] == deepsleep.PIN_WAKE:
        print("Pin wake up")
    elif wake_s['wake'] == deepsleep.TIMER_WAKE:
        print("Timer wake up")
    else:  # deepsleep.POWER_ON_WAKE:
        print("Power ON reset")
    

    https://docs.pycom.io/chapter/datasheets/boards/deepsleep/api.html



Pycom on Twitter