How to config USB wifi adapter for Raspberry Pi

From TIAO's Wiki
Jump to: navigation, search

10 PCS, 10cm x 10cm, 2 layers prototype for $38.80 shipped!








Buy Game Console Adapters from http://www.easymg.com or http://www.diygadget.com

Background

This tutorial helps you to manually config USB Wifi adapter purchased from http://www.diygadget.com on your Raspberry Pi.

These are the wifi adapters works with Raspberry Pi:

802.11b/g/n Nano USB Wifi Adapter Dongle with External Antenna for Raspberry Pi (Ralink RT5370)

802.11b/g/n Nano USB Wifi Adapter dongle for Raspberry Pi (Ralink RT5370)

802.11b/g/n Nano USB Wifi Adapter dongle for Raspberry Pi (REALTEK 8188CU)

This tutorial uses 2012-10-28-wheezy-raspbian.zip Raspbian image.

Before proceed to the steps, please have a working Raspberry Pi with above image installed.

Pre-setup

  • Power off Raspberry Pi
  • Insert the wifi adapter purchased from http://www.diygadget.com into one of the usb port on Raspberry Pi.
  • Connect your USB keyboard.
  • Connect your monitor with the HDMI cable.
  • Power on Raspberry Pi

USB wifi adapter needs additional power to work, if your power supply cannot provide enough power to your Pi, you can either switch to a better power supply or use a powered usb hub.

Config interfaces file

In console, run the following command:

sudo nano /etc/network/interfaces

This is the original content of the interfaces file:

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

If you want your router to assign an IP address automatically to your Pi, modify interfaces file to:

auto lo

iface lo inet loopback
iface eth0 inet dhcp

allow-hotplug wlan0
auto wlan0
iface wlan0 inet dhcp
wpa-ssid <your wireless access point ssid name>
wpa-psk <your wireless access point password>
# wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf
# iface default inet dhcp

If you want to have a static IP address of your Pi, modify interfaces file to:

auto lo

iface lo inet loopback
iface eth0 inet dhcp

allow-hotplug wlan0
iface wlan0 inet static
address 192.168.1.100
netmask 255.255.255.0
gateway 192.168.0.1
wpa-ssid <your wireless access point ssid name>
wpa-psk <your wireless access point password>
# wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf
# iface default inet dhcp

(Change 192.168.1.100 to the IP you want to use).

Now, restart the network interface by issuing the following command:

sudo /etc/init.d/networking restart

Then, run ifconfig to check the result:

pi@raspberrypi ~ $ ifconfig
eth0      Link encap:Ethernet  HWaddr b8:27:eb:f7:b1:b3
          UP BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

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:8 errors:0 dropped:0 overruns:0 frame:0
          TX packets:8 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:1104 (1.0 KiB)  TX bytes:1104 (1.0 KiB)

wlan0     Link encap:Ethernet  HWaddr 00:0f:54:0a:08:2c
          inet addr:192.168.1.14  Bcast:192.168.1.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:1444 errors:0 dropped:0 overruns:0 frame:0
          TX packets:283 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:345124 (337.0 KiB)  TX bytes:33694 (32.9 KiB)

pi@raspberrypi ~ $

Since I choose DHCP, so the IP address is 192.168.1.14.

Now you are done. When you reboot your Pi next, it will be connected to your network automatically.

Here are the links for supported wifi adapters:

802.11b/g/n Nano USB Wifi Adapter Dongle with External Antenna for Raspberry Pi (Ralink RT5370)

802.11b/g/n Nano USB Wifi Adapter dongle for Raspberry Pi (Ralink RT5370)

802.11b/g/n Nano USB Wifi Adapter dongle for Raspberry Pi (REALTEK 8188CU)


We also have other Raspberry Pi accessories for sale, check them out here:

http://www.diygadget.com

Have fun!

Buy Game Console Adapters from http://www.easymg.com or http://www.diygadget.com

Reference:

  1. Installing FreeNX server and NX Open Source Components


10 PCS, 10cm x 10cm, 2 layers prototype for $38.80 shipped!