First Forrays into Raspberry Pi

Per-Anders Irrigation, Maker

So I began my exploration of the Raspberry Pi a couple of days back having tracked one down to my local Radioshack.

The purpose of the Pi in my setup is to give me a nice visual control system as well as wifi.

To that end I’ve ordered myself a nice touchscreen for the Pi from Chalkboard electronics and I got an Edimax EW-7811Un wirelss nano USB adapter from Amazon.

Setting up the Wifi adapter on the RPi was perhaps more complex that I was initially expecting due to a couple of configuration discrepancies from the various tutorials, and the fact that it’s been a while since I used a linux distro and absolutely years since I had to use any of the various *nix terminal based text editors to configure anything in either OSX, possibly all the way back when I was using Workbench on the Amiga!

It’s not hard once you know, but I’ll go over them in case this helps others and saves you some time in the future, as well as to keep a record for myself in case I ever have to do this again.

First off the information given here : http://www.frodebang.com/p/1 while correct under most circumstances wont work if you’re using a router with a non-broadcasting SSID.  It seems to require the old fashioned route of adjusting both the interfaces and wpa_supplicant.conf files to work in this instance.

Following the instructions here : http://kp4tr.org/?page_id=320 are not enough.  Initially I tried this method (or more specifically the one outlined here : http://www.savagehomeautomation.com/projects/raspberry-pi-installing-the-edimax-ew-7811un-usb-wifi-adapte.html ) and got no-where, the adapter was working, but simply couldn’t reserve a valid IP address.  Shifting to the newer first method equally ended up no-where.  It took a bit of Google-ing and deduction to work out what was happening based on the errors I was getting,  After which I found the missing component, namely the scan_ssid flag.

So here’s the complete rundown.

  1. Plug the adapter in to your RPi
  2. Type
    $ lsusb
    into the terminal to check that the RPi see’s the adapter, the result should be a list of the USB devices including one labeled
    Edimax Technology Co., Ltd EW-7811Un 802.11n Wireless Adapter
  3. Type
    $ lsmod
    To check that the driver is loaded for the adapter, you should see a Module called 8192cu with a size of about 485042 and used by 0 listed in the output.
  4. Final validation check of the adapter itself is to call
    $ iwconfig
    , if all is correct you should see the wlan0 adapter as present.
  5. Provided everything is there now make sure you’re running a terminal from the desktop as you’re going to want to use the mouse and to be able to Copy & Paste text from within the terminal for the next few steps, so if you haven’t already then start it up with
    startx
  6. Type
    $ sudo nano /etc/network/interfaces
    and modify it To make sure it has the following lines.
    auto wlan0 allow-hotplug wlan0<br />
    iface wlan0 inet manual<br />
    wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf
    The resulting file should in total look like this
    # This file describes the network interfaces available on your system<br />
    # and how to activate them.<br />
    #<br />
    # The loopback network interface<br />
    auto lo<br />
    iface lo inet loopback# The LAN network interface<br />
    auto eth0<br />
    iface eth0 inet dhcp</p>
    <p>auto wlan0<br />
    allow-hotplug wlan0<br />
    iface wlan0 inet manual<br />
    wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf</p>
    <p>iface default inet dhcp<br />
    
  7. Press CTRL+O and then enter/return to save the file, then CTRL+X to exit and go back to the command line.
  8. In order to enter your password without storing it in your files in readable format you’re going to want to use the passkey version of your password, you can do this from the terminal by calling
    $ sudo wpa_passphrase "My Network Name" "My Network Password"
    this should result in an output looking something like this:
    network={<br />
    ssid="My Network Name"<br />
    #psk="My Network Password"<br />
    psk=b534692382a974293487f23879438efa3472897539aaa347893742bc348902612311af9af8<br />
    }
  9. Select the line starting psk=(some numbers and letters) and copy it, this is your passkey to be used instead of keeping your actual visible password available on the RPi.
  10. Type
    $ sudo nano /etc/wpa_supplicant/wpa_supplicant.conf
    to edit the wpa_supplicant configuration file with nano
  11. Add the following to the wpa_supplicant.,conf file if it’s not there already, pasting in the copied psk line from steps 8 and 9 into the line marked psk=(my copied passkey)
    network={<br />
    ssid="My Network Name"<br />
    scan_ssid=1<br />
    proto=RNS<br />
    key_mgmt=WPA-PSK<br />
    pairwise=CCMP<br />
    group=CCMP<br />
    psk=(my cop[ied passkey)<br />
    }
  12. Hit CTRL+O then Enter/Return to save the file, then CTRL+X to exit nano and return to the command line.
  13. Either reboot your Pi or call
    $ sudo ifdown wlan0; sudo ifup wlan0
    to restart the connection.
  14. Check that the router is available

If you have more problems trying to locate your wireless network you can check that it’s seen at all using

$ sudo iwlist wlan0 scan essid "My Network Name"
.

Follow this and you should have a working Wifi enabled RPi afterwards!