Documentation: pycom module 'machine'

  • Just trying to understand the reset conditions for the machine and noticed that the docs are incomplete in relation to reset causes.
    When I run print(machine.reset_cause()) I am returned an interger value. The list at Reset Causes does not have reset listed against their correspoding integer values AND there is no explanation of the the 'methods'; e.g. is machine.HARD_RESET correspond to both machine.reset() and a button push?

    Thank you for your time

  • @goldfishalpha You're right! Sorry for the confusion and good catch (I'll edit my previous post so as not to confuse future readers)

  • @Colateral Thank you for your response. I am just thinking along the lines of logging reset reasons for my device.
    e.g. If I get a WDT reset at a certain time, check and save the reason on restart of system. Would be handy for analysing software/system stability.
    However, I have just noticed that a reset button press returns 0 on a machine.reset_cause().
    Will keep testing as I go along.

  • @alexpul Thank you. It appears as if counting starts from 0 though.
    To confirm, I spotted that one can run help(machine) to get a list..
    PWRON_RESET -- 0
    HARD_RESET -- 1
    WDT_RESET -- 2
    SOFT_RESET -- 4
    PWRON_WAKE -- 0
    PIN_WAKE -- 1
    RTC_WAKE -- 2
    ULP_WAKE -- 3

  • machine.HARD_RESET never happens: nor at push button(POWER RESET) and never on machine.reset() (that actually is tided to WDT_RESET)

    When this cause is happening?

  • If you do machine.reset_cause() then the numbers correspond to the reset causes list
    0 - machine.PWRON_RESET
    1 - machine.HARD_RESET
    2 - machine.WDT_RESET
    3 - machine.DEEPSLEEP_RESET
    4 - machine.SOFT_RESET
    5 - machine.BROWN_OUT_RESET

    If you do machine.wake_reason() then the numbers correspond to the wake reasons list
    0 - machine.PWRON_WAKE
    1 - machine.PIN_WAKE
    2 - machine.RTC_WAKE
    3 - machine.ULP_WAKE

Log in to reply

Pycom on Twitter