Simple Sleep Questions

I have a couple quick questions that I am hoping one of you can help me with. They have to do with sleep and I am not seeing the answers clearly laid out in the documentation or on these forums. Apologize in advance if I missed something.

Context: Electron, Firmware 0.7.0-rc6

  1. Millis() - Is this correct?
System.sleep(seconds);                              // millis() keeps counting
System.sleep(wakeUpPin, edgeTriggerMode, seconds);   // millis() does not keep counting
  1. If I have a RISING interrupt on an interrupt - say intPin
attachInterrupt(intPin,sensorISR,RISING);      // I attach an interrupt in my Setup()
// Later in the program 
System.sleep(intPin,RISING,seconds);           // This wakes the Electron if intPin goes high but does it also call the ISR?
System.sleep(seconds);                         // Here the intPin will still wake up the Electron AND execute the ISR - right?

Again, sorry for the basics but it is hard to debug with sleep and I thought someone would have the answers at hand.



  1. Yes. But System.sleep(seconds) doesn’t really sleep the device but only switches off the radio module while the controller keeps running and will switch the radio back on after the given periode.

  2. In order to wake with a pin, you wouldn’t need attachInterrupt() but after waking from System.sleep(intPin, RISING, seconds) the interrupt you set up earlier will be active fire but hasn’t got any impact on System.sleep(seconds) hence the comment about weaking with intPin does not apply to that kind of sleep.

But I’m pretty sure all that is written in the docs, may just not as concise :wink:

As a side note on millis():
the number returned by millis() is not a counter maintained by the controller internally (althought there is one that counts the system ticks since last reset in hardware) but is only maintained via system code (low priority interrupt) and hence when the controller is not executing code, millis() won’t be updated. That’s also reason why millis() won’t be incremented inside an interrupt routine since the respective code won’t be executed while the controller attends to an interrupt (of same or higher priority).