machine — functions related to the board

The machine module contains specific functions related to the board.

Miscellaneous functions

machine.unique_id()

Returns a byte string with a unique idenifier of a board/SoC. It will vary from a board/SoC instance to another, if underlying hardware allows. Length varies by hardware (so use substring of a full value if you expect a short ID). In some MicroPython ports, ID corresponds to the network MAC address.

machine.time_pulse_us(pin, pulse_level, timeout_us=1000000)

Time a pulse on the given pin, and return the duration of the pulse in microseconds. The pulse_level argument should be 0 to time a low pulse or 1 to time a high pulse.

The function first waits while the pin input is different to the pulse_level parameter, then times the duration that the pin is equal to pulse_level. If the pin is already equal to pulse_level then timing starts straight away.

The function will raise an OSError with ETIMEDOUT if either of the waits is longer than the given timeout value (which is in microseconds).

Constants

machine.IDLE
machine.SLEEP
machine.DEEPSLEEP

irq wake values

machine.POWER_ON
machine.HARD_RESET
machine.WDT_RESET
machine.DEEPSLEEP_RESET
machine.SOFT_RESET

reset causes

machine.WLAN_WAKE
machine.PIN_WAKE
machine.RTC_WAKE

wake reasons