Raspberry Pis are so handy as a result of they’re cheap and small, however connecting one to its personal monitor, keyboard and mouse requires much more area and cash. In the event you’re simply making an attempt to program on the Pi or use it to regulate electronics similar to lights, motors and sensors, there isn’t any want to attach it to a show or enter gadgets as a result of you’ll be able to management the system remotely, utilizing a VNC or SSH shopper in your principal pc. We name this screenless set up a  headless Raspberry Pi setup.
By default, the Raspberry Pi’s official working system, Raspberry Pi OS (previously often known as Raspbian), installs with all types of distant entry disabled. However the excellent news is that you do not want to connect with a monitor and keyboard with a purpose to flip them on. By following the directions beneath, you’ll be able to create a headless Raspberry Pi that is prepared for distant entry earlier than you boot it up for the very first time. When you have a monitor and keyboard readily available, you can too see our information on The way to Set Up a Raspberry Pi for the First Time.
Putting in Raspberry Pi OS on Your microSD card
1. Insert a microSD card into your pc. Your card ought to be 8GB or bigger (the lite model of Raspberry Pi OS will use much less area). We have now a listing of the greatest microSD playing cards for Raspberry Pi that will help you select one which optimizes efficiency.
2. Obtain, set up and run Raspberry Pi Imager (opens in new tab).Â
3. Click on the Select OS button. A menu seems.
4. Choose your OS. Your best option for most individuals is Raspberry Pi OS (32-bit). Nonetheless, if in case you have a Pi 3 or 4, you need to use the 64-bit model which is underneath “Pi OS (different). There are additionally different selections.
5. Click on Select Storage and choose your card from the menu.Â
6. Click on the settings button or hit CTRL + Shift + X to carry up the settings menu.
A menu seems.
7. Toggle set hostname and change the hostname in order for you your system to be named something aside from “raspberrypi.”Â
8. Toggle allow SSH to on and choose “Consumer password authentication.”Â
9. Set a username and password to your Pi. Notice that in case you use the password “raspberry” with username “pi,” you could get a warning message if you log in, recommending (however not forcing you) that you simply change the password.
10. Set your Wi-Fi community’s SSID, password and nation. Then click on Save. The nation often defaults to “GB” (Nice Britain) so, in case you are within the U.S., you’ll have to scroll down a extremely lengthy approach to get the nation code you want.Â
11. Click on Write and click on Sure if requested whether or not you’re certain you wish to proceed.
The system will now take a couple of minutes to obtain the OS and write it to your card.Â
When it is completed, you’ll be able to pop your card right into a Raspberry Pi, boot it up, wait just a few seconds for it to get onto the community and try to log in by way of SSH, supplied that you simply’re utilizing a Wi-Fi community and each the Pi and your shopper PC are linked to it.
Enhancing Wi-Fi on a Prewritten Card
For instance you already wrote a card, however forgot to enter the right Wi-Fi credentials in Raspberry Pi Imager. Or maybe you moved to a special Wi-Fi community. You’ll be able to nonetheless change the Wi-Fi community, with out attaching a display and keyboard to the Pi.
To setup a Wi-Fi connection in your headless Raspberry Pi, open the microSD card in your PC. Then create a textual content file referred to as wpa_supplicant.conf, and place it within the root listing of the microSD card. You will have the next textual content within the file.
nation=US
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
community={
scan_ssid=1
ssid="your_wifi_ssid"
psk="your_wifi_password"
}
Change the nation to “GB” for the UK or to a different nation code for a special nation, and enter your precise SSID and password. Upon boot up, Raspberry Pi OS will log you into that community. Nonetheless, in case you’re on a public Wi-Fi community that requires you to click on “Okay” on a splash web page earlier than you get Web, this methodology will not work.
Want to make use of Ethernet? In the event you plug your Raspberry Pi on to a wired community, you need to be capable of entry it by its identify (raspberrypi or raspberrypi.native) with out altering another recordsdata.
Direct USB Connection (Pi Zero / Zero W Solely)
My favourite approach to join is by way of a direct USB connection, plugging my Pi Zero W instantly right into a port on my PC. This methodology is nice, as a result of it really works regardless of the place you’re (even when there isn’t any out there Wi-Fi), and it supplies each energy and a connection to your Pi, over a single cable. Nonetheless, you’ll be able to solely do that on a Pi Zero or Zero W.
1. Open the file config.txt within the root listing of the micro SD card, and add the road dtoverlay=dwc2 to the very backside of the file and save.
2. Open cmdline.txt and add the textual content modules-load=dwc2,g_ether after the phrase rootwait, and save the file. There aren’t any linebreaks on this file.
3. Obtain and set up Bonjour Print Companies (opens in new tab)Â from apple.com (if in case you have Home windows). It appears unusual that you’d want an Apple program to entry a Pi from Home windows, however this helps your PC see the Pi. Ignore the identify; you are not utilizing this for printing.
4. Join the micro USB cable to the port labeled “USB” on the Pi Zero. This is not going to work in case you connect with the port labeled “PWR.” Nonetheless, the “USB” port may even provide energy to your Pi, so that you needn’t join a devoted energy wire.
Direct Ethernet Connection
In case your PC has a spare Ethernet port or you’ve gotten an Ethernet-to-USB dongle, you need to use a community cable to go instantly out of your Pi to your pc. Simply just remember to have Bonjour put in in your PC and SSH enabled on the Pi (see above). Then, you’ll be able to simply join the 2 gadgets over Ethernet.
If you need the Raspberry Pi to get its Web connection out of your PC over the Ethernet port, it is advisable to do the next in Home windows 10 or 11:
1. Navigate to the Community Connections menu, which is a part of the old-school Management Panel. You may get to this display by going to Settings->Community & Web->Wi-Fi after which clicking “Change Adapter Settings” on the precise aspect of the display. This works whether or not you’re sharing an Web connection that involves your PC from Wi-Fi or from Ethernet.
2. Proper-click on the adapter that is linked to the Web, and choose properties.
3. Allow “Permit different community customers to attach” on the “Sharing” tab.
4. Choose the Ethernet port that’s linked to the Raspberry Pi from the “House networking connection” menu, and click on Okay.
Connecting to Your Pi by way of SSH
After you’ve gotten the Pi linked to your community or on to your PC, you will want to ascertain an SSH connection.
1. Obtain and set up Putty in case you do not have already got it. Putty is the main SSH shopper for Home windows.
2. Enter the hostname (by default raspberrypi or raspberrypi.native ) because the deal with you want to connect with in Putty, and click on Open. You often want so as to add the .native if the Pi is instantly linked to your PC by way of USB or Ethernet cable.
3. Click on Okay in case you get a safety warning alert. It is not an issue.
4. Enter your username and password.
Now you are linked on the command immediate, however if you wish to entry the GUI, full with a desktop and floating home windows, you will must allow VNC.
Enabling and Connecting over VNC
1. Enter sudo raspi-config on the command immediate.
A configuration app opens.
2. Choose Interfacing Choices (quantity 5 on the checklist)
3. Choose VNC (quantity 3 on the menu)
4. Choose Sure.Â
5. Hit Enter to acknowledge the VNC server is enabled.
6. Choose End
In your PC:
1. Obtain, set up and launch VNC Viewer.
2. Choose New connection from the File menu.
3. Enter the host identify (ex: raspberrypi.native) within the “VNC Server” discipline. If this doesn’t work, attempt once more with out the .native within the identify.
4. Click on Okay.
5. Double-click on the connection icon to attach.
6. Click on Okay in case you are proven a safety warning.
7. Enter the Pi’s username and password when prompted.Â
Your Raspberry Pi desktop will then seem in a window in your principal pc’s desktop. You’ll management all the things from there.