How to set up Wi-Fi on Raspberry Pi? (6 ways on RPI OS)


It’s probably the most common question when installing your first Raspberry Pi, so I choose to write a guide about it to help you find the good solution in your specific case.
All recent Raspberry Pi models (Pi 3, 4/400 and Zero W) include a wireless connection, but the configuration is not always easy, especially with a complex or secured network, or on Raspberry Pi OS Lite.
I will answer all your questions in this post.

Here are the steps to configure the Wi-Fi network on a Raspberry Pi:

  • Open a terminal
  • Type the following command to open the configuration tool:
    sudo raspi-config
  • Go to Network Options > Wi-Fi
  • Follow the wizard to choose a SSID and enter the password.

I’ll show you everything in this post. There are several solutions available, depending on your system version and access to it.

By the way, if you are really interested in improving your skills on Raspberry Pi, I highly recommend to check out my e-book hereIt’s a 30-days challenge from beginner to master, with step-by-step tutorials and many projects to practice along the way.

I answer your questions - Raspberry...
I answer your questions - Raspberry Pi FAQ

Raspberry Pi Wi-Fi Headless Configuration

Download the Pi Glossary!
If you are lost in all these new words and abbreviations, request my free Raspberry Pi glossary here (PDF format)!

I call this part “headless” because it’s the way you can use if you don’t have a screen on your Raspberry Pi.
But you can absolutely use it in any case. Besides, that’s what I do most of the time.

Use Raspberry Pi Imager

The easiest way currently to set up your Wi-Fi connection before the first boot is to use Raspberry Pi Imager. This tool includes advanced settings where you can set up a few things, including the wireless network you want to use.

  • Download and install Raspberry Pi Imager on your computer.
    If you don’t have it yet, you can get it for free from the official website. It’s available for Windows, Linux and even for Raspberry Pi OS.
  • Use Raspberry Pi Imager advanced options.
    Select the operating system you want to use (let’s say Raspberry Pi OS), and your storage (SD card or USB).
    Then, click on the settings icon in the bottom right to open the advanced options:

    In this form, you can enable SSH, set the username and password but also configure your Wi-Fi connection.
    Fill the SSID, password and country, then click on “Save”.
  • Click on the “Write” button to start the installation. Your settings will be included on the media.

Your Raspberry Pi will be connected automatically to your network on the first boot. Check the next part if you don’t use Raspberry Pi Imager, or want to do the same thing manually.

If you are using this tool for the first time, please take a look at my complete guide about Raspberry Pi Imager here. I will explain everything in more details and give you many advanced tips.

Manual configuration

Method

Download the Pi Glossary!
If you are lost in all these new words and abbreviations, request my free Raspberry Pi glossary here (PDF format)!

This solution applies if you just flashed your SD card, and want to enable Wi-Fi on your fresh system on the first boot (but it also works for an old SD card you used with Ethernet or an old wireless network).

You have a file to create and copy on the SD card, so on the next boot, Raspberry Pi OS will read the file and apply the configuration directly.
You don’t have anything else to do.
Good idea no?

wpa_supplicant.conf

Let’s see how to do this:

  • Open your favorite text editor on your computer.
    The basic editor from your operating system will be fine (Notepad for example).
  • Copy and paste these lines into it:
country=US
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
network={
  ssid="YOURSSID"
  scan_ssid=1
  psk="YOURPASSWORD"
  key_mgmt=WPA-PSK
}
  • Replace variables with your SSID and password, and change the country value if needed.
  • Save the file on a location you can find easily the next time you create a new SD card.

Insert your SD card into your computer (for a fresh new SD card created with Etcher, you have to eject and insert it again).
Then copy the wpa_supplicant.conf file to the boot partition.

It works with any Raspberry Pi OS version (Desktop or Lite).
So, it’s perfect for any use.

Enable SSH automatically

Raspad 3
Learn & program in Mins
A tablet that gives you access to all the Raspberry Pi ports you need, with a simple interface to start programming easily.

Buy now Check my review

Another thing you may want to add, if you really use your Raspberry Pi without screen, is to enable the SSH service automatically.
On RPI OS, it’s not the case by default. Even if your Pi connects to your wireless network, SSH will not be enabled.

To do this, there is another file to create.
Just create an empty file, named “ssh” into the same partition (boot).
It’s enough to tell Raspberry Pi OS to start the SSH service automatically on boot.

It’s something I use all the time, as explained in this tutorial on how to install a Raspberry Pi without screen and keyboard. You can also watch the video version of this tutorial here:

Configure Wi-Fi on Raspberry Pi OS Desktop

Let’s see now how to configure your Wi-Fi once you’re on Raspberry Pi OS with Desktop.

Welcome wizard

If it’s your first boot, you should get a “Welcome to Raspberry Pi” message, asking you to set up your system.
It’s the easiest way to do on Raspberry Pi OS with Desktop, don’t miss this menu.

After setting the country and password, you’ll get a window like this:

Select your Wi-Fi network SSID in the list, and type the password.
A few seconds later, you’ll be connected to your network.

Task bar

If you missed the welcome wizard, or skipped the Wi-Fi configuration here, you can do it or change it at anytime in the taskbar panel

  • On the top you have the main panel, with the menu, shortcuts and the clock.
  • Near the clock, there is a network symbol (with two red crosses if you are disconnected).
  • Click on it, a list of all available wireless networks appears.
  • Select your network in the list, and type your password.

That’s it, not very complicated either 🙂

Set up your Wi-Fi on Raspberry Pi OS Lite

If you’re on Raspberry Pi OS Lite, you may need more help to find how to configure your network.
Let’s see how to do this.

Raspi-config tool

The Raspberry Pi Foundation thought of you.
Even if you are on a black and white screen, there is a tool to help you to configure your wireless network easily.

This tool is raspi-config, available by default on Raspberry Pi OS Lite:

  • Start raspi-config with:
    sudo raspi-config
  • Go into System Options > Wireless LAN.
  • Type your SSID and your password.
  • Exit the tool.
    After a few seconds, your Pi is now connected to the wireless network you chose.

That’s an easy way to do on Raspberry Pi OS Lite.

Note: On older versions of Raspberry Pi OS, the menu may be slightly different. If you can’t find the same thing, the wireless configuration is probably under Network options > Wi-Fi.

Manual configuration

The last option is not easy, but only useful for specific network I think
In fact, I’m not sure when manual configuration is the only option.
Maybe on a big network with secure authentication, a critical device or static network?
Anyway, here is how to create a manual configuration, even if it’s just for your curiosity 🙂

WPA Supplicant

The wireless configuration on the Raspberry Pi is located in /etc/wpa_supplicant.
You can edit the configuration file with nano:
sudo nano /etc/wpa_supplicant/wpa_supplicant.conf

The syntax is the same as we saw in the first part, with the file you can put on your SD card.
You’ll find here the same information, so you can change them directly in this file if needed.
Here is a reminder of a basic configuration syntax with WPA-PSK:

country=US
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
network={
 ssid="YOURSSID"
 scan_ssid=1
 psk="YOURPASSWORD"
 key_mgmt=WPA-PSK
}

If the new configuration doesn’t apply after a few minutes, you may need to reboot the Raspberry Pi:
sudo reboot

You can find many examples here to adapt the configuration to your network (if you use WEP, EAP or any other security options).

Are you a bit lost in the Linux command line? Check this article first, for the most important commands to remember, and a free downloadable cheat sheet so you can have the commands at your fingertips.

Network configuration

Finally, if you need a static IP on your network, the interface configuration can be done in dhcpcd.conf:

  • Open the file:
    sudo nano /etc/dhcpcd.conf
  • Find the “Example static IP configuration” paragraph.
  • Uncomment every line you need (probably ip_address, routers and domaine_name_servers), and change the values to adapt to your network.
  • Here is a basic example:
    interface wlan0
    static ip_address=192.168.1.10/24
    static routers=192.168.1.1
    static domain_name_servers=8.8.8.8
  • Save and exit, then reboot the Raspberry Pi:
    sudo reboot

I have a complete tutorial on this website on how to find the current IP address of a Raspberry Pi, and set it to a static one. Feel free to check it out for more details.

Reminder: Remember that all the members of my community get access to this website without ads, exclusive courses and much more. You can become part of this community for as little as $5 per month & get all the benefits immediately.

Conclusion

Get My Cheat Sheet!
Grab your free PDF file with all the commands you need to know on Raspberry Pi!

That’s it, you know everything you need to set up the Wi-Fi on your Raspberry Pi, whatever your network.

I hope this post was helpful.
As a general rule, it’s easy when you know what to do, but maybe I’ve never been in a situation where configuring Wi-Fi on the Raspberry Pi was complicated 🙂

Now that you are connected to the Internet, you can start having fun with many different projects on your Raspberry Pi. Here are a few articles I wrote that you can check for more ideas :

Raspberry Pi Resources

Not sure where to start?
Understand everything about the Raspberry Pi, stop searching for help all the time, and finally enjoy completing your projects.
Watch the Raspberry Pi Bootcamp course now.

Master your Raspberry Pi in 30 days
Don’t want the basic stuff only? If you are looking for the best tips to become an expert on Raspberry Pi, this book is for you. Learn useful Linux skills and practice multiple projects with step-by-step guides.
Download the e-book.

VIP Community
If you just want to hang out with me and other Raspberry Pi fans, you can also join the community. I share exclusive tutorials and behind-the-scenes content there. Premium members can also visit the website without ads.
More details here.

Need help building something with Python?
Create, understand and improve any Python script for your Raspberry Pi.
Learn the essentials, step-by-step, without losing time understanding useless concepts.
Get the e-book now.

You can also find all my recommendations for tools and hardware on this page.

Patrick Fromaget

I'm the lead author and owner of RaspberryTips.com. My goal is to help you with your Raspberry Pi problems using detailed guides and tutorials. In real life, I'm a Linux system administrator with a web developer experience.

Recent Posts