Setup WiFi on Raspberry Pi – Raspbian

First make sure that Raspbian OS is all up to date with the latest drivers. To do this, run the following commands:

sudo apt-get update
sudo apt-get upgrade
sudo apt-get autoremove

Make a backup of the WIFI configuration file ‘/etc/wpa_supplicant/wpa_supplicant.conf‘ before we start to make changes.

sudo cp /etc/wpa_supplicant/wpa_supplicant.conf /etc/wpa_supplicant/wpa_supplicant.conf.bak

Now we can edit this file:

sudo nano /etc/wpa_supplicant/wpa_supplicant.conf

You need to change ‘YOUR_SSID‘ and ‘YOUR_PASSWORD‘ for your WIFI name and password. Once done, save and close it.

ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
 
network={
        ssid="YOUR_SSID"
        psk="YOUR_PASSWORD"
        proto=RSN
        key_mgmt=WPA-PSK
        pairwise=TKIP
        auth_alg=OPEN
}

Now reboot the system.

Once the system is back up and running, you can run `ifconfig` to see if the change we have made has worked. Here’s a sample output of the WLAN adapter that has been assigned an IP address (192.168.1.39 in this example).

wlan0     Link encap:Ethernet  HWaddr 00:13:ef:b0:2a:8b  
          inet addr:192.168.1.39  Bcast:192.168.1.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:1856 errors:0 dropped:981 overruns:0 frame:0
          TX packets:1468 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:1843018 (1.7 MiB)  TX bytes:234797 (229.2 KiB)

That’s it.