# Connecting Raspberry Pi to WiFi

Raspberry Pi doesn’t come with WiFi adapter built-in. It only have one fast ethernet (RJ45) port to connect it to the network. In order to make your Raspberry Pi become wireless, there are many small-sized WiFi USB dongle which is work out of the box with Raspberry Pi. One of them is TP-LINK TL-WN823N WiFi USB dongle.

Plug in the dongle to the Raspberry Pi USB port, then it should be directly recognized by Raspberry Pi as wlan0 interface. If it doesn’t, try rebooting your Raspberry Pi. Check it by using ifconfig command, and you should see something like below:

wlan0     Link encap:Ethernet  HWaddr 64:70:02:08:6b:64
UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
RX packets:289 errors:0 dropped:333 overruns:0 frame:0
TX packets:38 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:49192 (48.0 KiB)  TX bytes:5594 (5.4 KiB)

Notice that the wlan0 interface doesn’t have any IP address assigned to it.

To configure the IP address of your Raspberry wlan0 interface, edit the following file using nano / gedit / vi or any other text editor you like. Assuming that your Raspberry Pi will be getting it’s IP address using DHCP, put the following line to your /etc/network/interfaces file

allow-hotplug wlan0
auto wlan0
iface wlan0 inet dhcp
wireless-essid Nano-Hotspot
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf

In this example my Hotspot SSID is Nano-Hotspot which is protected by a WPA-PSK key. On the last line, I mentioned a wpa_supplicant.conf file which I use to store information needed to connect to the hotspot, such as the key itself.

If your hotspot configuration is open, which is not requiring to put any password or key, then the following configuration on the /etc/network/interfaces is sufficient enough.

allow-hotplug wlan0
iface wlan0 inet dhcp
wireless-essid Nano-Hostpot

In case that your hotspot requires access key, then you need to know the hotspot password to generate the PSK key in order to be able to connect to.

#### Generating Pre-Shared-Key Configuration

Open up Raspberry Pi terminal and execute the following example command:

pi@raspi:~# wpa_passphrase Nano-Hotspot secretpassword
network={
ssid="Nano-Hotspot"
psk=225df5bb1a27c09cbef5ed023079bc7e7845d64037a98cdb1d8a59f1e0b475a3
}
pi@raspi:~#

Where Nano-Hotspot is the SSID name and secretpassword is the password itself in this example. Copy the above command output to the /etc/wpa_supplicant/wpa_supplicant.conf file. Save and reboot your Raspberry Pi. The next time you boot your Raspberry Pi, it should be automatically connected to the defined hotspot.

#### How do I know whether my Raspberry Pi is connected or not?

Simple, if your WiFi dongle internal LED is lit or blinking then it is working. Then check it’s configuration using ifconfig command. In my case it was assigned an IP address of 192.168.0.12 like the following:

wlan0     Link encap:Ethernet  HWaddr 64:70:02:08:6b:64
UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
RX packets:455 errors:0 dropped:504 overruns:0 frame:0
TX packets:48 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:76251 (74.4 KiB)  TX bytes:7794 (7.6 KiB)

## 16 thoughts on “Connecting Raspberry Pi to WiFi”

1. Thanks!
Does TP-LINK TL-WN823N work without problems with RPi?
Does it need powered USB-Hub when RPi is only USB powered without power supply?

• @PAPPL: As far as I know, when I’m using it, TP-Link TL-WN823N works without any problem. The Raspberry Pi does work on USB-powered Hub with the dongle attached, but it is better to use an external micro-USB power adapter rather than using a USB port from a computer. A USB port is only capable of drawing out 5V DC current of 500 mA, which is might be insufficient to fully power the Raspberry Pi. Using an 1A micro USB power adapter is known to be stable.

2. Do you get full Wireless N with that dongle? I have read that some users have not been able to connect with full speeds to the TP-Link dongle…

3. @MacBurn, I haven’t tested it myself connecting to Wireless N access point cause I don’t have a Wireless N compatible access point to test. I’ll let you know if the full speed of the TP-Link dongle is working once I had tested it. Thanks.

4. I purchased one TP-LINK TL-WN823N USB dongle and I can connect to Wifi network using this dongle but any one know how I can enable the hotspot (Connect to the Raspberry Pi using my mobile.)

5. Hi to every body, it’s my first pay a quick
visit of this blog; this weblog carries remarkable and really excellent data in support of visitors.

6. This blog was… how do you say it? Relevant!!
Finally I have found something which helped me. Appreciate it!

7. Thanks you sir, i sett my rasberry has true and connect.

8. woow very nice post

9. thanks

10. thanks you

11. Nice Post, sangat membantu pak

12. Thank you Gan

13. Awesome Bro

14. Thanks for this tutorial.. it’s very usefull..