Raspberry Pi: Edimax EW-7811UN WiFi Dongle

I recently bought myself an Edimax Wifi dongle to use with my Raspberry Pi. My router is hidden away so I got tired of running a network cable to my Raspberry Pi. The Edimax WiFi dongle was ideal as it is really inexpensive and very small.
It took a while for me to get it set up correctly but eventually I got there. To set up the WiFi connection, you either need a ethernet cable plugged into your Raspberry Pi or you need to connect via the serial port. I connected via the serial port with a FTDI USB to UART converter as this made it much easier to know when the network was connected. 
First of all plug the dongle into one of the USB ports and then reboot.I have not tested this in a USB hub but I am sure it will work the same. To make sure that the dongle has been started, run 

ifconfig

and make sure that wlan0 can be seen.

The next step is to see if your Raspberry Pi can see your wireless network. Run the following command and look for your network.

sudo iwlist wlan0 scan

Under ‘Cell 01’ I can see my network. Take not of your ESSID and you will also need your network password.
Once you have established that your Raspberry Pi can see your wireless network, you will need to edit the network interfaces file.

sudo nano /etc/network/interfaces

You will need to add the following:

  auto wlan0
allow-hotplug wlan0
iface wlan0 inet dhcp
wpa-ssid ‘your ESSID’
wpa-psk ‘your password’

Your interfaces file should now look like this. Note that I have set a static IP address so if you still use DHCP then you will not need the static IP address settings like I have.

Restart your network connection by running

sudo /etc/init.d.networking restart

and then run

ifconfig

and you should notice an IP address assigned to wlan0.

Now reboot your Raspberry Pi to make sure that everything is working in order.

sudo reboot

If your connection is up and running after the reboot, then you are all set to go wireless.

Greg