How to setup WIFI on Raspbian Raspberry Pi

Configure the network interfaces file so that wlan0 uses DHCP:
pi@raspberrypi:>~ $ sudo nano /etc/network/interfaces
Change the line:
iface wlan0 inet manual
To:
iface wlan0 inet dhcp
Press <CTRL>O to save the file (press enter when prompted for the file name to write to).
Press <CTRL>X to exit Nano

Search for available WIFI access points: At the Raspberry Pi terminal prompt type:
pi@raspberrypi:~ $ sudo iwlist wlan0 scan | grep ESSID

Configure wpa_supplicant.conf with your chosen WIFI ESSID
pi@raspberrypi:~ $ sudo nano /etc/wpa_supplicant/wpa_supplicant.conf
# Add to the bottom of the file:
network={
ssid=”Chosen_ESSID”
psk=”WIFI_Password”
}

Press <CTRL>O to save the file (press enter when prompted for the file name to write to).
Press <CTRL>X to exit Nano

wpa_supplicant should hopefully detect the changes to these files and connect the WIFI interface to the WIFI access point.

To check that your WIFI network interface is working, type the following at the Raspberry Pi terminal prompt:

pi@raspberrypi:~ $ ifconfig -a
  lo
  Link encap:Local Loopback
  inet addr:127.0.0.1 Mask:255.0.0.0
  inet6 addr: ::1/128 Scope:Host
  UP LOOPBACK RUNNING MTU:65536 Metric:1
  RX packets:0 errors:0 dropped:0 overruns:0 frame:0
  TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
  collisions:0 txqueuelen:0
  RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
wlan0
  Link encap:Ethernet HWaddr 00:e0:4d:04:ff:b3
  inet addr:192.168.1.30 Bcast:192.168.1.255 Mask:255.255.255.0
  inet6 addr: fe80::6790:abf7:9305:4ac8/64 Scope:Link
  UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
  RX packets:19327 errors:0 dropped:0 overruns:0 frame:0
  TX packets:1295 errors:0 dropped:0 overruns:0 carrier:0
  collisions:0 txqueuelen:1000
  RX bytes:1348216 (1.2 MiB) TX bytes:153317 (149.7 KiB)

You should see wlan0 listed. You IP address will be shown on the “inet addr:” line.

If you don’t see am IP address, the take down and bring back up the wlan0 interface by typing the following at the Raspberry Pi terminal prompt:

pi@raspberrypi:~ $ sudo ifdown wlan0
pi@raspberrypi:~ $ sudo ifup wlan0

Test that your network connection is working:

pi@raspberrypi:~ $ sudo ping www.google.com
 PING www.google.com (62.252.191.216) 56(84) bytes of data.
 64 bytes from m984-mp1.cvx2-c.lng.dial.ntli.net (62.252.191.216): icmp_seq=1 ttl=58 time=20.2 ms
 64 bytes from m984-mp1.cvx2-c.lng.dial.ntli.net (62.252.191.216): icmp_seq=2 ttl=58 time=17.6 ms
 64 bytes from m984-mp1.cvx2-c.lng.dial.ntli.net (62.252.191.216): icmp_seq=3 ttl=58 time=22.5 ms
 64 bytes from m984-mp1.cvx2-c.lng.dial.ntli.net (62.252.191.216): icmp_seq=4 ttl=58 time=21.0 ms