Set Up WiFi on a Raspberry Pi 2
Setting up WiFi on a Raspberry Pi (Pi) is a very simple process if you are using the latest version of Raspian, it can be very helpful if you want to use your Pi in an indoor/outdoor environment where being connected via an Ethernet cable is not possible.
This guide will take you through the steps to set up the WiFi using the desktop if you have a keyboard and monitor connected or using Putty and command line (CLI).
In this tutorial I will be using the following materials:
Setting Up WiFi Using the Desktop
This process assumes that you have completed the initial setup of your Pi and have a keyboard, mouse, monitor and WiFi dongle attached. If you have access to your desktop then there is no need to have an ethernet cable connected. Turn on your Pi and wait for it to boot to the desktop environment then locate the network icon on the top right-hand side of your menu bar.
Click on the icon to see a list of available WiFi networks.
Select your network and you will be presented with a popup requesting your router password (This can normally be found on the back of your router).
Enter your password and you should now see your network icon change to a WiFi icon.
Your RPi should now be connected to your Wifi network, click on the Wifi icon to confirm that the green tick is on the WiFi network that you selected. A further step that you may consider is to set up your WiFi connection with a static IP address.
Setting up WiFi Using the Command Line Interface (CLI)
This process again assumes that you have completed the initial setup of your Pi but this time without any keyboard or monitor attached. You will need to have a network cable connected and SSH enabled so that communication can occur for the setup.
You will need to know the IP address of your Pi so you can connect to it, this can be done in several ways depending on your setup. I recommend following the instructions from the Raspberry Pi Foundation.
Once your ready connect the USB dongle and reboot the Pi, SSH to the Pi using Putty.
Scan for your WiFi network using the following command.
This command will provide you with the ESSID of your WiFi, again you will need to know the password for your router.
Next, we will need to edit the wpa_supplicant.conf file by entering the following command
Go to the bottom of this file and enter the following statement including your ESSID and password
Ensure that you include the double quotes.
In order to exit and save the file with the same name, press CTRL+X and then Y and finally hit enter. Shutdown the Pi.
Once your Pi is shutdown disconnect the power cable and the ethernet cable, then restart. Again you need to know your IP address of the Pi so follow the previous techniques from the Raspberry Pi Foundation, use this IP address to log into the Pi using SSH.
In order to confirm that the WiFi connection is working as expected, you can execute the following two commands.
The first command will provide you with the current IP address while the second is more wireless specific and shows SSID, frequency, power, link quality, etc. If the Link Quality reads 0/70, then the WiFi adapter didn’t get connected properly.
If for any reason you want to activate/deactivate the WiFi capabilities of the Pi then the following two commands can be used.
Finally, if you want a known IP address so that you don’t have to look it up each time you restart follow this tutorial to set a static IP for the Wi-Fi connection.
If you have any thought’s about this article, improvements or errors let me know in the comments below and if you found this helpful, why not share it with others.