3 ways to connect a Raspberry Pi 3 to a network using Wi-Fi

Raspberry Pi Wi-Fi
Published: by
Categories
Raspberry Pi

The Raspberry Pi 3 comes equipped with on-board Wi-Fi and an Ethernet port. Establishing a network connection using Wi-Fi can be done in a couple of ways.

This is an ongoing post. Please suggest corrections, explanations, etc. in the comment section at the bottom of this page.

From a hardware point of view, using Wi-Fi connectivity offers more freedom, but is a little more complicated to configure when compared with a wired connection. Using an Ethernet cable will need no configuration and will allow network connection with an automatic assigned dynamic IP address. Using Wi-Fi will also assign a dynamic IP, but will need the network name (SSID) and the password (also called the passphrase or pre-shared key) of the wireless network. Also read setting up a static IP address on the Raspberry Pi using Wi-Fi.

This post will show how to configure a wireless network connection using the Raspi-config tool (Raspbian Stretch only), the Raspbain GUI (Raspbian Jessie and Raspbian Stretch) and the terminal. It will also show how to remove the settings again.

Before or after the chosen method, an IP address will indicate that the Raspberry Pi is connected to a local network. To get the IP address, use the following command in the terminal:

hostname -I

The simplest way to test whether the Raspberry Pi is connected to the internet is by using the ping command from the terminal:

ping -c 5 google.com

Configuring the Wi-Fi settings using the terminal

Using the terminal to configure the Raspberry Pi 3’s Wi-Fi settings is the most accessible way, but also the most complicated. It offers a few more options when compared with the other options. The terminal is accessible on all the versions of Raspbian, either from the boot sequence, or from the terminal icon at the top of the GUI.

Raspbian Stretch GUI terminal
To access the terminal from the Raspbian Stretch’s GUI, use the terminal icon on the top right of the screen. Raspbian Jessie is the same.

The configuration settings for wireless connectivity is stored in the wpa_supplicant.conf file. To make a backup of the original file use:

sudo cp -p /etc/wpa_supplicant/wpa_supplicant /etc/wpa_supplicant/wpa_supplicant.original

To open and modify the wpa_supplicant.conf file:

sudo nano /etc/wpa_supplicant/wpa_supplicant.conf

and add the following lines at the end (there might already be other lines added by Raspi-config – don’t remove them):

network={
 ssid="NETWORK_NAME" # required, keep the quotation marks
 psk="NETWORK_PASSWORD" # required, keep the quotation marks
 key_mgmt=WPA-PSK # required, WPA-PSK or WPA-EAP
 proto=RSN # optional, RSN for WPA2 or WPA for WPA1
 pairwise=CCMP # optional, CCMP for AES or TKIP for TKIP
 auth_alg=OPEN # optional, OPEN for WPA1/2 or SHARED or LEAP
}

The default optional settings will work in most cases, but read the # comments for custom settings. Comment out (using #) or remove the line to use the default setting. Press Ctrl + X to exit and save the changes.

To remove the wireless network settings, simply remove all the network lines again and reboot the Raspberry Pi using:

sudo reboot

Configuring the Wi-Fi settings using the Raspbian GUI

As from Raspbian Jessie, the GUI offers a very easy way to configure the Wi-Fi settings.

Raspbian GUI network settings
The network configuration icon for Raspbain Jessie. This icon looks a bit different in Raspbain Stretch.

The network configuration icon is situated on the top right section of the GUI (next to the sound icon). By clicking on it, the available wireless networks will be selectible, after which the password (Pre Shared Key) will be prompted for.

Raspbian GUI Wi-Fi configuration

The configuration settings for wireless connectivity is stored in the wpa_supplicant.conf file. To remove the wireless network settings, see using the terminal commands mentioned earlier.

Configuring the Wi-Fi settings using the Raspi-config tool

As from Raspbian Stretch, the Wi-Wi settings can be configured using Raspi-config, the GUI and the terminal. Using the Raspi-config tool is an easy way (when compared with using the terminal) to configure the wireless settings using Raspbian Stretch Lite. The Raspi-config tool can be accessed using the following terminal command:

sudo raspi-config

To use Raspi-config from the terminal, the keyboard arrow buttons are used to move to the desired menu item and it is selected with the Enter key. The Escape key can also be used cancel certain options and to exit Raspi-config.

Raspbian Stretch Raspi-config Network Options

To change the Wi-Fi settings, go to Network Options -> Wi-Fi. From the menu, select your country, enter the SSID (network name) and password. Once this is complete, Raspi-config will restart.

The configuration settings for wireless connectivity is stored in the wpa_supplicant.conf file. To remove the wireless network settings, see using the terminal commands mentioned earlier.

Related product links

Please support Behind The Scenes by using these links to purchase these related products online from our partner websites. Links will open in a new window...

About the author
Renier busies himself with improving his English writing, creative web design and his websites, photoshopping, micro-electronics, multiple genres of music, superhero movies and badass series.

Save, share & Disqus

Use the buttons below, on the left or the bottom of this page to share this post. Your comment is important, but don't be a knob. Keep it constructive and polite.

Comment via Disqus

Disqus is a worldwide comment hosting service for web sites and online communities. This secure platform ensures a pleasant commenting environment which is manageable from one account. Use the Login button to sign up.

More Raspberry Pi related posts

Try one of Lynda.com’s online software and skills learning courses
Try one of Lynda.com’s online software and skills learning courses
25 April 2019
Ad: Improve your knowledge on anything from programming to business skills with Lynda.com’s huge range of professional video courses. More…
Raspberry Pi media centre
Using a Raspberry Pi as a cheap media centre
2 March 2019
With a plethora of mini media centre boxes becoming readily available, it comes as no surprise that open source platforms are also available for this purpose. Kodi is one such platform and it is available to be installed onto a Raspberry Pi. More…
Categories
KodiRaspberry Pi
Getting started with private projects on Raspbian and Bitbucket
Getting started with private projects on Raspbian and Bitbucket
28 October 2018
Bitbucket is a great alternative to Github to start, store and track simple programming dependant project files. On a Raspberry Pi it can be simply done using Raspbian. In addition to Github, projects uploaded to Bitbucket with less than 6 contributors can be kept private and won’t cost a cent. More…
Taking a screenshot on a Raspberry Pi from a remote location
Taking a screenshot on a Raspberry Pi from a remote location
1 July 2018
Whether it is for debugging purposes, making images for tutorials or capturing a moment in a game, screenshots (screengrabs or screen captures) often come in handy. Most operating systems, including Raspbian, will have options to create screenshots by using the keyboard, but what if no keyboard is connected? More…
Categories
Raspberry Pi