How to Configure Raspberry PI for WiFi using Edimax EW-7811Un

UPDATE! There has been changes in the way the Edimax Wifi interface interacts with the Raspberry Pi using the latest builds (Debian Wheezy) So I am updating this article with my findings.

The EW-7811Un can now work with both WPA2-PSK and WPA and WEP encryption. The wpa-supplicant software is no longer needed, and can be commented out of the “/etc/network/interfaces” file. The default /etc/network/interfaces file will contain the following:

 

 

auto lo

iface lo inet loopback
iface eth0 inet dhcp

allow-hotplug wlan0
iface wlan0 inet manual
wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf
iface default inet dhcp

 

You can comment out 2 entries and use the following (One entry uses WEP encryption and the other is WPA2-PSK):

 

auto lo

iface lo inet loopback
iface eth0 inet dhcp

allow-hotplug wlan0
###iface wlan0 inet manual
###wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf

iface wireless0 inet dhcp
wpa-ssid SSID-0
wpa-psk WPA2PSK-PASSWORD

iface wireless1 inet dhcp
wireless-essid SSID-1
wireless-key 0123456789ABCDEF0123456789

 

The example above shows 2 SSID’s. Notice one uses wpa-ssid/wpa-psk, and the other uses wireless-essid/wireless-key entries. One uses WEP encryption, the other WPA2-PSK. To connect one or the other use the following command:

ifup wlan0=wireless0

To connect to wireless1 use:

ifup wlan0=wireless1

 

Below is the original article using the wpa-supplicat software if desired.


The Edimax EW-7811Un will only work using WPA-PSK security. In Netgear, I chose in my security options to have both WPA and WPA2:  WPA-PSK [TKIP] + WPA2-PSK [AES]

To configure wifi in a few easy steps. Login to Linux. Follow steps as described in reference 1 link below.

Launch a repository update:  $ sudo apt-get update
Run a system upgrade: $ sudo apt-get upgrade
Make sure that the latest Raspberry Pi firmware version is installed:  $ sudo apt-get install raspberrypi-bootloader
Install the wpa_supplicant utility: $ apt-get install wpasupplicant

Generate a PSK version of your WLAN password with wpa_passphrase utility: $ sudo wpa_passphrase YOURSSID YOURPASSWORD

It will generate something like this:

network={
ssid=”YOURSSID
#psk=”YOURPASSWORD
psk=b7d90db3ddbd11d5ddb3dbfd81de3da6dd0dbcd53d0aa21a5ba8aac5a6faf9a5
}

Add the generated information to the bottom of the file: /etc/wpa_supplicant/wpa_supplicant.conf

Use WinSCP to copy, edit, and copy it back if nano or vi are too much.

network={
ssid=”YOURSSID
scan_ssid=1
key_mgmt=WPA-PSK
proto=WPA
psk=”YOURPASSWORD
}

With the ethernet cable connected, issue this command:

sudo ifdown wlan0; ifup wlan0

Your router should be issuing an IP address to the wlan0 via DHCP.

You should see an IP address (in red below) assigned to the wlan0 interface and the blue light blinking on the Edimax:

pi@raspberrypi:~# sudo ifconfig
eth0 Link encap:Ethernet HWaddr b8:27:ea:53:80:dc
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:9976 errors:0 dropped:0 overruns:0 frame:0
TX packets:3785 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:8296190 (7.9 MiB) TX bytes:449405 (438.8 KiB)

lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:12 errors:0 dropped:0 overruns:0 frame:0
TX packets:12 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:1248 (1.2 KiB) TX bytes:1248 (1.2 KiB)

wlan0 Link encap:Ethernet HWaddr 80:1f:02:86:ea:a1
inet addr:192.168.1.69 Bcast:192.168.1.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:339 errors:0 dropped:467 overruns:0 frame:0
TX packets:57 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:102962 (100.5 KiB) TX bytes:13933 (13.6 KiB)

 

Now you can disconnect the ethernet cable, and login again to the PI wirelessly using putty using the IP address assigned by your router via DHCP.

 

References