Connect your Raspberry Pi to Wi-Fi network in 5 easy steps

In This tutorial we will show you how to connect your Raspberry Pi to a Wi-Fi network in few easy steps.

The Wi-Fi adapter used is Edimax EW-7811UN, but the same steps apply for many other Wi-Fi adapters such as Ralink RT5730.

Hardware

  • Edimax EW-7811UN or similar Wi-Fi adapter

Software

  • This tutorial has been tested with success on 2013-09-25-wheezy-raspbian

 

Step 1 – Connect to Raspberry Pi

Connect to your Raspberry Pi via SSH or launc a LXTerminal app.

Step 2 – Open the command line interface for wpa_supplicant (cli)

Type

wpa_cli

in the command line and hit Enter. This will open wpa_supplicant command line interface.

Step 2

 

Step 3 – Scan for available Wi-Fi networks and display the results

Type

scan

in the command line and hit Enter. This will scan for all Wi-Fi networks in range.

To display results type

scan_results

. A list of all networks in range will appear.

Step 3

 

Step 4 – Add new network

To add a new Wi-Fi network to Raspberry Pi type

add_network

and hit Enter. You will see a number displayed back to you. Make a note of this number as we will have to use it in the following steps.

Step 4-1

 

Next type

set_network 0 ssid "yourSSID"

and hit Enter. Replace yourSSID with the network SSID you want to connect to and number 0 with the number that was returned by add_network command. We are going to connect to the network pirate008. You should get OK as a reply if the entry was successful.

After SSID has been added we need to enter a password for the network. To do that type

set_network 0 psk "yourPassword"

and hit Enter. Replace yourPassword with your network password and number 0 with the number that was returned by add_network command. If the password entry was successful you should get OK as an answer. If FAIL is returned then repeat previous step making sure that the password is typed in correctly.

Step 4-2

Step 5 – Save configuration and reboot

To make sure that the changes are saved type

enable_network 0

and hit Enter. Replace 0 with the number that was returned in step 4. Then type

save_config

to save the configuration file and finally type

quit

to exit the wpa_supplicant command line interface.

Step 5

Reboot your Raspberry Pi by typing

sudo reboot

in the command line and after Raspberry Pi is rebooted it should be connected to your chosen Wi-Fi network.