Computers, Laptops & Tablets Accessories & Hardware How to Set up a USB Wi-Fi Adapter With the Raspberry Pi Connect to the internet with your Raspberry Pi by Richard Saville Writer Richard Saville is a former Lifewire writer and computer enthusiast who has invented several add-on boards for Raspberry Pi and has been published in MagPi and other outlets. our editorial process Facebook Twitter Richard Saville Updated on September 17, 2020 Accessories & Hardware Raspberry Pi The Quick Guide to Webcams Keyboards & Mice Monitors Cards HDD & SSD Printers & Scanners Tweet Share Email For every version of Raspberry Pi prior to the latest Pi 3, connecting to the internet was achieved in one of two ways. You could connect using an Ethernet port or a USB Wi-Fi adapter. Here's how to set up a USB Wi-Fi adapter with your Pi, using an Edimax EW-7811Un as the example. Connect Hardware To connect the Raspberry Pi hardware components, turn off the Raspberry Pi and fit the Wi-Fi adapter into any of the Pi's available USB ports. It doesn't matter which port you use. Next, connect the keyboard and screen if you haven't done so already. When that's done, turn on the Raspberry Pi and give it a minute to boot up. Open the Terminal If your Pi boots to the terminal by default, skip this step. If your Pi boots to the Raspberry Pi OS desktop (LXDE), select the Terminal icon in the taskbar. It looks like a monitor with a black screen. Edit the Network Interfaces File The first change to make is to add a few lines to the network interfaces file. This sets up the USB adapter to be used, and later on, you'll tell it what to connect to. In the terminal, type in the following command and press Enter: sudo nano /etc/network/interfaces The file will have some lines of text in it, which can be different depending on the Raspberry Pi OS version. Regardless, make sure you have the following four lines—some may be there: auto wlan0allow-hotplug wlan0iface wlan0 inet manualwpa-roam /etc/wpa_supplicant/wpa_supplicant.conf Press Ctrl+X to exit and save the file. You're asked if you want to save the modified buffer. In other words, you are prompted to save the file. Press Y and then press Enter to save the file under the same name. Edit the WPA Supplicant File The supplicant file is where you tell the Pi which network to connect to and the password for that network. Before you edit the wpa_supplicant configuration, encrypt your network password and send it to the file. You can do this with the wpa_passphrase command. Give the command the name of your network (SSID) and your password. Then, direct the output to the wpa_supplicant file. It looks something like this: sudo sh -c "wpa_passphrase yourssid yourpassword >> /etc/wpa_supplicant/wpa_supplicant.conf" In the terminal, type the following command, and press Enter: sudo nano /etc/wpa_supplcant/wpa_supplicant.conf If the Pi is connected to a Wi-Fi network, you may see two network blocks. If not, you'll only have the one you created with wpa_passphrase. The one you created has psk equal to a long string of characters, and the plain text password is commented out. Delete the plain text password line. Delete any previous network blocks to ensure that the Pi connects to the right one. Inside the network block with the encrypted psk, add the following lines below the psk to tell the Pi how to connect to the wireless network. proto=RSNkey_mgmt=WPA-PSKpairwise=CCMPgroup=CCMP With that set up, save and exit the file. Press Ctrl+X, Y, then press Enter. Optional Step: Turn off Power Management If you experience issues with the Wi-Fi adapter dropping connections or becoming unresponsive, the driver's power management setting may be the cause of the problem. To turn off power management, create a new file with a line of text inside it. Enter the following command to create this new file: sudo nano /etc/modprobe.d/8192cu.conf Then enter the following line of text: options 8192cu rtw_power_mgnt=0 rtw_enusbss=0 rtw_ips_mode=1 Press Ctrl+X to exit the file, then save the file under the same name. Reboot Your Raspberry Pi That's everything you need to do to set up a Wi-Fi adapter. Next, reboot the Pi to put all of these changes into effect. Type the following command in the terminal to reboot, then press Enter: sudo reboot The Pi should restart and connect to the network within a minute or so. Troubleshooting If your Pi doesn't connect, there are a few things you should check: Power Supply: Try a different, stronger power supply. Wi-Fi can be demanding on power.Adapter: Is it fitted properly? The Pi's USB ports can be tight at first use.Adapter: Is it compatible?Network: Is your network on? Are other devices connected?Network: Double-check the details you entered in the supplicant file.Reboot: Try again, just in case.