Sunday, January 27, 2013

How to setup wireless connectivity on Raspberry Pi

In this post I will describe how I went about setting up the TP-Link WLAN adapter on a Raspberry Pi.

Items used

  1. MacBook Pro laptop running Mac OSX 10.7
  2. Raspberry Pi
  3. Network cable
  4. 3G dongle connected to laptop
  5. Monitor connected to Raspberry Pi via HDMI port
  6. Mouse connected to Raspberry Pi
  7. TP-Link WLAN adapter

Step by Step Guide

Step 1: Setup network connection between Raspberry Pi & laptop

This can simply be done by connecting the two using a network cable. A crossover cable is not necessary. The important thing would be to setup IP addresses for the laptop LAN interface & the Raspberry Pi eth0 interface. This could be done simply by assigning an IP address such as 192.168.33.1 & 192.168.33.2 to the two respectively, or by running DHCP on the Mac. I assigned the static IP address 192.168.33.1 to the Mac's ethernet interface.

Since running DHCP on the Mac is the cooler option, I chose that. "Running Mac OS X's built-in DHCP server" is the best article I found. I backed up the original /etc/bootpd.plist file, and replaced it with the example provided in that article, and started up my DHCP server. I also added the Raspberry Pis MAC address & bound it to a fixed IP address using the /etc/bootptab file. On the Raspberry Pi, the default option for the eth0 interface is to use DHCP so generally you will not need to change anything. If that is not the case, simply enable DHCP for that interface.

Step 2: Power up the Raspberry Pi 

Now you can simply power up the Raspberry Pi, and ssh to it from the laptop.

Step 3: Setup an HTTP proxy server on the Mac


I installed the SquidMan proxy server on the Mac & added the IP address of the Raspberry Pi eth0 interface to the client list, and started it using the "Start Squid" button.

Step 4: Configure the Raspberry Pi apt package manager to use the proxy server running on the Mac


sudo vim.tiny /etc/apt/apt.conf.d/01proxy
and add the following line to that file:

Acquire::http::Proxy "http://192.168.33.1:8080";
192.168.33.1 is the IP address of the ethernet interface on the Mac.

Step 4: Run a firmware upgrade on the Raspberry Pi

Firmware upgrade is a fancy way of asking you to do the following:


sudo apt-get update
sudo apt-get install --reinstall libraspberrypi-doc  libraspberrypi-dev  libraspberrypi-bin libraspberrypi0 raspberrypi-bootloader



Reboot the Pi. If everything went well, now the green light on the WLAN adapter should periodically blink, and ifconfig should list the wlan0 interface.

Step 5: Connect the wlan0 interface to an available wireless network

The easiest way to do this is to install wicd


sudo apt-get install wicd



From now onwards it is easier to use the keyboard, mouse & monitor connected to the Raspberry Pi.  Run startx, and then locate the "wicd manager" application under the "Internet" menu. The UI should automatically list the available wireless networks. Select a network, and provide the proper credentials. That's it! Your Raspberry Pi is now connected to the wireless network.



Post a Comment