WiFi on my Pi

The Raspberry Pi is such a small package it is just a crime to have it teathered to an ethernet interface.  I wanted to make it a little more portable so that I can take my Raspberry Pi with me anywhere.  I also had a USB wireless interface lying around from another project so I figured I could make the Pi detect what networking is available and enable the correct interface.  This is my documentation of who I made this work on the Wheeze Pi Distribution.

I will use the wpa supplicant utility to detect and join the wireless networks.  Edit the /etc/wpa_supplicant/wpa_supplicant.conf file and change it to look something like this:

ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
 
network={
        ssid="ssid"
        proto=RSN
        key_mgmt=WPA-PSK
        pairwise=CCMP TKIP
        group=CCMP TKIP
        psk="password"
        priority=100
}

 

Make sure to change the ssid and password in the above network definition to what your network needs. You can also add in as many network definitions as you need s othat it can automatically connect up if you are moving it around.  If you want it to automatically connect to open wifi networks, then add in the following network block.

 

 
network={
        ssid=""
        scan_ssid=1
        key_mgmt=NONE
        auth_alg=OPEN
        priority=1
}

 

 The next step is to setup the ifplugd so that it can switch between the wireless and wired connection.

Setting up ifplugd

Make sure that your wired interface is turned off and down.

 # ifdown eith0

The /etc/network/interfaces file is the file that controls the Linux interfaces and how that will startup.  We need to edit this file to make sure it will start the wpa_supplicant for the wireless interface and also make sure that the ifplugd can control the eth0 interface without fighting with other processes.

Edit the /etc/network/interfaces file to look similar to this one:

 # Network interface Definitions
auto lo
iface lo inet loopback

# eth0 is controlled by ifplugd. Do not use hotplug or other auto options
iface eth0 inet dhcp

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

iface default inet dhcp

The next is to reconfigure the ifplugd utility.  This is where I had a few issues.  I ssh’ed into the box and the terminal type I used seems to screw up the menu’s on the following command.  The following pictures are from the console, it didn’t looks like this for me.

NOTE: If anyone knows how to fix the terminal type of cursor based apps like the follwing, can you please leave a comment of this and let me know.

Run the ifplugd reconfiguration:

 # dpkg-reconfigure ifplugd

Clear the static interfaces so that it is blank.

ifplugd1

Add your wires interface (eth0) on this screen when it asks for “hopplugged interfaces”.

ifplugd2

Lead all the default configurations and just press OK.

ifplugd4

I am not sure if the Raspberry Pi has a susspend state (personal note, I should look into this) but just tell ifplugd to stop before a suspend.

ifplugd5

Check the results that are writed into /etc/default/ifplugd.  They should look similar to this:

INTERFACES=""
HOTPLUG_INTERFACES="eth0"
ARGS="-q -f -u0 -d10 -w -I"
SUSPEND_ACTION="stop"

Your computer should enable the wireless interface only if the wired withernet is not connected. Once an eithernet cable is plugged in it should turn off the wireless and switch over to the wired interface, once the cable is unplugged again, then it will switch back to the wireless.  A great setup if you are running headless list I do and want to travel with your Pi.

Reboot your Raspberry Pi with the wireless interface plugged in and without an eithernet cable.  It should come up with the wireless interface enabled and working.  you can check this by using the wpa_cli command as follows.

# wpa_cli status

Selected interface ‘wlan0’
bssid=00:21:ff:b5:f2:12
ssid=VE6KIK
id=0
mode=station
pairwise_cipher=CCMP
group_cipher=TKIP
key_mgmt=WPA2-PSK
wpa_state=COMPLETED
ip_address=172.31.16.5
address=f4:ec:38:96:ff:ff

 

Your Raspberry Pi should now be ready to go.  You can now put it on a wireless or wired network and start working with it.  Here is a picture if my Raspberry Pi sitting next to me on on an end table.  It is connected wirelessly to my network and I was using it while I wrote this article.

WiFiPi

Leave a Comment

Your email address will not be published. Required fields are marked *