Setting up RPi WiFi using WPA Supplicant

NOTE: This section may be redundant if you have set up your WiFi connection in the Raspberry Pi’s GUI.

When I set up my Raspberry Pi’s WiFi, I used some well written notes on configuring WiFi with the wpa_supplicant file provided by Eduard Schäli.

WiFi adapter or built-in

With the Raspberry Pi 2 Model B I started with, I used an Edimax 2.4 GHz USB 2.0 (EW-7811UN) WiFi adapter.

But the Raspberry Pi 3 now comes with built-in wireless.

[Note: I had trouble trying to set up the newer Edimax 2.4/5 GHz USB 2.0 (EW-7811UTC) – it seems to need an extra driver, but after trying some suggestions online I gave up and went back to my EW-7811UN]

Setting up WiFi

[Tips on connecting to eduroam below]

Auto WiFi

Firstly set the Pi to automatically use the WiFi interface. Using the RPi’s Terminal, edit the /etc/network/interfaces file:

sudo nano /etc/network/interfaces

Above the line mentioning ‘wlan0’, add ‘auto wlan0‘. And, if you need to make sure your WiFi doesn’t go to sleep, add ‘wireless-power off‘ below the ‘iface wlan0’ line.

So the wlan0 section of my file looks like this:

auto wlan0
allow-hotplug wlan0
iface wlan0 inet manual
    wireless-power off
    wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf

Ctrl-X to exit nano, type ‘y’, and press Enter to save your changes.

WPA_Supplicant file

Now edit the /etc/wpa_supplicant/wpa_supplicant.conf file:

sudo nano /etc/wpa_supplicant/wpa_supplicant.conf

And added the following section to the bottom of the file, substituting your SSID and Password:

network={
  ssid="Enter Your SSID"
  psk="Enter Your WiFi Password"
}

Ctrl-X to exit nano, type ‘y’, and press Enter to save your changes.

Reboot

Reboot your Pi.

sudo shutdown -r

If you boot into the GUI, hopefully the Network menu at the right end of the menubar shows a WiFi signal. Hovering your mouse over the Network menu should show you that ‘wlan0’ is associated with your WiFi network, and show you which IP address it is using.

From the command line (or Terminal in the GUI) you can find more information by using the command:

ifconfig -a

Check that an entry for ‘wlan0’ is listed, and shows its IP address in the ‘inet addr’ section.

If ‘wlan0’ is not listed – Drivers

Check which WiFi adapter you are using.

The older Edimax WiFi adapter I had (EW-7811UN) was plug-n-play, but the newer adpter (EW-7811UTC) didn’t seem to work straight off. Some threads suggest changes in Raspian version “Jessie” may be stopping it(?).

To check your verison of the kernal-release I had installed, use Terminal command:

aname -r

My version was 4.1.21-v7+

I’ll revert to EW-7811UN, and have another go at getting EW-7811UTC to work later (any suggestions welcome).

Setting a hostname

Keith on Keith’s Pi Tutorials suggested setting the Hostname of your Pi, so you don’t need to use its IP address to log in.

  1. Open the Raspberry Pi Configuration menu.
  2. Switch to the ‘System’ tab.
  3. Enter a new ‘Hostname’ (e.g. teamtrack for my climbing counter)
  4. Reboot the Pi
  5. You can now log in over SSH without the IP address, e.g. by typing:
    ssh pi@teamtrack.local

Disabling Power Saving

A few people have noted that the Edimax EW-7811UN WiFi adapter I’ve been using has a power saving mode, and can drop its connection. To make sure you don’t get a break in communication, you can disable power saving. I followed MrEngman’s suggestions on:

  1. Edit/create the following 8192cu.conf file:
    sudo nano /etc/modprobe.d/8192cu.conf
  2. Add the following line of code, then save the file with Ctrl-X, Y, Enter:
    # Disable power management
    options 8192cu rtw_power_mgnt=0 rtw_enusbss=0
  3. Reboot the Pi

Eduroam

To get the Pi to connect to Edinburgh University’s Eduroam network, I consulted their Generic settings for eduroam secure wireless access page. I used the Root certificate ‘QuoVadisOVRootCertificate.crt.pem (Base64)’ from their Installing the wireless root certificates page.

  1. On the Pi, download the Base64 certificate to /etc/ssl/certs:
    cd /etc/ssl/certs/
    sudo wget https://vpnreg.ucs.ed.ac.uk/eduroam/certs/QuoVadisOVRootCertificate.crt.pem
    
  2. Edit the /etc/wpa_supplicant/wpa_supplicant.conf file
    sudo nano /etc/wpa_supplicant/wpa_supplicant.conf
    
  3. Add a new ‘network’ section to the end of the file, substituting your ‘identity’ and ‘password’:
    network={
      ssid="eduroam"
      scan_ssid=0
      key_mgmt=WPA-EAP
      pairwise=CCMP
      group=CCMP TKIP
      eap=PEAP
      ca_cert="/etc/ssl/certs/QuoVadisOVRootCertificate.crt.pem"
      identity="UUN@ed.ac.uk"
      subject_match="radius01.is.ed.ac.uk"
      phase2="auth=MS-CHAPv2"
      password="Wireless Service Password"
    }
    
  4. Ctrl-X to exit nano, type ‘y’, and press Enter to save your changes.
  5. Reboot the Pi, and hopefully it will connect to Eduroam.

Leave a Reply

Your email address will not be published. Required fields are marked *