# Photon using wifi only when available

**URL:** <https://community.particle.io/t/photon-using-wifi-only-when-available/38984>\
**Category:** Firmware\
**Created:** [January 24, 2018, 4:41pm UTC](https://community.particle.io/t/photon-using-wifi-only-when-available/38984 "2018-01-24T16:41:02Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![aimee](https://avatars.discourse-cdn.com/v4/letter/a/c77e96/32.png) [@aimee](https://community.particle.io/u/aimee)\
**Post date:** [January 24, 2018, 4:41pm UTC](https://community.particle.io/t/photon-using-wifi-only-when-available/38984/1 "2018-01-24T16:41:02Z")

</div>

I’m trying to use my particle photon at home (with wifi) and out and about (without wifi). So I want my photon to only connect to wifi when it’s available and otherwise to just run the code and not connected to wifi.

I know I need to use SYSTEM\_MODE(SEMI\_AUTOMATIC) but other than that I don’t know how to write the code for the rest.

Please help! 😃

---

<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:** [January 24, 2018, 5:01pm UTC](https://community.particle.io/t/photon-using-wifi-only-when-available/38984/2 "2018-01-24T17:01:43Z")

</div>

Why the double post, you got an answer here already

> [@Figuring out Particle.disconnect() and WiFi.off()](https://community.particle.io/t/figuring-out-particle-disconnect-and-wifi-off/17062/8):
>
> You need to have WiFi.on() and I’d try WiFi.scan() for WiFi only and WiFi.ping(someOmnipresentIP) for internet and cloud access and when availble call the respective xxx.connect() function. I’d also suggest SYSTEM\_THREAD(ENABLED) and SYSTEM\_MODE(SEMI\_AUTOMATIC) as @peekay123 already did.

---

<div class="post-metadata">

**Author:** ![aimee](https://avatars.discourse-cdn.com/v4/letter/a/c77e96/32.png) [@aimee](https://community.particle.io/u/aimee)\
**Post date:** [January 24, 2018, 5:18pm UTC](https://community.particle.io/t/photon-using-wifi-only-when-available/38984/3 "2018-01-24T17:18:45Z")

</div>

I’m really new to coding and using the photon so I was hoping someone would write out the basics which i need in the right way so that i can then adapt it. would you be able to help me?

---

<div class="post-metadata">

**Author:** ![Moors7](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/moors7/32/588_2.png) [@Moors7](https://community.particle.io/u/Moors7)\
**Post date:** [January 24, 2018, 9:20pm UTC](https://community.particle.io/t/photon-using-wifi-only-when-available/38984/4 "2018-01-24T21:20:49Z")

</div>

That’s not a really great reason to start opening new threads until someone does the work for you.  
Why don’t you give it a shot and see where you get stuck? Then we can help with specific issues, rather than doing everything for you, in which case you learn the least.
