Posts Tagged OURLiNK

Installing a Miniature WiFi Module on the Raspberry Pi (w/ Roaming Enabled)

Background

In a earlier post, Installing a Miniature WiFi Module on the Raspberry Pi (w/o Roaming Enabled), I detailed the installation and configuration of a Miniature WiFi Module, from Adafruit Industries, on a RaspPi running Soft-float Debian “wheezy”. As I mentioned in that post, there was more than one method of configuring the WiFi Module (WNIC) on a WLAN, based on the research I did. I chose the simple method of hard-coding a single WLAN configuration into the ‘/etc/interfaces’ file.

Recently, while installing the same type WiFi Module (WNIC) on a RaspPi running Raspbian “wheezy”, I chose the alternate method. This involves adding the WLAN configuration to the wpa_supplicant configuration file (‘/etc/wpa_supplicant/wpa_supplicant.conf’). You can add multiple WLAN configurations to the wpa_supplicant configuration file. This allowing the RaspPi to roam from networks to network, automatically connecting to those that are configured.

If you’re not comfortable configuring networks from the command shell, you can also use the wpa_gui application (aka wpa_suppicant user interface) from the RaspPi’s desktop. It allows you to edit the same configuration from a gui, just as we will do manually in the command shell.

wpa_gui

Installing the WiFi Module Driver

Copy the ‘Linux and Android’ Realtek driver folder from the CD, supplied by the manufacturer, to the ‘tmp’ folder on the RaspPi using WinSCP. Then, run the following commands:

cd /
cd /tmp/Linux\ and\ Android
chmod +x install.sh
sudo ./install.sh

Remember to select #1 when asked to choose a card type:

...
Please select card type(1/2):
1) RTL8192cu
2) RTL8192du
#? 1

You can insert the WiFi Module at this point in the process.

Installing Wireless LAN Security Protocol Software

As detailed in the earlier post, we need to install software that allows us to configure and connect to our WPA/WPA2-secured wireless network. The particular software is referred to as ‘wpa_supplicant’. To install ‘wpa_supplicant’ and the ‘wpagui’, enter the following commands. Note this will check for any upgrades to the RaspPi’s existing software, first. This is a commonly-recommended step. The upgrade command might take a few minutes if you haven’t run this on your RaspPi in a while.

sudo apt-get update && sudo apt-get upgrade
sudo apt-get install wpasupplicant wpagui

Configuring the New WiFi Adapter

Examine the contents of the ‘/etc/networks/interfaces’ file, by entering the following command:

sudo cat /etc/network/interfaces

Unlike in the first post, we will make no changes to this file. The ‘/etc/networks/interfaces’ file should have the default settings for both the current NIC (eth0) as well as for the WNIC (wlan0), as shown below. Note the reference to the ‘/etc/wpa_supplicant/wpa_supplicant.conf’ file. Why are the file’s contents different than in the first post? Because we installed ‘wpagui’.

Raspbian Version of Interfaces File

WPA Supplicant Configuration
Enter the following command, substituting your own SSID (‘your_ssid’) and passphrase (‘your_passphrase’).

wpa_passphrase your_ssid your_passphrase

Based your SSID and passphrase, this command will generate a pre-shared key (PSK), similar to the following. Save or copy the PSK to the clipboard; we will need it in the next step.

Creating PSK

Next, open the ‘/etc/wpa_supplicant/wpa_supplicant.conf’ file using Nano, by entering the following command:

sudo nano /etc/wpa_supplicant/wpa_supplicant.conf

Add the following code at the end of the file. Remember to substitute your_ssid and your_psk_or_passphrase. Note the following settings are specific to my WPA2-secured network. If you are using WPA, refer to this post for the correct WPA settings.

network={
        ssid="your_ssid"
        proto=RSN
        key_mgmt=WPA-PSK
        pairwise=CCMP
        group=CCMP
        psk="your_psk_or_passphrase"
}

Your final file should look similar to this:

Raspbian Version of wpa_supplicant.conf File

Save the file and exit Nano. Lastly, execute the following series of commands to assign an IP address to the new WNIC.

sudo wpa_supplicant -d -c /etc/wpa_supplicant/wpa_supplicant.conf -i wlan0 -D wext
sudo ifconfig wlan0 up
sudo dhclient wlan0
sudo wpa_supplicant -B -c /etc/wpa_supplicant/wpa_supplicant.conf -i wlan0 -D wext 
ip addr show wlan0

You should see an IP Address for ‘wlan0′ displayed. That it, shutdown the RaspPi, remove the Ethernet cable, and restart the RaspPi. Use a program like ‘Advanced IP Scanner’ for Windows, or ‘Fing’ for iOS, to discover the wireless IP address of the RaspPi. The RaspPi will show up with the WiFi chipset manufacturer’s name, ‘REALTEK SEMICONDUCTOR’ or ‘REALTEK SEMICONDUCTOR CORP.’. Use this address to re-connect to the RaspPi.

Need to add another network’s configuration? Simply enter the information in the ‘/etc/wpa_supplicant/wpa_supplicant.conf’ and restart. Here are a few good articles I found on configuring a WiFi Module on the RaspPi with roaming:

http://hostap.epitest.fi/wpa_supplicant/

http://www.cyberciti.biz/faq/linux-ndiswrapper-wpa_supplicant-howto/

http://linux.die.net/man/5/wpa_supplicant.conf

http://ubuntuforums.org/showthread.php?t=1259003

http://ubuntuforums.org/showthread.php?t=318539

http://unix.stackexchange.com/questions/7817/how-to-find-out-which-wi-fi-driver-is-installed

, , , , , , , , , , , , , , , , ,

Leave a comment

Installing a Miniature WiFi Module on the Raspberry Pi (w/o Roaming Enabled)

One of the best purchases I’ve made recently was a Miniature WiFi Module for my Raspberry Pi, from Adafruit Industries. No more having my RaspPi tethered to an Ethernet port on my wireless router. I can have my RaspPi with me, wherever I’m working. At the same time, I have Internet access on both my laptop and the RaspPi. All this for less than $12!

OURLiNK WiFi Module Installed

Background

The Miniature WiFi Module is technically a wireless network interface controller (WNIC). It connects the RaspPi to a wireless local area network (WLAN). Wherever you see the word ‘Interface’ in this post, it is referring to either the new Miniature WiFi Module, or the built-in network interface controller (NIC), which connects the RaspPi to a local area network (LAN) via Ethernet.

In researching how to properly install and configure the WiFi Module, I read a number of articles and posts on the Internet. The simplest approach I found was presented in this article by Macro M.C. on MacroMC.com. Much of the following is based on his article. Marco directly edits the ‘interfaces’ file, instead of also editing the ‘wpa_supplicant.conf’ file, as is demonstrated in other posts. I will only be connecting my RaspPi to a single WLAN in this post. If you will be switching between multiple WLANs with your RaspPi, you might want to investigate the alternate method of editing the ‘wpa_supplicant.conf’ file, or using the wpa supplicant user interface, instead.

I will be installing and configuring my RaspPi using a Windows laptop. However, if you are using a Mac or Linux-based computer, you shouldn’t need change these directions. Also, I am using the WPA2-Personal security protocol on my home’s wireless network. These directions should work for both commonly used WPA and WPA2 wireless network security protocols; I will explain further in step 2. Lastly, since I largely develop Java SE Embedded applications for the Raspberry Pi, I have installed Soft-float Debian “wheezy” on my RaspPi. However, these directions should also work for the more commonly installed Raspbian “wheezy”, as well.

Getting Started

The configuration and installation of the Miniature WiFi Module takes less 15 minutes. I’ve broken the process down into three steps:

  1. Installing the WiFi Module driver
  2. Installing wireless LAN security protocol software
  3. Configuring the new WiFi Module

Before we start, make sure you have the following items available:

  • Your wireless network’s name (aka SSID)
  • Your network security key (aka passphrase)
  • SSH enabled on your RaspPi
  • LAN access to your RaspPi
  • Internet access from your RaspPi
  • PuTTY to your RaspPi
  • WinSCP to copy files to your RaspPi
  • Advanced IP ScannerFing, or similar network scanning software (optional)

Installing the WiFi Module Driver

Don’t insert the WiFi Module into the RaspPi, yet. Instead, connect the RaspPi to your LAN using an Ethernet cable. Make sure the RaspPi has Internet access. Insert the small CD that comes with the WiFi Module into your laptop’s CD/DVD player. Connect to the RaspPi from your laptop using WinSCP. Copy the ‘Linux and Android’ folder from the CD to the ‘tmp’ folder on the RaspPi, as shown below.

Copy Driver to RaspPi with WinSCP

Before we install the driver, let’s examine the current network interface configuration on the RaspPi. Log into your RaspPi using PuTTY. Using the ifconfig command, you should only see the built-in NIC (eth0), as shown in the example below.

Initial View of Network Interfaces

Realtek is the WiFi Module’s chipset manufacturer. To install the Realtek WiFi Module driver on the RaspPi, enter the following series of commands.

cd /
cd /tmp/Linux\ and\ Android
chmod +x install.sh
sudo ./install.sh

During the install you’ll be prompted to select between two card types, enter 1;

...
Please select card type(1/2):
1) RTL8192cu
2) RTL8192du
#? 1

Installing Wireless LAN Security Protocol Software

After installing the driver, we need to install software that allows us to configure and connect to our WPA-secured wireless network. The particular software is referred to as ‘wpa_supplicant’. According to Jouni Malinenwpa_supplicant is a WPA Supplicant for Linux, BSD, Mac OS X, and Windows with support for WPA and WPA2 (IEEE 802.11i / RSN). It is suitable for both desktop/laptop computers and embedded systems. Supplicant is the IEEE 802.1X/WPA component that is used in the client stations. It implements key negotiation with a WPA Authenticator and it controls the roaming and IEEE 802.11 authentication/association of the wlan driver.

To install wpa_supplicant, enter the following commands. Note this will check for any upgrades to the RaspPi’s existing software, first. This is a commonly-recommended step. The upgrade command might take a few minutes if you haven’t run this on your RaspPi in a while.

sudo apt-get update && sudo apt-get upgrade
sudo apt-get install wpasupplicant

Next, enter the following command, substituting your own SSID (‘your_ssid’) and passphrase (‘your_passphrase’).

wpa_passphrase your_ssid your_passphrase

Based your SSID and passphrase, this command will generate a pre-shared key (PSK), similar to the following. Save or copy the PSK to the clipboard; we will need it in the next step.

Creating PSK

Configuring the New WiFi Adapter

The last step is to configure the new WiFi Module (WNIC) for your WLAN. Open the ‘/etc/networks/interfaces’ file using Nano, by entering the following command.

sudo nano /etc/network/interfaces

This file will only have the default settings for the current NIC (eth0), as shown below.

Original Interfaces File Content

To add the new WNIC (wlan0), enter the following lines of code to the end of the ‘interfaces’ file. Substitute you SSID (‘your_ssid’) in quotes and the PSK you generated in the previous step. Do not use the SSID and PSK below, it will not work for your network, it is only an example.

auto wlan0
allow-hotplug wlan0
iface wlan0 inet dhcp
   wpa-ssid "your_ssid"
   wpa-psk b2abb0fcd2f4527e11817de0823a57bb19ba4622f4595062c94ec4dd1370b5fe

Save the file and exit Nano. Shutdown the RaspPi and remove the Ethernet cable. Insert the Miniature WiFi Module and restart the RaspPi. You should not run the RaspPi with both the LAN and WLAN Interfaces connected.

Finding the Raspberry Pi’s Wireless Address
Since you used Dynamic Host Configuration Protocol (DHCP) in the interface’s configuration, the Module has been assigned a new IP address. To find the RaspPi’s new wireless IP address, log directly into the RaspPi and use the ifconfig command. Alternately, we can use a program like ‘Advanced IP Scanner’ for Windows or ‘Fing’ for iOS, to discover the address of the RaspPi. The RaspPi will show up with the WiFi chipset manufacturer’s name, ‘REALTEK SEMICONDUCTOR’ or ‘REALTEK SEMICONDUCTOR CORP.’.

In the example below from Fing on an iPhone, there are two wireless RaspPi’s on my network, an inactive wireless RaspPi at 192.168.1.7, and my active wireless RaspPi at 192.168.1.9.

iPhone Fing View of Network

Here is another view of my network using Advanced IP Scanner on Windows. My active wireless RaspPi at 192.168.1.9.

Advanced IP Scanner View of Network

If you are unable to find your RaspPi on the WLAN, re-connect to the RaspPi directly and check for errors. I had to do this on more than a few occasions while researching this post, mostly due to typos in my interface file. Try rebooting the RaspPi and watch the shutdown and boot-up screens for errors.; network errors will often show up here.

Use the RaspPi’s new wireless IP address you found to connect back into your RaspPi with PuTTY. To better understand how the new WiFi Module (WNIC) is configured, run the ifconfig command, again. This time you should see both the NIC (eth0) and WNIC (wlan0).

Final View of Network Interfaces

Congratulations, your RaspPi is wireless. Please feel free to ‘move about the cabin’. -gs

, , , , , , , , , , , , , , , , ,

12 Comments

Follow

Get every new post delivered to your Inbox.

Join 676 other followers