Accessing the Internet with Your Raspberry Pi Through Wireless Networks
Learn how to connect your Raspberry Pi to a wireless network and access the internet. This article will guide you through the process step by step, from configuring the operating system to finding you …
Updated October 21, 2023
Learn how to connect your Raspberry Pi to a wireless network and access the internet. This article will guide you through the process step by step, from configuring the operating system to finding your WiFi network’s SSID and password.
Step 1: Preparation
Before we begin, make sure that you have the following items ready:
- Raspberry Pi (any model) with a microSD card containing Raspbian or another compatible operating system preinstalled
- Power supply (5V/2.5A recommended for most models)
- Keyboard and mouse (or other input devices compatible with your Pi)
- Monitor or HDMI cable (to display the desktop on a TV or computer screen)
- WiFi adapter (if your Raspberry Pi doesn’t come with built-in WiFi support)
Step 2: Boot Up Your Raspberry Pi
Insert the microSD card into your Raspberry Pi and connect it to a power source, keyboard, mouse, and monitor. Power on the device by pressing the power button or connecting the power supply. Once the operating system has fully booted, you should see the desktop interface appear on your screen.
Step 3: Open the Command Line Interface (CLI)
To access the WiFi settings, we need to use the command line interface (CLI). Click on the terminal icon in the menu bar or press Ctrl + Alt + T
to open a new terminal window.
Step 4: Check for WiFi Adapters
If your Raspberry Pi has built-in WiFi support, you can skip this step. If not, connect your external WiFi adapter and run the following command in the terminal:
sudo iwconfig
This will display a list of available network interfaces. Make a note of the name of your WiFi adapter (usually wlan0
or wlan1
).
Step 5: Scan for Available Networks
Run the following command to scan for nearby wireless networks:
sudo iwlist wlan0 scan
Replace wlan0
with your WiFi adapter’s name if it differs. This will display a list of available networks, including their SSID (network name) and signal strength.
Step 6: Choose a Network and Get the Password
Find the network you want to connect to in the list and write down its SSID (case sensitive). You’ll also need the password for that network. If you don’t know the password, ask the network administrator or check the documentation provided with the router.
Step 7: Edit the WiFi Configuration File
Create a new file to store your WiFi connection details using the following command:
sudo nano /etc/wpa_supplicant/wpa_supplicant.conf
Add the following lines at the end of the file, replacing your_network_ssid
and your_password
with the appropriate values:
network={
ssid="your_network_ssid"
psk="your_password"
}
Save and exit the file by pressing Ctrl + X
, then Y
, and finally Enter
.
Step 8: Restart the WiFi Service
Run the following command to apply the changes:
sudo systemctl restart wpa_supplicant
Step 9: Check Your Connection
After a few seconds, your Raspberry Pi should establish a connection to the wireless network. To verify this, run:
iwconfig wlan0
If the ESSID
field matches your chosen network’s SSID and the Link Quality
is above 0, you have successfully connected to WiFi.
Step 10: Test Your Internet Connection
To check if you can access the internet, open a web browser or run the following command in the terminal:
ping google.com
If you receive replies from Google’s servers, your Raspberry Pi is now connected to WiFi and has internet access.
And that’s it! Your Raspberry Pi is now connected to a wireless network and can access the internet. With this basic setup in place, you can start exploring other software and projects that require an internet connection.