Connect to WiFI

Setting up WiFi in a Raspberry Pi is easy! I am using the latest version of Raspbian but the process is more or less the same for other Linux distributions as well. Before we do anything, however, let’s take a moment to update and upgrade the repositories with the following commands:

sudo apt-get update
sudo apt-get upgrade

This is the first step and in general it’s always good to run those commands before you do any new project.
Next have a look here for supported WiFI hardware: RPi USB Wi-Fi Adapters

If your hardware is supported out of the box then you can choose one of the following methods in order to connect to any WiFi network. Just a single method is OK, you don’t have to follow everything into here. If you hardware is not supported the you can run the process of driver installation. I will have a post about that soon.

 
 

Using methode 1

Type the command:

sudo nano /etc/network/interfaces

depending of your system and the previous configuration that you have made you are going to see something like that:

This is the nano text editor and you have to add a few lines of “code” in here.
If your network that you want to connect is using WPA/WPA2 then type:

auto wlan0
allow-hotplug wlan0
iface wlan0 inet dhcp
wpa-ssid "WiFi Name"
wpa-psk "Password"

If your network is using WEP then type:

auto wlan0
allow-hotplug wlan0
iface wlan0 inet dhcp
wireless-essid WiFI Name
wireless-key Password

Where WiFi name is the broadcasted name (the SSID in other words) that you are going to see when you are scanning for a WiFi network in any computer and Password is the access code you are using. Have in mind that for WEP networks the quotes ( ” ” ) are not there!

For example I want to connect to my home network (a WPA one under the name MyWiFi) and after typing a few lines we have this result:

Look if everything is as suppose to be (WiFI name, WiFi password, any spelling mistakes etc) and then hit Ctrl-X. It will ask you if you want to save changes. Press Y and then enter.

Reboot you Pi:

sudo reboot

Let the Pi a little bit of time to reboot and connect to the WiFi. And you are ready!

 
 

Using methode 2

This method uses again the terminal but gives you many more choices together with WiFi scanning. On top of those, you can select to automatically reconnect to the desired WiFi network is for some reason the previously made connection failed.

Type the command:

sudo apt-get install wicd-curses

Let the Raspberry Pi to install all the packages and then we are ready to start. Type:

sudo wicd-curses

You’ll get a list of the wireless networks found by the Raspberry Pi:

Use the up and down keyboard arrows to select your WiFi. Then hit the right arrow in order to configure it:

You can insert the WEP or WPA key, you can assign a static ip or dhcp, configure alternative dns and so on. Remember to check the “Automatically connect to this network” box if you don’t want to press connect and connect again and again every time you power cycle your Pi.

When you’re done press F10 to save. Then once more you are ready and connected to the selected WiFi.

Is seems that if you run the first command in order to install the wick tools and you don’t have any USB WiFi dongle already connected you will not be able to see any available WiFi network. In order to solve this problem you can connect your dongle prior the execution of the first command or when you run the wicd-curses hit P to go to the configuration menu and at the wireless interface type wlan0

 
 

Using methode 3

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: