Wake-Up Pin Callback

Is there a callback function that gets triggered when the wake-up pin is actioned?

What would be the best way to handle a wake-up event?

@LXCOR, if you are waking a deep sleeping device with the wkp pin then the device will reset on wake. No callback.

@peekay123 when I use a pin different then reset pin to wake up the device (ie A0) it doesn’t run setup after it wakes up as in a normal reset.

This is my line of code:

System.sleep(WAKEUP_PIN, RISING);

This is from the docs:

System.sleep(uint16_t wakeUpPin, uint16_t edgeTriggerMode, long seconds) can be used to put the entire device into a stop mode with wakeup on interrupt or wakeup after specified seconds. In this particular mode, the device shuts network subsystem and puts the microcontroller in a stop mode with configurable wakeup pin and edge triggered interrupt or wakeup after the specified seconds. When the specific interrupt arrives or upon reaching the configured timeout, the device awakens from stop mode. The device will not reset before going into stop mode so all the application variables are preserved after waking up from this mode. The voltage regulator is put in low-power mode. This mode achieves the lowest power consumption while retaining the contents of SRAM and registers.

@LXCOR, that is STOP mode sleep which, when awakened, will run the code immediately after the sleep command. If you put a System.reset() after the sleep command, it will reset the processor.