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

Raspberry Pi Wi-Fi
Published: by Renier Delport
Collection(s): 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):

 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.

USB 2.0 Wireless Wi-Fi Adapter Dongle
Supplier: BangGood
Delivers: Worldwide
Price range: U$D 7 / ZAR 105
Description: Small and compact (2×1.5 x 0.6cm), generic, IEEE 802.11n, 2.4 GHz Wi-Fi adapter dongle. Up to 150 Mbps. Perfect for PC and Raspberry Pi.

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 shit. 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

Fiverr – Freelance services marketplace for the lean entrepreneur
Fiverr – Freelance services marketplace for the lean entrepreneur
21 September 2018
Fiverr is the world’s largest freelance services marketplace for entrepreneurs to focus on growth & create a successful business at affordable costs. More…
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.