How to connect to a Raspberry Pi via wireless/WiFi

IMPORTANT: Normally you'd turn off your Raspberry Pi by using the shutdown command from a command line or use an option in a graphical user intereface. But we're still just trying to connect to the Pi at this point. If you have problems, don't remove power if it's been on for only a few seconds since there may be data waiting to be written to the SD card. Wait a minute or so before turning it off or watch the SD card indicator light to see when it's been quiet before removing power.
Connect to the modem via wireless.
Connect the Raspberry Pi to the modem via wireless.

This involves connecting your Raspberry Pi wirelessly using WiFi through your WiFi modem. The computer can be connected to the modem using wireless as well, or using an Ethernet cable.

Telling your Raspberry Pi your WiFi network name and password

Before you can connect wirelessly to you Pi you'll first need to do some configuration on the Pi. You need to put your WiFi network name and your WiFi password in a configuration file.

If you have a keyboard and display directly connected to your Pi then that's easy. Just log into your Pi and do the steps below. But if you don't, which I don't since mine will be embedded in robots and things that I make, then telling it this information is more difficult.

Without a keyboard and display attached to your Pi you'll have to connect to the Pi using an Ethernet cable and log into your Pi. Two methods for doing that are detailed at the two links below. Choose whichever you want:

In either case, whether using a keyboard and display connected directly to your Pi or using one of the two methods detailed at the two links above, you should now be logged into your Pi.

To tell the Pi your WiFi network name and password you'll need to edit a file called /etc/wpa_supplicant/wpa_supplicant.conf.

1. On the Raspberry Pi, go to /etc/wpa_supplicant. Since I was doing this from a command line terminal, I did:

Go to /etc/wpa_supplicant.
Go to the /etc/wpa_supplicant directory.

2. Edit the file that you'll find there called wpa_supplicant.conf. To do that I first used the "ls" command to verify that it was there and then I used the editor called nano as follows:

Edit the "wpa_supplicant.conf" file.
Edit the

3. In the wpa_supplicant.conf file, go to the bottom and add what's shown in the example below but put your own WiFi network name in place of "BOB" and your own WiFi password in place of "orange". To make sure it's clear, here it is in plain text:

network={
        ssid="BOB"
        psk="orange"
}
Adding wireless network information.
Adding wireless network information to the interfaces file.

4. Save the file by pressing Ctrl-O and exit the editor by pressing Ctrl-X.

5. Restart the Pi. Make sure to use the shutdown command first to give the editor and anything else time to write to the SD card.

Connecting to WiFi

Once you've told the Pi the WiFi information as detailed in the steps above, it's time to try it out.

I have the Raspberry Pi 3 Model B which has WiFi built in. If you have a Pi that doesn't then you'll need a WiFi dongle as shown below. Plug that into any of the USB ports of your Pi.

A WiFi dongle.
A WiFi dongle.
Plugging in the WiFi dongle.
Plugging the WiFi dongle into the Raspberry Pi's USB port.
WiFi dongle plugged into the Pi.
A WiFi dongle plugged into the Raspberry Pi.

Next, give power to your Raspberry Pi. You should see various lights lit up at different times.

Finding the Pi's IP address

After a minute or so the Raspberry Pi should have connected to your WiFi. To start talking to it from your computer, you need to find out its IP address.

One way to do that is to bring up a web browser on your computer and go to your WiFi modem's webpage, most modems have one. Type in the IP address of your modem to connect to it as is shown in the snapshot below. Type the address into the browser's address bar, located near the top-left of the browser window, and press Enter. If you don't know the modem's IP address then contact your internet provider to get it. It'll be something like 192.168.1.1 or 192.168.2.1. In the snapshot I'm using the Firefox browser running on Windows Vista and have already given it the IP address following the above steps. You can see it circled in the top, left. Note that I typed in only the "192.168.2.1" in the address bar. The browser filled in the stuff that you see following it. My modem is called the Bell Home Hub 1000 and that's what you see in the webpage that came up. Unless you have the same modem, yours will look different but have similar features.

In the Network section of the webpage I found a diagram of what's connected to the modem. Circled in red at the bottom, you can see that it's showing the Raspberry Pi as being connected and it's giving its IP address, 192.168.2.15, the one we're looking for.

Finding the Raspberry Pi's IP address in Firefox.
Finding the Raspberry Pi's IP address in Firefox.

Using the IP address to connect to the Pi

Now that you have the Pi's IP address, you can connect to it however you want, provided the setup on your Pi allows you to connect.

In my case, the setup that came with Raspbian on my SD card allowed me to ping the Pi to see if I could get to it at all. This is done by running the ping command and passing it the Pi's IP address, as shown below. Doing a ping is like tapping it on the shoulder to see if it's there.

Pinging the Pi from a Windows Command Prompt window.
Pinging the Raspberry Pi from a Windows Command Prompt window.

I could also start up an SSH (secure shell) session using PuTTY, free software that most Pi users use at one point or another. In the snapshot below I'm running it from a Windows Command Prompt window. Once it was up, I typed in the Pi's IP address.

Running PuTTY from a Windows Command Prompt window. Note I typed in the Pi's IP address.
Running PuTTY from a Windows Command Prompt window.

Note above that the Connection type is selected as SSH and so when I click on the Open button I get a new window with an SSH running in it. I'm asked to log in. For a new Raspberry Pi system the username is usually pi and the password is raspberry.

Logging into an SSH session.
Logging into an SSH session on a Raspberry Pi.

At this point you are connected and able to start typing commands.

rimstar.org
Contact:
Liked this? Share it with: