TechBuzzPro

How to Connect Raspberry Pi to Wi-Fi

· 6 min read · Wi-Fi & Networking

In this article
  1. What You'll Need
  2. Step-by-Step
  3. Common Mistakes
  4. Tips
  5. Troubleshooting
  6. Frequently Asked Questions

To connect a Raspberry Pi to Wi-Fi, the quickest way is to use the graphical desktop: click the network icon in the top-right corner, select your Wi-Fi network, and enter the password. If you're using the Lite (headless) version, you'll need to edit a configuration file or use the command line. This guide covers both methods, plus troubleshooting for common issues.

What You'll Need

  • A Raspberry Pi (any model with built-in Wi-Fi, or a compatible USB Wi-Fi dongle for older models)
  • A microSD card with Raspberry Pi OS installed (desktop or Lite)
  • A power supply for your Raspberry Pi
  • A monitor, keyboard, and mouse (only for the desktop method)
  • Your Wi-Fi network name (SSID) and password
  • Optional: an Ethernet cable for initial setup if you're using the headless method

Step-by-Step

Method 1: Using the Desktop (Raspberry Pi OS with GUI)

  1. Boot your Raspberry Pi to the desktop. If you're already logged in, you'll see the taskbar at the top of the screen.
  2. Look for the network icon (two arrows or a Wi‑Fi symbol) in the top-right corner of the taskbar. Click it.
  3. A dropdown list of available wireless networks appears. Click on your Wi‑Fi network's name (SSID).
  4. If your network is secured, a dialog box will ask for the password (also called the passphrase or security key). Type it carefully—it's case-sensitive.
  5. Click "OK" or press Enter. The Pi will attempt to connect. Once connected, the network icon will change to show signal bars, and you'll see a confirmation message.
  6. To verify the connection, open a web browser (like Chromium) and try to load a page. Or open a terminal and run ping -c 4 google.com—if you get replies, you're online.

Method 2: Using the Command Line (Raspberry Pi OS Lite or Headless)

  1. If you haven't already, create a fresh image of Raspberry Pi OS on your microSD card. After imaging, the SD card will appear as a drive called "boot" on your computer.
  2. On that boot drive, create a new text file named wpa_supplicant.conf (exact name, no extension).
  3. Open the file in a text editor (like Notepad on Windows or TextEdit on Mac). Paste the following, replacing YOUR_WIFI_NAME and YOUR_PASSWORD with your actual network details:
    country=US
    ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
    update_config=1
    
    network={
        ssid="YOUR_WIFI_NAME"
        psk="YOUR_PASSWORD"
    }
    Note: The country= line should match your country code (e.g., US, GB, DE). If unsure, use US.
  4. Save the file and safely eject the SD card from your computer.
  5. Insert the SD card into your Raspberry Pi and power it on. The Pi should automatically read this file on first boot and connect to your Wi-Fi.
  6. To find the Pi's IP address, you can check your router's admin page (look for connected devices) or use a network scanner app on your phone. Alternatively, if you have an Ethernet cable, plug it in temporarily and run hostname -I in a terminal after booting.

Method 3: Using the raspi-config Tool (Terminal on an Existing System)

  1. Open a terminal on your Raspberry Pi (or SSH into it if you're already connected via Ethernet).
  2. Run sudo raspi-config.
  3. Use arrow keys to navigate. Select "System Options" (or "Localisation Options" in older versions) and press Enter.
  4. Choose "Wireless LAN" from the list.
  5. Enter your country code when prompted, then select your Wi-Fi network from the list, or type the SSID if it's hidden.
  6. Enter your password when asked. The Pi will configure the connection automatically.
  7. Exit raspi-config. The connection should be active immediately.

Common Mistakes

  • Wrong password or SSID: Wi-Fi passwords are case-sensitive. Also, ensure you're typing the exact network name, including any spaces or special characters.
  • Using the wrong country code: In the wpa_supplicant.conf file, an incorrect country code can prevent Wi-Fi from working in some regions. Double-check it.
  • File name error: The file must be exactly wpa_supplicant.conf—not wpa_supplicant.conf.txt. On Windows, you may need to enable "Show file extensions" in File Explorer to avoid this.
  • Hidden network: If your Wi-Fi doesn't broadcast its SSID, you must add scan_ssid=1 inside the network block in the config file.
  • Firewall or router restrictions: Some routers have MAC address filtering or "guest network" isolation that can block the Pi. Check your router settings.

Tips

  • For headless setups, consider using the Raspberry Pi Imager's advanced options (press Ctrl+Shift+X on Windows/Linux, or Cmd+Shift+X on Mac) to pre-configure Wi-Fi, hostname, and SSH before writing the image. This is the easiest method.
  • If you have multiple Wi-Fi networks (e.g., 2.4GHz and 5GHz), note that some older Pi models only support 2.4GHz. Choose the 2.4GHz network if your Pi doesn't see the 5GHz one.
  • Keep your Raspberry Pi OS updated with sudo apt update && sudo apt upgrade to ensure Wi-Fi drivers are current.
  • If you're using a USB Wi-Fi dongle, try a different USB port or a powered USB hub—some dongles draw too much power from the Pi's USB port.

Troubleshooting

  1. Check if Wi-Fi is enabled: Run sudo ifconfig wlan0 or ip addr show wlan0. If you see "no wireless extensions" or a missing interface, Wi-Fi might be disabled. Try sudo rfkill list to see if it's blocked, and unblock with sudo rfkill unblock wifi.
  2. Restart networking: Run sudo systemctl restart dhcpcd (or sudo systemctl restart networking on older systems) to force a reconnection.
  3. Check the wpa_supplicant file: If you used the manual method, verify the file is in the correct location: sudo cat /etc/wpa_supplicant/wpa_supplicant.conf. It should contain your network details. If not, edit it with sudo nano /etc/wpa_supplicant/wpa_supplicant.conf and add them.
  4. Forget and re-add the network: On the desktop, click the network icon, select "Advanced Options" > "Forget Network", then reconnect from scratch.
  5. Check the router's DHCP lease: If the Pi connects but has no internet, try a static IP configuration. Edit /etc/dhcpcd.conf and add:
    interface wlan0
    static ip_address=192.168.1.100/24
    static routers=192.168.1.1
    static domain_name_servers=8.8.8.8
    (Adjust the IP addresses to match your network.) Then restart with sudo systemctl restart dhcpcd.
  6. If nothing works, reboot: Sometimes a simple sudo reboot resolves transient issues.

Frequently Asked Questions

Why doesn't my Raspberry Pi see any Wi-Fi networks?

This usually means the Wi-Fi hardware isn't detected or is disabled. Check that your Pi model has built-in Wi-Fi (Pi 3, 4, Zero W, etc.) or that your USB dongle is properly inserted. Run sudo rfkill list to see if it's blocked, and unblock if necessary.

Can I connect to a 5GHz Wi-Fi network?

Yes, but only if your Raspberry Pi model supports 5GHz. The Pi 3B+, 4, and Zero 2 W support dual-band. Older models like the Pi 3B and Zero W only support 2.4GHz. If your Pi doesn't see the 5GHz network, it likely doesn't support it.

How do I find my Raspberry Pi's IP address after connecting?

If you have a monitor, run hostname -I in a terminal. If headless, check your router's DHCP client list, or use a network scanner like Fing on your phone. You can also set a static IP to avoid this issue.

Is it safe to use the wpa_supplicant.conf method?

Yes, it's the official method recommended by the Raspberry Pi Foundation for headless setup. Just make sure to remove the file after first boot if you're concerned about security, though it's not strictly necessary.

Why does my Wi-Fi keep disconnecting?

This can be caused by power supply issues (use an official adapter), interference, or power management settings. Try disabling Wi-Fi power saving with sudo iwconfig wlan0 power off and add it to /etc/rc.local to make it permanent.

Can I use a hidden network?

Yes, add scan_ssid=1 inside the network block in the wpa_supplicant.conf file, or in the desktop method, choose "Connect to Hidden Network" and enter the SSID manually.