The Raspberry Pi Linux distribution I'm using is Adafruit's Occidentalis.  It supports WiFi out of the box and appears easy to configure.  But as noted by Adafruit, adding peripherals to the RPi may increase the loading on the power supply to your board and this, in turn, may affect the voltage presented to the RPi.

This is clearly the case, even for the tiny  OURlink WiFi (802.11b/g/n) USB Adapter (uses the RTl8192cu chip which is supported by Debian Linux) I purchased from Adafruit.  When I plugged it into the RPi, it became unstable and crashed.  Adafruit advises that you can over come this by attach the RPi's USB port to a powered hub.  (Note that all USB hubs aren't powered or powered sufficient, and therefore, not all are  recommended.  I used a Dynex 4 Port Hub with a 5V 2.1A power adapter and all seem fine.)  If you find using a using a USB hub completely unacceptable, you could make some RPi board modifications to the polyfuses, but this isn't the "official/supported" approach for this power problem .... but first .... see the Epilogue No. 1 below.

I eventually got around to moving away from WEP to WPA2. See Epilogue No. 2 at the end of this page. To make things even more exciting, I changed the WiFi adapter to one that didn't have a currently installed drive on the RPi. See Epilogue No. 3 for the solution to this dilemma.

My First Attempt (Unsuccessful)

Once I got the RPi USB port properly powered, I followed the Adafruit's instructions.  I updated the/etc/network/interfaces file with the following:

########## DID NOT WORK FOR ME ##########

# The loopback network interface
auto lo
iface lo inet loopback

# The primary (wired) network interface
iface eth0 inet dhcp

# The wifi (wireless) network interface
auto wlan0
allow-hotplug wlan0
iface wlan0 inet dhcp
      wpa-ssid YOUR_SSID
      wpa-psk YOUR_WEP_KEY

I ran  ifconfig -a and got the following:


This tells me that Linux sees the WiFi device and assigned it device name wlan0. It also says there isn't an IP address assigned and no data is moving.  Appears that network interface wlan0 isn't running so I tried bring it up with sudo ifup wlan0 and I got the following:


No IP assigned ... now what?

This Worked ... But

After the typical thrashing about, it came to me that I'm not using WAP security (which is implied by the/etc/network/interfaces file content) but I'm using WEP.  I did some web searching and found a site that claimed to address Debian WiFi WEP configuration.  This provided me the needed command syntax for the solution.   I updated the/etc/network/interfaces file with the following:

# The loopback network interface
auto lo
iface lo inet loopback

# The primary (wired) network interface
iface eth0 inet dhcp

# The wifi (wireless) network interface
auto wlan0
allow-hotplug wlan0
iface wlan0 inet dhcp
       wireless-essid YOUR_SSID
       wireless-key YOUR_WEP_KEY

I then ran sudo ifup wlan0 to start the wireless networking (Note: you can use sudo ifdown wlan0 to turn-off the wireless network).  This time DHCP discovery appeared to work.  I then ran ifconfig -a giving me the display below with an assigned wireless IP.

it worked

The wireless device now has an IP address and data seems to be flowing.  In an effort to further convince myself that the WiFi was working, I disconnected the wired ethernet connection and attempted to re-login in via ssh -X pi@RedRPi.local, over the wireless interface. This failed, giving the message:

ssh: Could not resolve hostname RedRPi.local: hostname nor servname provided, or not known

Working For Sure

I suspected (after more thrashing about) it was Ssh or Avahi/Bonjour or both that was getting in the way.  So I did the following:

    1. I cleaned out the ~/.ssh/known_hosts file on the PC from which I'm accessing the RPi (I'm using Cygwin with Openssh). With the entries in the file removed  ssh keys would need to be recreated on next login.
    2. I then logged into the RPi in via ssh -X pi@RedRPi.local. The login created an entry the ~/.ssh/known_hosts file on the PC.
    3. Using vi, I edited the  ~/.ssh/known_hosts file.  I duplicated the one existing record but changed the  IP address to the wireless address.
    4. I restarted the openssh on the PC.  (I terminated all the Cygwin window and restarted them.  I could get anything else to work short of a PC reboot).
    5. I then logged in using ssh -X pi@ Now I'm wireless!!

My ~/.ssh/known_hosts file looks like this:

known hosts

Epilogue No. 1

I have found that if  I don't use a USB  powered hub and I plug in the OURlink WiFi (802.11b/g/n) USB Adapter while the RPi is up and running, the RPi will crash.  The good news is that, once the RPi reboots, it runs fine without the powered hub.

So, go ahead and use the WiFi USB Adapter, without the powered hub, but make sure the adapter is plugged in when you boot up .... problem solved!

Epilogue No. 2

I eventually got around to improving the security on my WiFi network by moving to WPA2. This is a vast improvement over WEP, but not completely unbreakable. I followed the procedures outline in How to Setup Wi-Fi On Your Raspberry Pi via the Command Line.

The results are these two files: /etc/network/interfaces

# The loopback network interface
auto lo
iface lo inet loopback

# The primary (wired) network interface
iface eth0 inet dhcp

# The wifi (wireless) network interface for WPA2
allow-hotplug wlan0
iface wlan0 inet dhcp
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf
iface default inet dhcp

and the file /etc/wpa_supplicant/wpa_supplicant.conf

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


# Protocol type can be: RSN (for WP2) and WPA (for WPA1)

# Key management type can be: WPA-PSK or WPA-EAP (Pre-Shared or Enterprise)

# Pairwise can be CCMP or TKIP (for WPA2 or WPA1)

#Authorization option should be OPEN for both WPA1/WPA2 (in less commonly used are SHARED and LEAP)

To get it running, execute the commands sudo ifdown wlan0 then sudo ifup wlan0.

Note: To create the Hex version of the psk key from an ASCII passphrase, your can use the wpa_passphrase documented here.

Epilogue No. 3

I had to swap out my OURlink WiFi (802.11b/g/n) USB adapter on the RPi for a new one and suddenly WiFi stopped working. This seem strange, since it was the same manufacture. I discovered, via the lsusb command, that the USB ID had changed for the adapter. This could imply that the chip set inside the adapter is also different.

After much research, I discovered that the device drive had changed. I found the procedures for the fix in this article and downloaded the new compiled module driver for the kernel along with its companion firmware file, and added the module to the kernel.

At that point, the WiFi adapter could be sensed by ifconfig but I still couldn't get it to work. A looked into the /etc/udev/rules.d/70-persistent-net.rules file for udev rules, and this showe that the adapter was assigned a new name. I reflected this new name in the /etc/network/interfaces file, and then everything worked fine.