How to wakeup every <n> seconds from sleep(SLEEP_MODE_CPU)?


#1

I want to try a really common use case:

1 - have a DK sleep most of the time to conserver battery power
2 - wake up every < n > seconds (think 300, 600, 3600)
3. take a reading from < some peripheral >
4. publish the reading to the particle cloud

In a photon/electron, I would use: System.sleep(SLEEP_MODE_DEEP, (long)(300)), what is the best practice for a DK ?


#2

Is this a dup of Timer lib available? ?

If so, I disagree that the max timer interval of 512 sec discussed in that thread is acceptable, if that is indeed a limit, then hide longer delays by daisy-chaining max duration delays to suit (extra credit for accounting for the overhead of daisy-chaining, so that each daisy-chain step doesn’t introduce X% more error in the overall delay.


#3

What i ended up doing for now was to use software timers from my Photon in the gateway shield to call a Particle.function() on my Bluz. It is my understanding that this has no impact on the battery but isn’t for timing sensitive applications. Works great so far. Having looked at this more I agree that 512seconds is fine or like you said to chain them to get to the value required would work just fine.


Minimising power usage
#4

Software Timers are on the list for bluz. We should get to them in the next release.

I can say that for bluz, the idea is also to keep low enough power that this doesn’t become a full necessity. Deep sleep with a wake up is certainly best practice for any device where the current draw is very high. But with bluz, the normal current draw should be so low that this isn’t always required. Clearly in certain use cases it will be beneficial, and we will support it for just that reason. But the current CPU sleep mode should keep things low powered enough that you can do a whole lot and run off batteries for a long time without disconnecting from the network and fully going to sleep.

I should hopefully be able to get a date together soon for a new release that will have the capability.


Wake on interrupt