DEV Community

Cover image for Running A Headless Raspberry Pi
Otuekong Arthur
Otuekong Arthur

Posted on

Running A Headless Raspberry Pi

Imagine having a Raspberry Pi, a tiny computer that fits in your palm, running smoothly without the need for a monitor, keyboard, or mouse. This is what we call running a headless Raspberry Pi: a setup where the Pi operates without a traditional display and input devices. It might sound a bit techy, but it's simpler than you think.
In this article, we'll walk through the basics of running your Raspberry Pi headlessly, unlocking its potential without the clutter of additional peripherals.

Aside

I recently got a Raspberry Pi from a friend and many things have been flooding my mind on what to use it for:

  • Perhaps If I add another Raspberry Pi I could run a Kubernetes Cluster
  • Practice my Linux skills
  • Use it for some home automation ideas in the future.

Even though I have Ubuntu Linux running on my Windows machine, I still need the feel of a standalone Linux machine and my tiny raspberry pi cuts it for me.
Anyway, let's get to it.
These are the list of things I will be working with:

Note:
I recommend you install the recommended software on your machine before we start.

Overview

In summary, we are going to perform 9 steps:

  1. Insert Or connect our SD card to our computer
  2. Format the SD card
  3. Selecting the Device and operating system in the Raspberry Pi Imager
  4. Configure settings for our Raspberry Pi Os
  5. Download Raspberry PI OS to our SD card
  6. Insert Our Sd card into the Raspberry PI
  7. Connect the Raspberry Pi to a power source
  8. Remotely SSH into the Raspberry PI over a Wi-Fi network
  9. Use RealVNC viewer to Remotely access the Raspberry PI over a Wi-Fi network

About Raspberry PI

According to Wikipedia, Raspberry Pi is a series of small single-board computers (SBCs) developed in the United Kingdom by the Raspberry Pi Foundation in association with Broadcom.
In summary, they say that a Raspberry Pi is a small computer that has all the Storage and memory (RAM) on a single and small board.
As earlier stated, I will be using a Raspberry Pi 3 model B with 1 gigabyte of Random Access Memory(RAM) and 8 gigabytes SD card for storage
First connect your SD card to your computer, if your machine has an SD card slot like mine then you may just slide it in else you should get an SD card adapter.
Launch the Raspberry Pi Imager and you’ll get to see the below screen:

Image description

Next, you will get to choose your Raspberry Pi device, go ahead and choose your device

Image description

In my case, I selected Raspberry Pi 3 as my option. You can see that it has all the submodels under it.
Go ahead and choose the Operating system(OS)

Image description

Next, click on Choose Storage and select your SD card as the storage

Image description

You may now click on the Next button.

Image description

At the click of the Next button, you’ll be prompted with the OS Customisation menu as below:

Image description

Under the OS customization menu are 3 tabs

  • General
  • Services
  • Options

First, the General tab provides a way to set our hostname for the Raspberry Pi and set username and password. Under Configure wireless LAN, Add your Wifi network name and password. Also choose your country under Wireless LAN country, in my case, I selected NG which is the symbol for Nigeria.
Next, under Set locale settings, choose your timezone and keyboard layout.
Move to the services tab:

Image description

Under the services tab, enable SSH(Secure Shell). This is very important as it will allow us to communicate with this device over the Wifi network through the terminal. Also, choose password authentication.
Done with the services tab, move to the Options tab:

Image description

Just as the name suggests, The Options tab is optional, but for me, I need my machine to play sound when it is finished downloading the OS. I also need it to automatically eject the SD card when completed and also enable telemetry which provides OS downloads data to Raspberry.
When done, click on the Save button and you will be presented with the confirmation screen below:

Image description

Click Yes.

You’ll then be prompted to confirm if you want to do this:

Image description

Since you are sure of what you are doing, click Yes.

If everything goes well, you should see the below output:

Image description

If you are getting the “Please insert a disk into ..” error like the below output

Image description

This little SD formatter tool should fix the issue.

After some time, the download will start:

Image description

If you chose the Eject media option, your SD card will be automatically ejected when installation is completed. If you did not, you will have to eject it yourself manually.
Next, we will run the Raspberry OS on our Raspberry PI.

Getting Raspberry Pi Running

Insert the SD card card into your Raspberry PI and plug in the power cable.
After some seconds your Raspberry PI should be up and running.
We need to find a way to communicate with this device.
Remember we had a wifi network as one of the things you’ll need in this tutorial?
Get your Raspberry Pi and your machine on the same Wifi network you configured in Os customization for the Raspberry Pi.
After you have them both connected to the same network, under
This is the time that we bring in one Putty. Putty is an SSH client that will let us communicate with our Raspberry Pi on the Wifi network using its IP address.
Open your Wifi router menu and copy the IP address of the Raspberry Pi on the network. Open Putty and paste the IP address like so:

Image description

Click on open.

You will be prompted to enter your username and password. If the login is successful, you should see a screen similar to below

Image description

Hurray, we are in.
We can use our tiny computer from here(command line) or even take it further and get a graphical user interface(GUI) from it.
To achieve this we need Virtual Network Computing(VNC) software. VNC is a remote access technology that enables computers to access and take control of another computer.
In this tutorial, we will be using a type of VNC called RealVNC viewer.
RealVNC comes in 2 parts: RealVNC viewer that we have installed on our machine and RealVNC Server that talks to us from the computer we want to access.
We have to get into our tiny machine and enable the RealVNC Server.
In the Putty terminal run the command below:

sudo raspi-config
Enter fullscreen mode Exit fullscreen mode

On running the above command, you’ll be shown the screen below

Image description

What is of particular interest to us is the Interface Options. Navigate to the Interface Options using the arrow down key and press enter when you are there.
This gets you to the screen below:

Image description

Use the down arrow key to scroll to VNC and hit enter

Image description

Use the left and right arrow keys to toggle between Yes and No. Toggle it to Yes and press the enter key.
It shows that the RealVNC server is enabled by showing the following output

Image description

Click on enter and use the right arrow key to navigate to finish. Then press enter.
RealVNC Server is now ready to talk to our machine.

Accessing Raspberry Pi through RealVNC viewer(Desktop)

Open RealVNC viewer, click on the file tab then “new connection”.
The below output is what you should see next.

Image description

Copy and paste the Raspberry Pi IP address to the “VNC Server” then click OK.
Right-click on the monitor icon and click connect
It will ask for your RealVNC username and password, supply it and

Image description

Click Ok

Image description

You may play around with it, ensure you shut it down before you unplug the power cable.

Image description

Accessing Raspberry Pi through RVNC viewer(Mobile)

It is also possible to remotely access the Raspberry Pi with your smartphone.
To achieve this, search and install RVNC viewer on Google Play Store for Android or App Store for iOS.

Image description

Click on the + button

Image description

Next, input your Raspberry Pi IP address and click Create.
You will be presented with the below screen

Image description

Click on “Connect”
Add your username and password and click “Continue”

Image description
Behold your Raspberry PI on mobile
Image description

Conclusion

Running a headless Raspberry Pi offers an efficient way to use this versatile mini-computer. By eliminating the need for monitor and input devices, you not only save space but also open up possibilities for various projects and applications.

Top comments (0)