Setting up a wireless connection on Raspberry Pi 3 Using the console is a challenge faced by both novice and experienced users. Unlike models with an Ethernet port, where the network connection is configured automatically, Wi-Fi requires manual configuration. This issue is especially relevant when working in headless mode (without a monitor and keyboard), when access to the device is only via SSH or a network cable.
In this article we will look at all the connection methods. Raspberry Pi 3 Model B/B+ to Wi-Fi via terminal: from editing configuration files to using utilities like wpa_cli And nmcliYou'll learn how to avoid common errors, check connection status, and troubleshoot driver issues. And if you're working with Raspberry Pi OS Lite or any other "lightweight" build that lacks a graphical interface, this guide will be your primary reference.
1. Preparing to set up Wi-Fi: What you need to know
Before you begin the configuration, make sure that your Raspberry Pi 3 Ready to work with wireless networks. Unlike newer models (for example, Raspberry Pi 4 or Pi Zero W), the "troika" has a built-in Wi-Fi module BCM43438, which supports standards 802.11n (up to 150 Mbps). However, for its correct operation, the following is required:
- 📋 Updated version Raspberry Pi OS (previously Raspbian). Old images may not contain the necessary drivers.
- 🔌 Power source with a current of at least 2.5AInsufficient power supply leads to unstable Wi-Fi operation.
- 📡 Availability of an access point (router) with broadcasting enabled SSIDHidden networks will require additional settings.
- 🔑 Connection details: network name (
SSID) and password (PSK). For corporate networks it may be necessaryEAP- authentication method.
If you are connecting to Raspberry Pi via Ethernet, first update the system:
sudo apt update && sudo apt upgrade -y
⚠️ Attention: On some builds Raspberry Pi OS (especially "lightweight") may be missing a packagewireless-toolsInstall it with the commandsudo apt install wireless-tools, if you later encounter errors when scanning networks.
Also check if the Wi-Fi adapter is recognized by the system. Run the command:
iwconfig
The output should show the interface wlan0 (or wlan1(if an external adapter is used). If it is not there, the problem is with the drivers or hardware.
2. Method 1: Configuration via file wpa_supplicant.conf
The most reliable and universal method is editing the configuration file. /etc/wpa_supplicant/wpa_supplicant.confIt works on all versions. Raspberry Pi OS and does not require additional software installation. Open the file in a text editor. nano:
sudo nano /etc/wpa_supplicant/wpa_supplicant.conf
Add the following block to the end of the file (replace YOUR_SSID And YOUR_PASSWORD for current data):
network={ssid="YOUR_SSID"
psk="YOUR_PASSWORD"
key_mgmt=WPA-PSK
}
For networks with hidden SSID add a line scan_ssid=1 inside the block networkIf your router uses WPA3, replace key_mgmt=WPA-PSK on key_mgmt=SAE.
Save changes (Ctrl+O, then Enter) and close the editor (Ctrl+X). To apply the settings, run:
sudo wpa_cli -i wlan0 reconfigure
Replaced YOUR_SSID and YOUR_PASSWORD with real data|
Password case sensitivity checked (WPA-PSK is case sensitive)|
The correct encryption method is specified (WPA-PSK for most home networks)|
The file was saved with root privileges (sudo)
-->
If the connection is not established, check the logs:
journalctl -u wpa_supplicant -b
Errors like Failed to connect to network or Wrong password will indicate a problem with the login data.
3. Method 2: Using a utility raspi-config
For users who prefer a semi-automatic method, the built-in utility is suitable raspi-configIt allows you to configure Wi-Fi through an interactive menu, which reduces the risk of syntax errors. Run it with the command:
sudo raspi-config
Go to the menu:
System Options → Wireless LAN.
The system will ask:
- Network Name (
SSID). - Password (
PSK). - Country (select
RUfor Russia, to comply with local frequency regulations).
After entering the data raspi-config will update automatically wpa_supplicant.conf and restart the service wpa_supplicantThis method is convenient for beginners, but has limitations:
- 🚫 Does not support networks with Enterprise authentication (WPA2-Enterprise).
- 🔄 Does not allow you to configure multiple networks simultaneously (prioritization).
- 📡 Doesn't display a list of available networks (you need to know the SSID in advance).
⚠️ Attention: If after setting up throughraspi-configThe connection is not working, check the file/etc/wpa_supplicant/wpa_supplicant.conffor the presence of duplicate blocksnetwork={...}. Remove unnecessary ones manually.
4. Method 3: Manually scan networks and connect via wpa_cli
Utility wpa_cli — a powerful tool for managing Wi-Fi connections in real time. It allows you to scan the air, connect to the network, and diagnose problems without editing configuration files. Run it in interactive mode:
sudo wpa_cli -i wlan0
Basic commands:
| Team | Description | Output example |
|---|---|---|
scan |
Scans available networks | OK (see results in scan_results) |
scan_results |
Shows a list of networks with signal strength | bssid / frequency / signal level / flags / ssid |
add_network |
Adds a new network to the configuration | 0 (New network ID) |
set_network 0 ssid "MyWiFi" |
Sets the SSID for the network with ID 0 | OK |
enable_network 0 |
Activates the network | OK |
Step-by-step connection example:
- Do it
scan, thenscan_resultsto see available networks. - Add a new network:
add_network(remember the returned ID, for example,0). - Configure the settings:
set_network 0 ssid "MyWiFi"set_network 0 psk "MyPassword"
set_network 0 key_mgmt WPA-PSK - Activate the network:
enable_network 0. - Save settings:
save_config.
If your network uses WPA3, replace key_mgmt with SAE. Not all routers work correctly with WPA3 on Raspberry Pi 3 due to driver limitations.
5. Troubleshooting: Why Wi-Fi Won't Connect
If the connection is not established after setup, check the following:
- 🔌 Nutrition: Insufficient current (less than 2.5A) causes Wi-Fi disconnects. Use the original power supply.
- 📶 Signal level: Do it
iwconfig wlan0and checkSignal level. The value is below-70 dBmindicates a weak signal. - 🔒 Incorrect password: Error
WPA: 4-Way Handshake failedin the logs (journalctl -u wpa_supplicant) means incorrectPSK. - 🔄 IP conflict: If the router does not provide an IP address via DHCP, assign a static address in
/etc/dhcpcd.conf.
Common mistakes and their solutions:
| Error | Cause | Solution |
|---|---|---|
Failed to connect to network |
Incorrect password or SSID | Check the data in wpa_supplicant.conf |
No network configuration found |
File wpa_supplicant.conf empty or damaged |
Restore the file from a backup or configure it again. |
Device or resource busy |
Interface wlan0 is used by another service (eg NetworkManager) |
Stop the conflicting service: sudo systemctl stop NetworkManager |
| Wi-Fi connects, but there is no internet | Missing default route or DNS issues | Check it out ip route And ping 8.8.8.8 |
For in-depth diagnostics, use:
sudo iwlist wlan0 scan | grep -A 10 "YOUR_SSID"
This command will show details of your connection to a specific network, including supported encryption standards and signal strength.
6. Setting up a static IP address (optional)
If your network uses static addressing or requires IP reservations for Raspberry Pi, configure it in the file /etc/dhcpcd.conf. Open the file:
sudo nano /etc/dhcpcd.conf
Add the following lines to the end (replace the parameters with the actual ones):
interface wlan0static ip_address=192.168.1.100/24
static routers=192.168.1.1
static domain_name_servers=192.168.1.1 8.8.8.8
Where:
192.168.1.100— the desired IP address for Raspberry Pi.192.168.1.1— IP of your router (gateway).8.8.8.8— backup DNS (Google Public DNS).
After saving, restart the service:
sudo service dhcpcd restart
⚠️ Attention: Make sure that the static IP you select is not in your router's DHCP range (usually 192.168.1.100–192.168.1.200). Otherwise, conflicts are possible.
How to check the DHCP range on a router?
Typically this information is listed in the router's web interface in the section LAN or DHCP SettingsFor example, for TP-Link routers the path will be:
Advanced → Network → DHCP Server.
Look for fields Start IP And End IP — this is the range of addresses being distributed. The static IP must be outside of it.
7. Alternative methods: NetworkManager And connman
If standard methods do not work (for example, due to a service conflict), you can use alternative network managers:
- 🔧 NetworkManager: Install it with the command
sudo apt install network-manager, then usenmtuiornmclito set up Wi-Fi. - 🌐 ConnMan: A lightweight manager suitable for minimalist builds. Installation:
sudo apt install connman, control throughconnmanctl.
Example of connection via nmcli:
nmcli dev wifi connect "YOUR_SSID" password "YOUR_PASSWORD"
For connmanctl:
sudo connmanctl> enable wifi
> scan wifi
> services
> agent on
> connect wifi_XX_XX_XX_XX_XX_XX_YOUR_SSID
These tools are useful in cases where wpa_supplicant conflicts with other services or requires more flexible connection management (for example, when frequently changing networks).
8. Security: How to protect your connection
Wi-Fi on Raspberry Pi is often a target for attacks, especially if the device is accessible from the internet. The following measures will improve security:
- 🔐 Disable WPS on the router. Vulnerabilities in WPS allow the PIN code to be brute-forced in a matter of hours.
- 🛡️ Use WPA3 (if supported by the router and the client). Otherwise - WPA2-AES (avoid TKIP).
- 🔄 Update your system regularly: Do it
sudo apt update && sudo apt upgrade -yat least once a month. - 🚪 Close unnecessary ports: Check open ports with the command
sudo ss -tulnpand close the extra ones throughufw.
For added protection, turn off broadcasting SSID in the router settings and set up a connection to a hidden network in wpa_supplicant.conf:
network={ssid="YOUR_HIDDEN_SSID"
scan_ssid=1
psk="YOUR_PASSWORD"
key_mgmt=WPA-PSK
}
Also consider using VPN to encrypt traffic, especially if Raspberry Pi Connected to public networks. Popular solutions: OpenVPN or WireGuard.
⚠️ Attention: If you use Raspberry Pi as a server (for example, forNextcloudorHome Assistant), never open ports 22 (SSH) and 80/443 (HTTP/HTTPS) directly to the Internet. Use reverse proxy (For example,Nginx) with IP restrictions or two-factor authentication.
FAQ: Frequently asked questions about setting up Wi-Fi
Is it possible to connect a Raspberry Pi 3 to Wi-Fi without a monitor?
Yes, this is the main use case for console methods. Just edit wpa_supplicant.conf on a memory card from another computer (in the section boot) or connect via Ethernet for initial setup.
Why doesn't Wi-Fi connect automatically after a reboot?
The reasons may be different:
- In the file
wpa_supplicant.confline missingcountry=RU(or your country). - Service
wpa_supplicantnot activated: checksudo systemctl status wpa_supplicant. - Conflict with
NetworkManagerordhcpcd.
Solution: check the logs (journalctl -u wpa_supplicant -b) and configure the service to start automatically.
How do I connect to a network with a captive portal (e.g., in a hotel)?
Standard methods don't work with networks that require web-based authentication. You'll need:
- Connect to the network via
wpa_supplicant(even if there is no internet). - Open a browser on another device and manually log in using the MAC address. Raspberry Pi (find out his:
ip link show wlan0). - Or use
curlto automate login (if the portal URL is known).
For automation, you can write a script on Python with the library requests.
Does Raspberry Pi 3 support 5GHz networks?
No, Raspberry Pi 3 Model B/B+ works only in the range 2.4 GHzFor 5 GHz you will need an external USB adapter (e.g. TP-Link TL-WN725N with chipset RTL8188EU).
How do I reset all Wi-Fi settings to factory defaults?
Delete the configuration file and reboot the device:
sudo rm /etc/wpa_supplicant/wpa_supplicant.conf
sudo reboot
After rebooting, the file will be recreated with default settings.