Raspberry PI: Add Multiple WiFi Access Points
Filed Under Raspberry Pi on 2012-09-22, 09:41
I don’t know about you, but I can’t remember the last time I had to configure wireless access from the commandline on a Linux machine. When I bought my Raspberry Pi, I also bought an Edimax EW-7811Un Wireless Adaptor. It’s super tiny, and provides wireless access to the Raspberry PI without adding anything bulky hanging off. It uses the very common Realtek RTL8188CUS chip, so it’s supported on Linux. Installing it was a piece of cake with this info and script. Huge thanks to MrEngman for this! (UPDATE: They say this wifi chip is supported with the new Raspberry Pi Debian image, so no need to run the script even!)
Once I had the wireless adapter up and running I realized I wanted it to be able to connect to any of the 3 wireless access points in our house. Turns out it’s really easy to setup your Raspberry Pi to connect to more than one wireless access points, but I had a bit of trouble finding a good how-to for it. Also, I’m sure I’ll forget these steps in due time. So here’s the painfully simple steps both for you and future me:
Edit your network interfaces with the command: sudo nano /etc/network/interfaces
Put the following in interfaces:
auto lo iface lo inet loopback iface eth0 inet dhcp allow-hotplug wlan0 auto wlan0 iface wlan0 inet dhcp pre-up wpa_supplicant -Dwext -i wlan0 -c /etc/wpa_supplicant.conf -B
Then generate your psk for each of your access points with: wpa_passphrase <ssid> <passphrase>
The output will show what your generated psk is. Copy this, we’ll put this in the next file.
Edit your config for wpa_supplicant: sudo nano /etc/wpa_supplicant.conf
Put the following in wpa_supplicant.conf:
ctrl_interface=/var/run/wpa_supplicant #ap_scan=2 network={ ssid="your ssid #1" scan_ssid=1 proto=WPA RSN key_mgmt=WPA-PSK pairwise=CCMP TKIP group=CCMP TKIP psk=the psk you generated above } network={ ssid="your ssid #2" scan_ssid=1 proto=WPA RSN key_mgmt=WPA-PSK pairwise=CCMP TKIP group=CCMP TKIP psk=another psk you generated }
That should be all you need. Now when you plug-in and boot your Raspberry Pi it should connect to whatever access point is available that is supplied in the wpa_supplicant.conf. To check and see which one you’re using at any given time, just use the command iwconfig
. Other handy linux commands for wireless stuff like checking signal strength.