Electron: How to post-measurement data to Cloud for a set time period, plus save battery power?

If this refers to the way to make the device wake at a particular time then you might want to have a look here
Have System.sleep SLEEP_MODE_DEEP wakeup at the same time everday - #7 by ScruffR

It's not exactly what you're looking for, but you should get the idea.

And for the code after deep sleep, with your code, you could just put everything into void setup() with System.sleep(SLEEP_MODE_DEEP, secsToWake); as last instruction and leave loop() empty - this way you won't forget, that deep sleep always wakes to run from the very beginning.
No variablies (unless explicitly marked retained) will carry over from one session to the next.


Update:
Just browsed over the linked thread and saw this final post by the ingenious Mat

void sleepUntil(time_t time) {
     time -= Time.local();
     System.sleep(SLEEP_MODE_DEEP, time); 
}

But reading through the thread will still be good for background and to figure how to build the time parameter :wink:

1 Like