Learn How To Make Use Of The imp’s Wake Pin Facility
|Wake Pin(s)||1||1||W||W||N/A||V, W||W|
The Wake pin is not enabled by default. Instead you use the imp API method hardware.pin.configure() to set the pin up for waking. This method must be called before the imp goes into Deep Sleep, like this:
The onPinStateChangeCallback parameter takes a reference to a function that may be triggered when the wake pin is asserted. Waking the imp from deep sleep restarts the Squirrel virtual machine afresh, so the registered callback will not be called. However, the callback will be called if the pin is triggered while the imp is awake.
Once the Wake pin configured, an imp in Deep Sleep will be woken by applying logic high (3V3) to the pin.
You should bear in mind a couple of points when working with an imp’s Wake pin:
The following example code can be run on any imp — we recommend using a breakout board. On power up, it will report its reason for waking:
2020-10-07 13:37:03.961 +01:00: [Server] Device connected 2020-10-07 13:37:04.112 +01:00: [Device] imp woken (but not by wake pin)
The app will now configure the Wake pin and then go into Deep Sleep for 30 minutes. It will restart automatically after that period, but in the meantime you'll see log output like:
2020-10-07 13:37:43.119 +01:00: [Device] Sleeping until 2020-10-07 13:07:42Z 2020-10-07 13:37:43.119 +01:00: [Server] Device disconnected
To wake the imp up, just bridge your board’s 3V3 pin and the Wake pin. The imp will wake and report the fact:
2020-10-07 13:37:03.961 +01:00: [Server] Device connected 2020-10-07 13:37:04.112 +01:00: [Device] imp woken by wake pin
Remove the wire between the 3V3 and Wake quickly: if it’s still connected when the imp sleeps again, the imp will wake immediately.