Raspberry Pi: Multiple wpa_supplicant networks

Imagine building a raspberry pi project at home that is dependent on wifi. Everything is working perfectly until you move that project somewhere outside your home network. You have to go find a monitor and keyboard to set it up on the new wifi. This process is difficult, time consuming, and stressful. I have had the pleasure to endure this multiple times throughout my projects. Especially when there is pressure to have it done for a public event. I was curious if there was a way to get the networks to be plug and play, where there would not be an issue when moving it from one place to another. Doing a bit of research I have found that you can setup multiple wireless networks on the raspberry pi. There are two pieces in which were new to me for the wpa_supplicant file:

  •  id_str This will be the name we will save for later to reference this network .
  • Priority The higher the number, the higher the priority is for that network if it finds two from the list

In the example below, I have my home network as the first one it will connect to if it finds it. If I plug it in at Spruce it should be already ready to go. If the two of those can not be found I have a backup hotspot on my phone to make the magic happen. Below is an example of the wpa_supplicant file.


ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev

    ssid="Hemstreet Home Network"

    psk="beards are good and stuff"

    ssid="Cell Hotspot"

In the example below you can notice that the 2nd column is the corresponding id_str we had set earlier in our wpa_supplicant file.


iface home inet dhcp
iface spruce inet dhcp
iface cell inet dhcp


Innovative, entrepreneurial and positively unsatisfied mind that constantly pushes the tech boundaries to create new solutions and devices that change people’s lives. Throughout my career, I have had the opportunity of having a multi-disciplinary experience, which led me to wear the hats of: Architect, IoT Consultant (Internet of Things Consultant), Developer, Designer, Engineer, Server Admin, Consultant and Project Manager – to name a few. Based on this diversified background, I get projects done by following smart ideas and well-planned goals. In a world which is getting more unconventional by the day, I use unconventional ways, and a very healthy dose of integrity, to create devices and solutions that help companies go from a steady present to a dynamic future.

You may also like...