In the previous tutorial, I explained how to install the Raspbian operating system without a monitor or keyboard, and how to establish an SSH connection to your Raspberry Pi over an ethernet connection. Now I’ll explain how to use that SSH connection to setup a WiFi dongle so you can run your Raspberry Pi wirelessly from a remote desktop application. This is a really useful way to set up your Raspberry Pi, because you will be able to access your it over the internet from anywhere in the world. You can use it from your iPhone, iPad, or Laptop from anywhere with an internet connection.

We have already established an SSH connection to our Raspberry Pi with an ethernet cable, and that is fine if you want to leave it connected to your router with a physical cable. However, I prefer to use a WiFi dongle, which gives me more flexibility with the physical locations I can store the Raspberry Pi while it is running. Be careful when choosing a WiFi dongle for the Raspberry Pi though, because not all WiFi dongles will work without a lot of configuration and headaches. I found that this one from Kootek works great without any driver installations needed.

Still, there are some things that need to be done in order to set up the WiFi dongle to work properly with your Raspberry Pi. I will go through them step by step in this article. You should already have set up the SSH over ethernet connection I described in part one of this post.

Watch the video tutorial here:

Now, login to your Raspberry Pi over SSH through the PuTTY SSH client, and get to the pi@raspberrypi – $ command prompt:

raspi after entering password, before sudo raspi-config

Next, we need to will need to change a few configuration settings in two files: /etc/network/interfaces, and /etc/wpa_supplicant/wpa_supplicant.conf.

To edit these files, we need to use the Raspbian text editor, Nano. At the command prompt, type sudo nano /etc/network/interfaces to edit the /etc/network/interfaces file.

Pro Tip: If you ever want to copy something from your laptop/desktop and paste it into PuTTY, just copy it on your laptop/desktop, then right click with your mouse where you want to paste it into PuTTY and it will be inserted.

Replace the code in the file with this code:

auto lo

iface lo inet loopback
iface eth0 inet dhcp

auto wlan0
iface wlan0 inet dhcp
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf

Afterwards, the file should look like this:

etc,network,interfaces file

Then type ctrl X to exit, and Y to save the changes. Now edit the /etc/wpa_supplicant/wpa_supplicant.conf file by typing sudo nano /etc/wpa_supplicant/wpa_supplicant.conf at the command prompt. Replace the code in the file with this code:

ctrl_interface=/var/run/wpa_supplicant
ctrl_interface_group=0
update_config=1

network={
        ssid="YOUR WIFI NETWORK NAME"
        psk="YOUR WIFI PASSWORD"
        proto=WPA
        key_mgmt=WPA-PSK
        pairwise=TKIP
        group=TKIP
        id_str="YOUR WIFI NETWORK NAME"
}

The file should look like this:

etc,wpa supplicant

The entry for ssid=”YOUR WIFI NETWORK NAME” should be the name of your wireless network, typed exactly as it shows when you connect to your WiFi from another computer. It is case sensitive. The entry for psk=”YOUR WIFI PASSWORD” is the password you normally use to login to your home wireless network. Then re-enter your network name under the id_str=”YOUR WIFI NETWORK NAME” line. Now press ctrl X, then Y, to save the changes to the file.

To see a list of the currently available WiFi networks, enter sudo iwlist wlan0 scan | grep ESSID at the command prompt. To check the status of your WiFi connection, type iwconfig at the command prompt. Your WiFi network name should appear under ESSID: “YOUR WIFI NETWORK NAME”, in my case it is “Siamese“.  If your WiFi connection is successful, you should see a message like this:

iwconfig2

If you see something like Link Quality=0/100 or Signal Level=0/100, go back and make sure that you have entered everything exactly as it is shown in the images. All of the configuration settings should now be saved to work with your WiFi dongle, so enter sudo poweroff into the command prompt to shut down the Raspberry Pi. Now disconnect the ethernet cable and the power cord. Wait about one minute, then plug the power cord back into it without the ethernet cable. Now we will need to use Advanced IP Scanner again to find the new local IP address of the Raspberry Pi when it is connected via WiFi. This has likely changed slightly from when we used it on the ethernet connection. It is useful to keep track of both IP’s if you will be connecting with ethernet at all in the future.

PuTTY is great if all you need to do is access your Raspberry Pi from the command line. However, many features are only available through the Raspbian desktop. In order to access the desktop remotely, we need to install and configure a Remote Desktop Connection. Read How to Set Up Access to the Raspbian GUI via a Remote Desktop Connection for a tutorial on how to do that. And as always, feel free to leave a comment if you’re having trouble setting this up and I’ll do my best to help you out.

Need an easy-to-use way to design circuits and layout PCBs?