This quick tutorial aims to show you the steps required to set up the pcDuino WiFi Dongle with everyone’s favorite fiberglass-flavored development board: the Raspberry Pi (model B or model A).
This WiFi dongle is a cheap solution to adding network connectivity to your Pi, if you don’t have Ethernet nearby. It’s easy to set up, once you get the hang of editting text files and typing Linux commands. It’s not quite plug-and-play-easy, but it’s easy enough.
- pcDuino WiFi Dongle
- Powered USB Hub with at least 3 ports
- Raspberry Pi with these accessories:
- USB mouse and keyboard
- 4+ GB SD card with Rasbpian installed and set up
- 5V USB power supply that can source at least 700mA, and a micro-B USB cable to connect between it and the Pi
- Display connected to the Pi via either HDMI or component
There’s not a whole lot to this hardware setup:
- Power down the Pi.
- Find an open USB slot.
- Plug the WiFi Adapter into USB slot.
The trick is finding a USB slot on the Pi. It’s only got two, and those are often swallowed up by a keyboard and mouse. If you’re out of available USB slots, you’ll need to find a powered USB hub to get more USB space.
A powered USB hub serves the USB keyboard, mouse, and WiFi adapter. It also helps to offload a lot of the Pi’s powering duties.
Make sure the hub is powered. The WiFi adapter can pull a lot of current, which the Pi isn’t especially well-suited to sourcing.
Note: It’s possible to perform this setup with solely a USB keyboard, plugging that and the WiFi adapter into the Pi’s USB sockets. We generally recommend against this, as the WiFi adapter can pull a lot of current and potentially damage the Pi. Attempt at your own risk!
Verifying the Driver
After connecting the adapter to your Pi, go ahead and power it up. Once the Pi has booted up, open up LXTerminal and issue this command:
[email protected] ~ $ lsusb
This will list all USB devices attached to the Pi. Among other things, like your keyboard and mouse, you should see a listing for a Ralink Technology Corp. RT5370 Wireless Adapter.
That’s the WiFi adapter, and it’s a good sign if you see that. It means the adapter has been recognized, and the RT2800 USB driver should have been installed for it.
There are two configuration files we need to edit to set up WiFi:
- /etc/network/interfaces – Configures DHCP (or static) and tells the wireless utility where to look for your authentication settings.
- /etc/wpa_supplicant/wpa_supplicant.conf – Stores your wireless network’s SSID and authentication settings.
To edit both of these files we’ll use Nano, Raspbian’s default terminal text editor.
Open up LXTerminal to begin. Then, to open interfaces with the Nano editor, enter this command:
[email protected] ~ $ sudo nano /etc/network/interfaces
That command will open interfaces in Nano. By default it should look like this:
The default interfaces file layout.
First delete or (if you’re a digital packrat) comment out the bottom three lines (iface wlan0 inet manual, wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf, and iface default inet dhcp).
Next, following line 4 (iface eth0 inet dhcp), add these six lines:
iface wlan0 inet dhcp
wireless mode managed
wireless essid any
All done! Save interfaces by pressing CTRL+O, keep the file name the same when it asks. Then exit with CTRL+X. Your new interfaces files should look like this:
This is a fairly generic configuration that sets the Pi up to receive an IP address dynamically, through DHCP.
If your network requires that you statically assign an IP you’ll need to use something like this instead:
iface wlan0 inet static
wireless mode managed
wireless essid any
Make sure to modify the IP addresses to match the needs of your network.
Now that our network interface is configured, the next step is to specify the SSID and authentication parameters, which we’ll do in wpa_supplicant.conf.
wpa_supplicant.conf is a configuration file for wpa_supplicant, a piece of software used to implement WPA and other security protocols that WiFi networks implement.
Before continuing on, you should know what kind of security protocol (WPA, WPA2, WPA-PSK, WPA2-PSK, etc) your network requires. And, obviously, you’ll need to know the name (SSID) of your network as well.
Open wpa_supplicant.conf in Nano with this command:
[email protected] ~ $ sudo nano /etc/wpa_supplicant/wpa_supplicant.conf
Lot’s of typing! For lazy folk, don’t forget you can press Tab to ask the terminal to try to finish a directory location for you.
By default, wpa_supplicant.conf should have two lines at the top:
Leave those be, we’ll be adding some extra information below them.
Now it’s time to “choose your own adventure”. What, exactly, you fill this file out with depends on your network’s authentication protocols. Here are a few example configurations for the file:
Open Authentication With No Encryption
This is about as basic as it gets. If you’re trying to connect to an open network, all you need to know is the SSID:
Just replace yourNetworkSSID with your WiFi network’s name.
Network with Authentication (WPA, WPA2-PSK, etc)
If your network does require authentication with a passkey, you’ll need to enter two parameters:
Again, pretty bare bones. This should work for networks using WPA and WPA2-PSK, and should be agnostic to the cipher (TKIP, CCMP).
If your network does not broadcast its SSID, you’ll need to add scan_ssid=1 to the list. For example, here’s a configuration for a hidden open network with no authentication:
This will connect to a hidden network named PiFi with open authentication.
Read More info….