How to Connect a Raspberry Pi to WiFi

Built-in WiFi on a computer is a feature and a security hazard. Being conscious of it and taking control of it are two good steps on the way to better Raspberry Pi operations. In this article, we’ll take a look at two different methods of controlling the WiFi feature on a Raspberry Pi.

Method One: Plan for It!

Right after you create your bootable SD card and you close the imager software, your Windows computer will probably try to automount the /boot partition on the newly minted SD card. Take this as an opportunity and a reminder. If you plan on using wireless on this Raspberry, you can set the stage by putting the wpa_supplicant.conf file in place now. While you’re at it, create an empty file called ssh in this same partition. It will execute the sshswitch service at boot time to start the OpenBSD Secure Shell server then remove the created file, so you can connect to the Raspberry with ssh.

The wpa_supplicant.conf is a file that you can put in place ahead of time in the /boot partition to enable the Raspberry to attach to your wireless network. It’s just a simple text file that looks like this:


Replace wifi_name with your existing wifi ID and replace wifi_password with your wifi’s password. The quotes stay in place in the edited file. I keep a copy of this file and a blank file, named ssh, on my desktop so I can easily drag and drop them into the /boot folder on the SD card after Windows opens that folder for me.

Method Two: raspi-config

If you’re in terminal mode, run this from the command prompt:

sudo raspi-config

This starts the Raspberry Pi Software Configuration Tool. You’ll get a menu of available options. Arrow down to Network Options and then Wireless LAN. Choose your Country and hit Enter on OK to confirm. Next, type in your Wireless LAN name, followed by the password on the next screen. The program will create a new wpa_supplicant file or overwrite your existing file. Upon the next reboot, your Raspberry will be on the Wireless LAN.

Method Three: Edit config.txt for the wireless on/off switch

You can directly edit the config.txt file located on the boot partition. To turn off the wifi, put this line somewhere in the file. The end is a convenient place. It really doesn’t matter where.


To turn the wifi back on, just comment out or delete the line!

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.