# Photon: How to run code when no WIFI or Internet

**URL:** <https://community.particle.io/t/photon-how-to-run-code-when-no-wifi-or-internet/44127>\
**Category:** Getting Started\
**Created:** [September 23, 2018, 3:21pm UTC](https://community.particle.io/t/photon-how-to-run-code-when-no-wifi-or-internet/44127 "2018-09-23T15:21:07Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![atom](https://avatars.discourse-cdn.com/v4/letter/a/85f322/32.png) [@atom](https://community.particle.io/u/atom)\
**Post date:** [September 23, 2018, 3:21pm UTC](https://community.particle.io/t/photon-how-to-run-code-when-no-wifi-or-internet/44127/1 "2018-09-23T15:21:07Z")

</div>

Hello,

I have noticed that the micro-controller stops running my code, when I turn off the router, or I disconnect the WAN cable from the router.  
Also Photon does not seem to start my code until it connected to the internet, which is not really good for me. Is it possible to setup that my code should run always?

Thanks!

---

<div class="post-metadata">

**Author:** ![atom](https://avatars.discourse-cdn.com/v4/letter/a/85f322/32.png) [@atom](https://community.particle.io/u/atom)\
**Post date:** [September 23, 2018, 3:28pm UTC](https://community.particle.io/t/photon-how-to-run-code-when-no-wifi-or-internet/44127/2 "2018-09-23T15:28:22Z")

</div>

Sorry, I have just found the solution!  
SYSTEM\_THREAD(ENABLED);

---

<div class="post-metadata">

**Author:** ![peekay123](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/peekay123/32/810_2.png) [@peekay123](https://community.particle.io/u/peekay123)\
**Post date:** [September 24, 2018, 12:55am UTC](https://community.particle.io/t/photon-how-to-run-code-when-no-wifi-or-internet/44127/3 "2018-09-24T00:55:57Z")

</div>

@atom, you also need to look at SYSTEM\_MODE and make sure that if your code expects cloud connectivity, you check Particle.connected() first, for example.

---

<div class="post-metadata">

**Author:** ![atom](https://avatars.discourse-cdn.com/v4/letter/a/85f322/32.png) [@atom](https://community.particle.io/u/atom)\
**Post date:** [September 24, 2018, 6:43am UTC](https://community.particle.io/t/photon-how-to-run-code-when-no-wifi-or-internet/44127/4 "2018-09-24T06:43:09Z")

</div>

@peekay123, great, thanks for the info!
