What Do I Need?

In addition to the above items, you will need to check the configuration of the Wi-Fi network you plan to connect to, you will need the SSID, password, and encryption type/method (e.g. the node is using WPA with TKIP shared-key encryption).

Enabling the Wi-Fi Dongle via the Terminal

To get started, power up your Raspberry Pi unit without the Wi-Fi card attached. At this point, the only network device should be the onboard Ethernet NIC (which you have connected to your network via Ethernet cable so you can remotely access the headless device).

Connect to your Pi via SSH, and login.

At the prompt, enter the following command:

sudo nano /etc/network/interfaces

In the nano text editor, you’ll see something like this:

auto lo

iface lo inet loopback
iface eth0 inet dhcp

That’s the very basic configuration that governs your Pi’s Ethernet connect (indicated by the eth0 portion). We need to add on a very minor bit to enable the Wi-Fi. Use the arrow keys to move down below the existing entry and add the following lines:

allow-hotplug wlan0
iface wlan0 inet dhcp
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf
iface default inet dhcp

Once you’ve annotated the file, press CTRL+X to save the file and exit the nano editor. At the prompt again, enter the following command:

sudo nano /etc/wpa_supplicant/wpa_supplicant.conf

Compare the contents of the file, if it exists, to the following code. If the file is empty, you can use this code to populate it. Take note of the commented lines (indicated by the # marks) to reference which variable you should use based on your current Wi-Fi node configuration.

ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1

network={
ssid="YOURSSID"
psk="YOURPASSWORD"

# Protocol type can be: RSN (for WP2) and WPA (for WPA1)
proto=WPA

# Key management type can be: WPA-PSK or WPA-EAP (Pre-Shared or Enterprise)
key_mgmt=WPA-PSK

# Pairwise can be CCMP or TKIP (for WPA2 or WPA1)
pairwise=TKIP

#Authorization option should be OPEN for both WPA1/WPA2 (in less commonly used are SHARED and LEAP)
auth_alg=OPEN
}

When you’re done editing the file, press CTRL+X to save and exit the document. Now is the time to unplug the Ethernet cable and plug in the Wi-Fi USB sitck.

You will then want to reboot the R-Pi

sudo reboot

When the device finishes rebooting, it should automatically connect to the Wi-Fi network. If for some reason it fails to appear on the network, you can always plug the Ethernet cable back in to double check the two files and the variables you altered.