Virtually every Raspberry Pi project will require a network connection. While Ethernet is faster, Wi-Fi is far more flexible. But how do you set up Wi-Fi on a Raspberry Pi? And what if your Raspberry Pi doesn't come with built in wireless networking?

Here is everything you need to know about setting up Wi-Fi on a Raspberry Pi.

Ethernet Or Wireless?

The benefit of Ethernet over wireless LAN on the Raspberry Pi – as with most other platforms – is that there is zero configuration required. Simply ensure the cable is connected to a router, plug it into your Pi and boot it up.

Setting up Wi-Fi on the Raspberry Pi is usually straightforward, but this will depend on the model and OS. Taking the time to configure wireless networking will improve your Pi's flexibility, however. Projects both indoors and outdoors are made possible with the addition of Wi-Fi.

Read More: What Is an Ethernet Cable?

Setting Up Wi-Fi on Raspberry Pi OS

If you're booting into Raspberry Pi OS for the first time, you'll be prompted to set up a wireless connection.

When the Pi boots into the desktop for the first time, you'll be asked to complete some setup details. One of these options is to connect to a wireless network. Choose the right network name (SSID) and enter the password. Moments later the Pi will connect.

Connect to Wi-Fi on Raspberry Pi

Alternatively, you might have been using Raspberry Pi OS for a while without Wi-Fi, having skipped the section during the first boot. In this case, you can enter the Wi-Fi credentials on the desktop:

  1. Click the Wi-Fi icon
  2. Click the SSID for the corresponding wireless network
  3. Enter the passkey
  4. Click OK

Your Raspberry Pi should now be online.

Wi-Fi on Older Raspberry Pis

Wireless networking has only been built into the Raspberry Pi since the Raspberry Pi 3B was released in 2016. All models prior to this, including the Raspberry Pi Zero and Raspberry Pi 1A, shipped without Wi-Fi or Bluetooth.

If the Pi was purchased as part of a kit, it likely shipped with a wireless USB adapter (also known as a "dongle"). But if you bought it as a standalone unit, you'll need to find a compatible dongle to get Wi-Fi.

Many Wi-Fi dongles will work with the Raspberry Pi as they support Linux, which Raspberry Pi OS is based on. For a list of compatible hardware, refer to elinux.org. Along with everything you need to know about the Pi's hardware, you'll find a section on USB Wi-Fi dongles for the Raspberry Pi. These are inexpensive components available from stores like ThePiHut.com and Pimoroni.

Related: The Best USB Wi-Fi Adapters

Configuring Wi-Fi on Older Raspberry Pi Models

The following details are for setting up Wi-Fi using a USB adapter on pre-2016 Raspberry Pi running Raspberry Pi OS Lite. These steps will also work if you're using an old Raspbian build on your ageing Raspberry Pi.

With the Raspberry Pi switched off, connect the USB Wi-Fi adapter, and ensure the SD card is correctly inserted. Power up the computer and when the desktop opens, launch the terminal emulator, Terminal.

Start by ensuring the OS is fully updated:

        sudo apt update && sudo apt upgrade -y
    

With this complete, check the USB dongle is detected:

        lsusb
    

The Wi-Fi device should be listed in the results.

At this point, try clicking the Wi-Fi networking symbol in the top-right corner of the desktop. This should let you connect to the network as if the USB adapter was an internal wireless radio.

Connect to Wi-Fi Automatically

Rather spend time configuring Wi-Fi after the operating system has been installed, you can enter credentials before booting. This makes the whole first boot far more streamlined. You have two options here:

  • Use the advanced settings in Raspberry Pi Imager
  • Manually configure the wpa_supplicant.conf file

(A third option, Raspberry Pi Bakery, is discontinued. While it can still be downloaded from GitHub, it is reported to not work with the Raspberry Pi 4.)

Let's look at the two options in turn.

Pre-configure Wi-Fi Settings With Raspberry Pi Imager

Raspberry Pi Imager is the best way to install an operating system on the Raspberry Pi. Before you write the disk image to your Pi's SD card, however, it is worth checking out the Advanced options screen.

  1. Press Shift+Ctrl+X
  2. In the Advanced options pop-up, scroll to Configure Wi-Fi
  3. Check the box to enable the setting
  4. Input the SSID and Password for your wireless network
  5. Set the Wi-Fi country
  6. Click Save
Raspberry Pi Imager advanced settings

The window will close, so proceed with writing the disk image to your SD card. When the Pi boots for the first time, as long as the credentials are correct it will automatically connect to your network.

This option works with all the operating systems included in Raspberry Pi Imager.

Edit wpa_supplicant.conf for a Streamlined First Boot

Wireless networking information is stored in a file called wpa_supplicant.conf. This file can be edited before booting the Raspberry Pi, ensuring the network SSID and password are preconfigured.

By default, wpa_supplicant.conf can be found in the /etc/ directory. However, you can create a new one in the Pi's boot partition. After writing the disk image to SD card, eject the media from your PC then reinsert it. In the SD card's /boot/ directory, create a new text file, called wpa_supplicant.conf.

Be sure to remove the .txt file extension if this is retained.

Next, open wpa_supplicant.conf in your operating system's text editor. You're now ready to edit the file, taking care to set the correct country, ssid, and psk (password).

        ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev

update_config=1

country=US

network={

ssid="SSID"

psk="PASSWORD"

key_mgmt=WPA-PSK

}

Use Ctrl + X to exit and save, then Y and Enter to confirm. When the Pi boots, this information should be used to connect the device to your wireless network automatically.

Forget Ethernet – Make Your Raspberry Pi Wireless!

Whether you use an old Raspberry Pi with a USB wireless adapter or rely on a modern model with built in Wi-Fi, it's easy to get online. Connecting to your wireless network either means a few mouse clicks and a password, or a bit of text file editing. You can even preconfigure your Raspberry Pi OS with the wireless credentials before booting for the first time.