How to Setup a Raspberry Pi for Headless Remote Access
2020-08-18 | By Nate_Larson
A Raspberry Pi is a great little computer to have in your arsenal of electronics, but what does one do if you don’t have the space for all the basic peripherals that typically accompany a computer? In this tutorial we’ll review a quick and easy method to get your Pi up and running completely headless, i.e. without a keyboard, mouse, or even a monitor; while providing full access to the desktop environment, even when connected to a remote network.
(Image source: DigiKey)
Required Hardware
As mentioned above, this will be a headless setup, so the hardware required will be quite minimal for this tutorial. Below is a list of hardware that will be needed.
- Raspberry Pi
- We will want to begin with a Raspberry Pi with wireless networking capability. This has become standard on recent iterations of Pi boards, so we can select any of the Model 3 or Model 4 options currently available, or even a Zero W. Although the below method may work with older versions of the Pi that don’t have native Wi-Fi, additional hardware would be required which may require software provisioning not covered here.
- Power supply
- Remember that older Pis have a micro USB power connector while the Model 4 boards have USB C for power; take care to select the appropriate power supply for your board.
- MicroSD card
- It is recommended to use a Class 10 or better microSD card with a capacity of 8GB or greater.
- MicroSD card reader (optional)
- May be needed to connect your microSD card to your computer, in order to flash the software.
Required Software
There are a few pieces of software that will be needed to setup and access our Raspberry Pi; these will need to be installed on a Windows or Mac computer. Links for the downloads are provided below. A couple of these tools are open-source, so please consider contributing or donating to the developers.
- SD Memory Card Formatter
- SD Memory Card Formatter tool formats SD/SDHC/SDXC Cards complying with the SD File System Specification created by the SD Association (SDA).
- PiBakery
- PiBakery is an open-source tool that creates a customized version of Raspbian that can include a set of scripts that run when the Raspberry Pi is powered on, which can automatically perform setup tasks. Please ensure during installation that you do not select the “Raspbian Lite” option as this version does not include the GUI desktop interface.
- Angry IP Scanner
- Angry IP Scanner is an open-source and cross-platform network scanner for fast and simple scanning of IP addresses, ports, and more.
- VNC Viewer
- RealVNC’s VNC Viewer allows users to connect to computers running a VNC Server, which is included by default in the Raspberry Pi operating system.
Preparing the microSD card
The first step in preparing the microSD card is to ensure it is formatted correctly. To do so, insert the microSD card into the reader on your computer and note the correct drive. It is critical to get this correct as the formatting process will erase any data on the drive selected. Launch the SD Card Formatter program, select the correct SD card, and click the Format button. Note that the quick format option is fine for our purposes and once formatting is complete you can close the program, but do not remove the SD card yet.
Next, we will launch the PiBakery application and accept any block updates that are available. Within the PiBakery main screen you will see a selection of headings on the left and a workspace on the right, similar to many other Scratch-style block-based applications. Under Startup drag the “On First Boot” block into the workspace.
Under the first boot block we will add the “Setup Wi-Fi” block from the Network heading. Change the “Network” text to match that of your Wi-Fi SSID that we will be connecting the Pi to, then add the correct password in the “Pass” text box, ensure the “Type” is set to match the security encryption of your Wi-Fi network, and enter the proper ISO 3166 country code for your location.
Next, from the Settings heading add the blocks to set the hostname and user password. These are not required but adding a unique hostname will make it easier to identify your Raspberry Pi, especially if there is more than one Pi running on the network, and it is good practice to always change default passwords.
Finally, add a “Reboot” block from the Other heading to the bottom of block of actions to reboot the Pi and apply these settings.
Now we need to create one more set of blocks. Drag the “On Every Boot” block from the Startup heading and add the “Enable VNC Server at Boot” from the Programs heading below the On Every Boot block. The Raspbian software includes Virtual Network Computing (VNC) server software from RealVNC by default and enabling this software will allow us to remotely connect to the Raspberry Pi later in this tutorial.
Now our configuration is complete, and we are ready to write the software to the microSD card we previously formatted. Simply click the Write icon in the upper left corner.
Select the appropriate SD card, and ensure the operating system selected is Raspbian Full. Once this is confirmed, click “Start Write” and wait for the program to complete writing to the SD card.
Once complete, close the program and remove the microSD card from your computer.
Booting and connecting to the Raspberry Pi
Now that our microSD card is ready, we can insert it into the Raspberry Pi and connect the power supply. Allow 5-10 minutes for the Pi to boot and configure the settings we defined in the previous steps.
When you are confident your Pi has finished configuration and rebooted, open the Angry IP Scanner program on your computer – you will need to be connected to the same network as what was defined in the previous step in order to locate the IP address of your Pi. The application should preload the correct IP Range for your network, so you shouldn’t need to change any of the settings, just click the start button to begin scanning.
When scanning has completed you can review the results and check the “Hostname” column for your device. You should find the hostname you defined previously listed in this column, potentially followed by “.local”.
Once located, record the IP address of your Pi, open the VNC Viewer application, input this IP address in the text box, and press enter to connect.
You may receive an identity check message at this time, please verify the IP address is correct and click Continue.
On the Authentication screen, enter “pi” as the username and the user password that you defined earlier and click OK.
You should now see your Raspberry Pi’s desktop in a window on your computer. From here you can use your Pi as you normally would, but without the clutter of an additional keyboard, mouse, and monitors. When finished with the tasks on your Pi, simply end the VNC session using the drop-down toolbar in the VNC Viewer window, your Pi will continue to run on its own, waiting for you to connect again.
Keep in mind at this point you are only able to connect to your Pi from within the same network, and depending on your Wi-Fi router’s settings, your Pi may change IP addresses unless you assign it a static IP within the network. You may be satisfied with the setup at this point, but if you want remote access from outside the network you will need to sign up for a free account from Real VNC. Once your account is created you can connect your Pi’s VNC server to your account by simply clicking the VNC logo in the top toolbar of your Raspberry Pi’s desktop, clicking sign-in, entering your account info, and selecting the option to allow cloud connectivity. Additionally, this same login information can be used in the VNC Viewer application installed on any compatible device to allow you access to your Pi, which should now display within the “Team” view of the VNC Viewer application.
Conclusion
We now have a Raspberry Pi up and running entirely headless, requiring nothing more than a power supply and microSD card and accessible from anywhere via the VNC Viewer application. Since your Pi is now remotely accessible, keep security in mind – use a strong password, keep your Pi updated by using the “sudo apt update” and “sudo apt full-upgrade” commands regularly in the terminal, and consider creating a backup copy of your SD card.
Have questions or comments? Continue the conversation on TechForum, DigiKey's online community and technical resource.