Skip to main content


Returns a constant indicating the reason why the imp was woken




Integer — a Wake-up Code


This method tells you what event caused the imp to wake up. The integer code it returns will be one of the following constants. You should note that not all of these constants are valid for a given type of imp.

Code Constant Value Description
WAKEREASON_POWER_ON 0 Powered on (cold boot)
WAKEREASON_TIMER 1 Woken after sleep time expired
WAKEREASON_SW_RESET 2 Restarted due to a software reset (eg. with imp.reset()) or an out-of-memory error occurred
WAKEREASON_PIN 3 Woken by wakeup pin going high
WAKEREASON_NEW_SQUIRREL 4 Restarted due to new Squirrel code being loaded
WAKEREASON_SQUIRREL_ERROR 5 Restarted due to a Squirrel run-time error
WAKEREASON_NEW_FIRMWARE 6 Restarted due to a firmware upgrade (from impOS™ 30)
WAKEREASON_SNOOZE 7 Woken from a snooze-and-retry event (from impOS 30)
WAKEREASON_HW_RESET 8 Restarted by RESET_L pin (imp003 and above only; from impOS 30)
WAKEREASON_BLINKUP 9 Restarted following a reconfiguration by BlinkUp (from impOS 32)
WAKEREASON_SW_RESTART 10 Restarted by server.restart() (from impOS 36)
WAKEREASON_POWER_RESTORED 11 VBAT powered during a cold start (from impOS 40)

The values assigned to the constants may change in a future impOS release.

Module-specific Information


Power cellular radio brownouts at start-up are currently reported as reason 11.


This method is not available on the imp005 and is not expected to be added.

Release-specific Information

impOS 36

From release 36, calling server.restart() on the device will result in hardware.wakereason() reporting the constant WAKEREASON_SW_RESTART, even if the reboot results in new Squirrel application code being downloaded and run. In addition, out-of-memory errors will be reported as WAKEREASON_SW_RESET, again whether new Squirrel is downloaded after the restart or not.

impOS 32

The value WAKEREASON_BLINKUP is only available in release 32 and later. If there is new Squirrel code available after restarting due to a BlinkUp, the wake reason will be overridden with WAKEREASON_NEW_SQUIRREL.

impOS 30

The values WAKEREASON_NEW_FIRMWARE and WAKEREASON_SNOOZE are only provided in impOS release 30 and above. In previous releases, both of these causes were categorized as WAKEREASON_TIMER.

The value WAKEREASON_HW_RESET is also only available in impOS release 30 and later. It is only relevant to the imp003 module; the imp001 and imp002 do not have a hardware reset pin. In prior impOS releases, WAKEREASON_HW_RESET was presented as WAKEREASON_POWER_ON.

Example Code

A simple function which uses hardware.wakereason() to display the reason why an imp restarted.