For a lot of projects/applications it is useful to have a wireless connection on your pi. It turns out this is really easy to do…

GUI Method:

One way is to use the GUI in Rasbian. Start up your pi either by attaching a screen or connecting remotely via a VNC session and click on “WiFi Config” which can be found on the desktop.
This will open the wpa_gui. Click on “Scan” to search for broadcast SSIDs.

Double click on your network will bring up the following gui which will allow you to select the correct authentication (etc.) and enter the network’s password.

Add the network and then click “connect” to connect to the network.

That’s it! Everything should be working.

CL Method:

But what if don’t have access to the GUI? Maybe you are running headless and don’t want to be forced into installing a VNC server. Luckily you can also configure the wireless from terminal.

To add our wireless interface we will need to edit the interfaces file:
    $ sudo nano /etc/network/interfaces

You will probably see a section for you Ethernet connection (and maybe wireless if you have configured wireless in the past):
    auto lo
    iface lo inet loopback
    iface eth0 inet dhcp

Below the Ethernet (lo) interface we need to add the following:
    allow-hotplug wlan0
    iface wlan0 inet dhcp //iface wlan0 inet manual
    wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf
    iface default inet dhcp

You’ll also want to edit the settings in the wpa_supplicant.conf file which includes the details of the network you will be connecting to:
    $ sudo nano /etc/wpa_supplicant/wpa_supplicant.conf

Wou’ll want to enter something along the following lines:
    ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
    update_config=1

    network={
        ssid=”Thomson4E4823
        psk=”raspberry
        # Protocol type can be: RSN (for WP2) and WPA (for WPA1)
        proto=WPA
        # Key management type can be: WPA-PSK or WPA-EAP (Pre-Shared or Enterprise)
        key_mgmt=WPA-PSK
        # Pairwise can be CCMP or TKIP (for WPA2 or WPA1)
        pairwise=TKIP
        #Authorization option should be OPEN for both WPA1/WPA2 (in less commonly
        used are SHARED and LEAP)
        auth_alg=OPEN
}

Advertisements