# Doing something while waking up from sleep

**URL:** <https://community.particle.io/t/doing-something-while-waking-up-from-sleep/27619>\
**Category:** Firmware\
**Created:** [November 30, 2016, 3:23pm UTC](https://community.particle.io/t/doing-something-while-waking-up-from-sleep/27619 "2016-11-30T15:23:13Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![\_koray](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/_koray/32/11644_2.png) [@\_koray](https://community.particle.io/u/_koray)\
**Post date:** [November 30, 2016, 3:23pm UTC](https://community.particle.io/t/doing-something-while-waking-up-from-sleep/27619/1 "2016-11-30T15:23:13Z")

</div>

Hi,  
I want do be able to blink an LED or play tone() while my electron is waking up from sleep .  
Right now it takes 20 seconds or so before it is ‘awoken’ and only then I am able to flash some LEDs or play a tune… Is there a function like STARTUP for waking from sleep ? (I am using an electron with 0.5.3)

---

<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:** [November 30, 2016, 3:58pm UTC](https://community.particle.io/t/doing-something-while-waking-up-from-sleep/27619/2 "2016-11-30T15:58:09Z")

</div>

You’d need to chose a better `SYSTEM_MODE()` and consider the use of `SYSTEM_THREAD(ENABLED)` too.

BTW, `STARTUP` will only be executed when waking from deep sleep, not from Stop Mode sleep.

---

<div class="post-metadata">

**Author:** ![\_koray](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/_koray/32/11644_2.png) [@\_koray](https://community.particle.io/u/_koray)\
**Post date:** [December 1, 2016, 8:07am UTC](https://community.particle.io/t/doing-something-while-waking-up-from-sleep/27619/3 "2016-12-01T08:07:56Z")

</div>

so If I use SYSTEM\_THREAD(ENABLED) i will win some time? (Or do i need a manual system mode so the startup is faster and then do somehting first before connecting to the cloud ?)  
I need to go to sleep for indefinite amount of time and then wake from a pin. so Deep sleep is not an option i think

---

<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:** [December 1, 2016, 9:55am UTC](https://community.particle.io/t/doing-something-while-waking-up-from-sleep/27619/4 "2016-12-01T09:55:01Z")

</div>

With a dedicated thread for the cloud tasks your own app code will start running immediately without needing to wait for the cloud connection.  
But for that reason you might want to check for an active connection before doing cloud-dependent stuff.

Choosing the right SYSTEM\_MODE() will then just help the system thread not to waste time on cloud stuff when you won’t need/want it anyway.
