# Dual wifi ?1 home 2 work

**URL:** <https://discourse.mopidy.com/t/dual-wifi-1-home-2-work/4018>\
**Category:** Pi MusicBox (archive)\
**Created:** [May 18, 2020, 11:45am UTC](https://discourse.mopidy.com/t/dual-wifi-1-home-2-work/4018 "2020-05-18T11:45:14Z")\
**Posts on this page:** 1\
**Showing post:** 8

<div class="post-metadata">

**Author:** ![Steve\_Lambert](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.mopidy.com/steve_lambert/32/1149_2.png) [@Steve\_Lambert](https://discourse.mopidy.com/u/Steve_Lambert)\
**Post date:** [May 23, 2020, 8:03am UTC](https://discourse.mopidy.com/t/dual-wifi-1-home-2-work/4018/8 "2020-05-23T08:03:10Z")

</div>

Apologies for delay, kept missing a fi and couldn’t understand why it wouldn’t work.  
It works now for me, but I only have 1 network specified, you’ll have to try both when set up.  
**Make sure and backup the sd card before starting, if it fails it won’t connect to wifi at all and you will need to rewrite the card** - which I have done numerous times  
Hope it works for you - good luck

Log in via SSH using root and musicbox  
sudo nano /opt/musicbox/startup.sh

Scroll down to the line “if [“$INI\_\_network\_\_wifi\_network” != “”]”  
Delete or # everything between the first line and the #enable wifi line there is also a fi at the very end that I missed loads of times so make sure and delete that as well.

* * *

if [“$INI\_\_network\_\_wifi\_network” != “”]  
then  
#put wifi settings for wpa roaming  
#  
# If wifi\_country is set then include a country=XX line  
if [“$INI\_\_network\_\_wifi\_country” != “”]  
then  
WIFICOUNTRY=“country=$INI\_\_network\_\_wifi\_country”  
else  
WIFICOUNTRY=""  
fi  
if [“INI\_\_network\_\_wifi\_password" != ""] then password\_length={#INI\_\_network\_\_wifi\_password}  
if [$password\_length -gt 63]  
then  
PSK=”$INI\_\_network\_\_wifi\_password"  
else  
PSK=""$INI\_\_network\_\_wifi\_password""  
fi  
cat \>/etc/wpa.conf \<\<EOF  
ctrl\_interface=DIR=/var/run/wpa\_supplicant GROUP=netdev  
update\_config=1  
$WIFICOUNTRY  
network={  
ssid="$INI\_\_network\_\_wifi\_network"  
psk=$PSK  
scan\_ssid=1  
}  
EOF  
else  
#if no password is given, set key\_mgmt to NONE  
cat \>/etc/wpa.conf \<\<EOF  
ctrl\_interface=DIR=/var/run/wpa\_supplicant GROUP=netdev  
update\_config=1  
$WIFICOUNTRY  
network={  
ssid="$INI\_\_network\_\_wifi\_network"  
key\_mgmt=NONE  
scan\_ssid=1  
}  
EOF  
fi

* * *

```
#enable wifi
ifdown wlan0 Remove # from this line
ifup wlan0

/etc/init.d/networking restart

```

fi **Delete this line**

ctrl x to save and exit.

Next  
Open /etc/wpa.conf

sudo nano /etc/wpa.conf - it should show your network details.  
Copy and paste underneath, then fill in correct names etc.  
ctrl x to save and exit

* * *

```
        ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
        update_config=1

        network={
            ssid="myhomenetworks"
            psk="myhomepassword"
            scan_ssid=1
        }

        network={
            ssid="myworknetworks"
            psk="myworkpassword"
            scan_ssid=1
        }

```

* * *

Reboot and fingers crossed.  
If you can hook up to hdmi to check progress as it reboots it’s easier to spot any errors.

**Make sure and backup the sd card before starting, if it fails it won’t connect to wifi at all and you will need to rewrite the card**

---

_[View the full topic](https://discourse.mopidy.com/t/dual-wifi-1-home-2-work/4018)._
