According to the documentation, System.sleep(uint16_t wakeUpPin, uint16_t edgeTriggerMode, long seconds) will wake-up my Electron board if the given pin is wiggled (it says “when the specific interrupt arrives”) or when the timeout has expired. However, I seem to be seeing the Electron board wake-up from sleep on the WKP pin being toggled also, even though I’m specifying D3 as the wakeUpPin (and setting D3 to be an output and set to zero specifically so that I don’t wake up).
WKP Active-high wakeup pin, wakes the module from sleep/standby modes. When not used as a WAKEUP, this pin can also be used as a digital GPIO, ADC input or PWM.
The sleep variation you listed above is a stop mode sleep. When either the time expires or the interrupt pin specified has the indicated condition occur (rising, falling, or change), execution continue after the sleep() function.
The WKP is the only pin that will wake up from deep sleep mode SLEEP_MODE_DEEP. It’s also active high only. When waking up from deep sleep, execution resumes as if reset - you go through setup() again.
Less obvious is that WKP will also wake up a stop mode sleep, active high, as well. This is a bug, and not intended unless the WKP pin is specifically set as the pin to use for sleep stop mode, and edge trigger mode is set to RISING. [BDub]
I’ll raise an issue on the documentation then, 'cos that’s not what it actually states for that function: it says “the specific interrupt” (my italics), not "wakeUpPin or the WKP pin", or “any interrupt”.
May seem petty but this is very important because I’ve now got 100 PCBs wired in the wrong way…
Having the device wake up via the WKP pin when in stop mode sleep is not the intended behavior, and this has been fixed for release in 0.6.0. After 0.6.0, the WKP pin will not wake up the device in stop mode sleep (the variant listed at the top of this thread) unless that is the pin specifically stated in the sleep call.
After 0.6.0 the WKP pin will only have any effect in standby mode, aka SLEEP_MODE_DEEP.
I hope that clarifies things, and means you can use those 100 PCBs and puts your mind to rest.
Thanks for that, but it’s not the first time that earlier responses get superceeded by later ones, so I’d just like to have the correct, non-confusing statement explicitly stated as “last-word”
But this way it seems confusing to say it does something in one mode but in the next sentence stating it will onlyhave any effect in standby mode (only seems to exclude other modes)
I can interpret, but interpretation should not be required. I want to be able to just take it as said (speaking for other members viewpoints too - I hope).