# Detect the state of the wifi

**URL:** <https://discourse.processing.org/t/detect-the-state-of-the-wifi/13021>\
**Category:** Coding Questions\
**Created:** [July 28, 2019, 1:04pm UTC](https://discourse.processing.org/t/detect-the-state-of-the-wifi/13021 "2019-07-28T13:04:09Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![hugo](https://avatars.discourse-cdn.com/v4/letter/h/b38774/32.png) [@hugo](https://discourse.processing.org/u/hugo)\
**Post date:** [July 28, 2019, 1:04pm UTC](https://discourse.processing.org/t/detect-the-state-of-the-wifi/13021/1 "2019-07-28T13:04:10Z")

</div>

Hello,  
I would like to change the background depending on the state of the wifi :

```auto
if (//wifi is activated\\) {
   background(0,255,0);
 } else {
   background(255,0,0);
}

```

What should we put in place of “//wifi is activated\” ?  
Do you have an idea to solve my problem ?  
Thank you.

---

<div class="post-metadata">

**Author:** ![jeremydouglass](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jeremydouglass/32/20_2.png) [@jeremydouglass](https://discourse.processing.org/u/jeremydouglass)\
**Post date:** [August 5, 2019, 10:44pm UTC](https://discourse.processing.org/t/detect-the-state-of-the-wifi/13021/2 "2019-08-05T22:44:46Z")

</div>

Whether your computer has wifi on or not is OS-level information. How to check will depend on if you are on Windows, MacOS, or Linux.

For example, on Windows, you could use command to check ipconfig or ping.

[https://www.digitalcitizen.life/command-prompt-advanced-networking-commands](https://www.digitalcitizen.life/command-prompt-advanced-networking-commands)

On MacOS, you could try a command to ping or netstat.

> <https://apple.stackexchange.com/questions/171160/how-to-get-the-wi-fi-connection-status-from-terminal/171203#171203>

Or, if you have a particular server you are connecting to in your sketch, just test its availability directly with the network library using available().

[https://processing.org/reference/libraries/net/Client\_available\_.html](https://processing.org/reference/libraries/net/Client_available_.html)
