3

I have a headless pi setup and I want it to connect to two different wifi's at two separate houses. This is how my wpa_supplicant.conf is setup:

ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
country=US

network={ ssid="SSID" psk="password" priority=2 }

network={ ssid="opennetwork" psk=NONE priority=1 }

Right now i'm only able to be connected to my first network, as the other one is somewhere else. If my wpa_supplicant.conf file has only that network listed it connects fine. But, if I have it set up like this, it doesn't connect anywhere. Where did I go wrong?

Dango
  • 41
  • 1
  • 4

4 Answers4

1

I don't see why it does not work properly; if it does not find the first network it should look for the other. You might debug this by looking at wpa_supplicant's output -- I am not sure where it is by default or if wpa_supplicant has its own service by default on RpiOS/Raspbian (I use customized dhcpcd scripts to manage that and discard the defaults when I configure a system).

So you could look into that. However, it's simple enough to swap config files, although it becomes awkward if you are moving a headless pi since it is a bit manual. If you have two files in /etc/wpa_supplicant, neither of which is called wpa_supplicant.conf, you can do this:

> cd /etc/wpa_supplicant; ls
one.conf
two.conf
> ln -s one.conf wpa_supplicant.conf; ls
one.conf
two.conf
wpa_supplicant.conf

The last one is a symlink, basically, provides an alias for one.conf. To reverse the situation:

> rm wpa_supplicant.conf  # <- Only deletes the symlink
> ls -l two.conf wpa_supplicant.conf

Then restart dhcpcd:

systemctl restart dhcpcd

Check pidof wpa_supplicant before and after that if it does not work. If they are the same, then you need to stop dhcpcd, check and if necessary kill (or stop, if there is a service) wpa_supplicant, and then start dhcpcd.

goldilocks
  • 60,325
  • 17
  • 117
  • 234
1

I have 8 networks in my wpa_supplicant.conf - some on different continents and I can move seamlessly between them.

There is no point in priority unless multiple networks are visible.

Your file looks OK but not sure if psk=NONE is affecting results.

Milliways
  • 62,573
  • 32
  • 113
  • 225
1

I figured out how to do it. I just went into raspberry pi config sudo raspi-config, went to network, and added a new network ssid. Then it automatically updated the wpa_supplicant file.

Dango
  • 41
  • 1
  • 4
0

I had a same problem once, you may try to use GUI to join the wifi network if you have the chance, it will update your wpa_supplicant.conf file regarding your network.

hyorman
  • 29
  • 2