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

**URL:** <https://community.particle.io/t/electron-how-to-post-measurement-data-to-cloud-for-a-set-time-period-plus-save-battery-power/20837>\
**Category:** Getting Started\
**Created:** [March 7, 2016, 6:49am UTC](https://community.particle.io/t/electron-how-to-post-measurement-data-to-cloud-for-a-set-time-period-plus-save-battery-power/20837 "2016-03-07T06:49:44Z")\
**Posts on this page:** 1\
**Showing post:** 6

<div class="post-metadata">

**Author:** ![ScruffR](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/scruffr/32/6952_2.png) [@ScruffR](https://community.particle.io/u/ScruffR)\
**Post date:** [March 9, 2016, 10:45pm UTC](https://community.particle.io/t/electron-how-to-post-measurement-data-to-cloud-for-a-set-time-period-plus-save-battery-power/20837/6 "2016-03-09T22:45:21Z")

</div>

> [@samb375](#):
>
> Do you have any example code that I may be able to work from?

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](https://community.particle.io/t/have-system-sleep-sleep-mode-deep-wakeup-at-the-same-time-everday/18720/7)

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

```auto
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 😉

---

_[View the full topic](https://community.particle.io/t/electron-how-to-post-measurement-data-to-cloud-for-a-set-time-period-plus-save-battery-power/20837)._
