Wi Fi
How to set up WiFi on a Raspberry Pi
Although the Raspberry Pi Model B comes with built-in 100Mbps wired Ethernet, it can also use WiFi via a USB dongle. The Model A doesn’t come with Ethernet at all, so using a WiFi adapter is a good way to get networking on that model. In both cases, simply plugging in a supported USB dongle and doing a simple bit of configuration will give your Pi access to wireless.
Plug in the USB adapter and boot your Raspberry Pi. There are several ways to check if the adapter has been recognized. The easiest is to type:
ifconfig wlan0 Link encap:Ethernet HWaddr 80:1f:02:e6:98:4a inet addr:192.168.0.111 Bcast:192.168.0.255 Mask:255.255.255.0 UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:251 errors:0 dropped:3 overruns:0 frame:0 TX packets:8 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:25837 (25.2 KiB) TX bytes:1662 (1.6 KiB
You should see a listing for eth0 – the built-in wired Ethernet port; for lo – the loop back device; and wlan0 – the wireless adapter.
Alternatively you can list the current USB devices attached to the Pi using:
sudo lsusb Bus 001 Device 002: ID 0424:9512 Standard Microsystems Corp. Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub Bus 001 Device 003: ID 0424:ec00 Standard Microsystems Corp. Bus 001 Device 004: ID 7392:7811 Edimax Technology Co., Ltd EW-7811Un 802.11n Wireless Adapter [Realtek RTL8188CUS] Bus 001 Device 005: ID 09da:0260 A4 Tech Co., Ltd
If you aren’t using the desktop then the WiFi can be configured using the command line. Raspbian should come with all the correct packages pre-installed but if any of the commands or files mentioned below aren’t available, then run this command to install them:
sudo apt-get install wpasupplicant wireless-tools
The general network settings are configured in “/etc/network/interfaces” file:
sudo nano /etc/network/interfaces
Ensure that the section about wlan0 (typically found at the end of the file) reads as follows:
auto lo iface lo inet loopback iface eth0 inet dhcp auto wlan0 allow-hotplug wlan0 iface wlan0 inet dhcp wpa-ssid "clarion" wpa-psk "clarion2" #wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf iface default inet dhcp
If you are using a 'hidden' SSID, try the following
auto wlan0 allow-hotplug wlan0 iface wlan0 inet dhcp wpa-scan-ssid 1 wpa-ap-scan 1 wpa-key-mgmt WPA-PSK wpa-proto RSN WPA wpa-pairwise CCMP TKIP wpa-group CCMP TKIP wpa-ssid "My Secret SSID" wpa-psk "My SSID PSK"
If there are difference then change them to accordingly. Don’t alter any of the lines about the lo adapter or the eth0 adapter. Press “CTRL + X” to exit nano (press Y and then press ENTER when prompted).
To get a list of the currently available wireless networks, use the iwlist command:
sudo iwlist wlan0 scan
If there is too much information, use grep to find the fields you need. For example to see just the ESSIDs, use:
sudo iwlist wlan0 scan | grep ESSID
Finally reboot your Pi:
sudo reboot
You can check the status of the wireless connection using ifconfig (to see if wlan0 has acquired an IP address) and iwconfig to check which network the wireless adapter is using.