How To Configure WiFi on Raspberry Pi: Step By Step Tutorial - Latest Open Tech From Seeed
Technology

How To Configure WiFi on Raspberry Pi: Step By Step Tutorial – Latest Open Tech From Seeed

How To Configure WiFi on Raspberry Pi: Step By Step Tutorial – Latest Open Tech From Seeed

How to connect pi to wifi

One of the first things you’ll want to do with your raspberry pi is definitely set up Wi-Fi.

Today, we will show you three ways to set up Wi-Fi on your Raspberry Pi with Raspberry Pi OS Desktop and Server. we’ll also cover how to do it on a headless raspberry pi!

Photo by Harrison Broadbent on Unsplash

Let me first introduce you to the reTerminal, a future-ready Human Machine Interface (HMI) device. It can easily and efficiently collaborate with IoT and cloud systems to unlock endless scenarios at the edge. It can be placed at the heart of an IoT/Edge system where you can connect multiple sensors to the reTerminal via different wireless protocols (e.g. LoRa, Zigbee, Wi-Fi, Bluetooth, Sub-1G) and connect the reTerminal to the Ethernet, Wi-Fi, 5G/4G or connect to edge servers to store and process data.

reterminal: linux embedded with raspberry pi cm4 ships with raspberry pi os out of the box. so all you have to do is plug it into power and start building your iot, hmi and edge ai applications right away!

you can refer to home wiki for device wifi settings and others.

wired ethernet connection

To set up a wired internet connection, simply connect your raspberry pi to the back of your network router with an ethernet or rj45 cable. once plugged in, you should see the network led blink on your raspberry pi.

In most cases, your cable internet connection will now be active and ready to use, as long as your router has dhcp enabled. dhcp stands for dynamic host configuration protocol and basically assigns ip addresses to devices that connect to your router.

To enable dhcp, access your home router’s admin console with another computer that’s already connected. You can usually do this by entering your router’s IP address into the address bar of any internet browser.

for more details, computer hope has a free detailed guide here.

wireless connection – wifi hardware

To set up a wifi connection, we will first need a wifi module for our raspberry pi. Fortunately, all Raspberry Pi models from Raspberry Pi 3 Model B (2016) and later ship with built-in Wi-Fi. If you have an older model on hand or its built-in Wi-Fi module doesn’t work, you’ll need to use an external USB Wi-Fi adapter.

When choosing a Wi-Fi adapter, make sure it is supported by the driver. for example wifi adapters with rtl8192cu chipset will work easily as they have built in support for raspberry pi os.

Another consideration is power consumption. Wi-Fi can require a lot of power, especially if a large amount of data is being transmitted. for the older raspberry pi in particular, you may need an external power source, such as a powered usb hub, to power the wifi adapter.

For more details on how to select a suitable usb wifi adapter, you can read this page on elinux.org. they also have a list of compatible wifi adapters for raspberry pi!

[updated Mar 2021] the only method you need to setup raspberry pi wifi!

With a new update to the Raspberry Pi Imager, it’s now easier than ever to set up Wi-Fi on your Raspberry Pi, whether you opt for a stand-alone setup or not. Let’s get started!

step 1: Install the latest version of raspberry pi imager for your operating system here.

step 2: open the raspberry pi imager. you should be greeted with the same old screen.

step 3: press ctrl + shift + x to open the advanced menu (cmd + shift + x for mac osx).

Step 4: Scroll down to Set up Wi-Fi, check the box and enter your Wi-Fi credentials.

note: make sure you change the country of your wifi according to your country code!

step 5: click save and update your operating system on your microsd card for your raspberry pi. that’s it!

There are also other settings in the advanced options menu that you can explore. For example, you can enable ssh to facilitate headless installations and even configure the hostname of your raspberry pi.

other methods to configure raspberry pi wi-fi

The methods shared in the following sections are still valid and will work to configure Wi-Fi on your raspberry pi. however, I recommend that you follow the newer method, as it will be much easier for you!

method 1: configure wifi with raspberry pi os gui

For users running the Raspberry Pi OS desktop on their Raspberry Pi, you can simply use the provided GUI to configure your Wi-Fi connection. this works just as you would expect with your other laptops or smartphones.

method 2: configure wifi from the command line with raspi-config

if you are running a raspberry pi os server distribution without a gui, you will need to use raspi-config instead. this method also works on the desktop of raspberry pi os.

raspi-config is a console based application used to configure various settings on the raspberry pi. can be used for network configuration, remote access configuration, boot options, etc.

to open raspi-config at the command line, type the command:

Using the arrow keys on your keyboard, navigate to “network options” and press enter.

select wi-fi, then follow the on-screen instructions to enter your network’s ssid and password. When you’re done, select “finish” from the main menu to close raspi-config.

finally, restart the raspberry pi to apply the settings we just changed. your wifi connection should be ready to go!

configure wifi on a raspberry pi without peripherals

a headless raspberry pi is one that we would like to run without a monitor, keyboard, or mouse. As you can imagine, it won’t be that easy to apply the methods we’ve covered so far.

enable ssh (secure shell)

For this section, we will first want to enable ssh on our raspberry pi. this is something you’ll want to do if you’re running your raspberry pi headless anyway.

With ssh, you can use an internet connection to remotely execute terminal commands on the raspberry pi from your main computer via an internet connection.

To enable ssh on a headless raspberry pi, simply put a file called “ssh”, without any extension, on the boot partition of another computer’s sd card. this will tell the raspberry pi to enable ssh on boot. the content of the file doesn’t matter.

note: do not connect your raspberry pi directly to a public network if you have not yet set strong passwords for all users. your device may be compromised by hackers.

method 1: enable wifi via ethernet cable

this method involves using an ethernet connection to use ssh to configure our wifi.

once our ethernet connection has been established via a wired connection to our router, please refer to the dhcp mapping table in your router’s admin console to get the ip address of your raspberry pi.

once we have obtained the ip address, we can use any ssh client like putty on windows to access the raspberry pi. linux and macos users can use ssh without any additional software.

on linux or macos, simply enter the following command with the <ip> for your device.

once the connection is successful, we can simply use:

to configure our wifi connection as we have done before!

method 2: enable wifi via wpa_supplicant

This method consists of replacing the wpa_supplicant.conf file on our raspberry pi to provide our wifi configuration.

First, you’ll want to create a wpa_supplicant.conf file with the following content. you can do this with any text editor.

remember to replace <country code>, <ssid> and <password> with your own country code, wifi ssid and password.

then mount your raspberry pi os sd card on your computer and copy the wpa_supplicant.conf file to the root of your sd card’s /boot partition. Similar to how we enabled ssh, the file will be used on boot to apply our new wifi settings to our raspberry pi.

Since we are totally unattended, it can be difficult to work around this wifi setup method. If it doesn’t work the first time, check and make sure your wpa_supplicant.conf file name and content are correct before trying again.

once we successfully set up our wifi connection using any of the above methods, we can now use ssh over wifi to interact with our raspberry pi’s command line!

test your wifi connection

verify ip address

To make sure our Wi-Fi connection has been successfully established, please unplug your ethernet cable first. we can check our ip address through the command line with:

next to “inet”, we should see our ip address, indicating a successful connection.

ping a website

Next, we can check if our Wi-Fi connection allows us to send and retrieve data to and from our favorite websites. try pinging google.com to see if you can access it.

summary

We have shown you several ways to configure Wi-Fi on the Raspberry Pi!

If you’re just starting out with your pi, consider setting it up as a vpn server! visit our blog to learn how to set up a raspberry pi vpn server using pivpn and browse safely on public networks.

the following seeed articles will also give you more knowledge and ideas on what to do:

  • learn all about raspberry pi: introduction, projects, software, tutorial
  • top 35 4 raspberry pi projects you must try now
  • rasberry pi tutorials – guides and projects
  • multi-stage inference with edge impulse/tensorflow lite – reterminal (raspberry pi cm4 inside)

for more information and things you can do with raspi-config or ssh, check out these articles from the raspberry pi foundation:

  • wireless connectivity
  • raspi-config
  • remote access with ssh

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button