How to Use Raspberry Pi via VNC

Are you creating a project that requires remote access to the Raspberry Pi?

You can enable SSH on the Pi and access it remotely from another system using a terminal.

However, not everyone is familiar with the terminal and commands.

An alternative is to access the Raspberry Pi via VNC. This way you create a remote connection to the Pi and use it graphically as if it were connected to your monitor and keyboard.

Control raspberry pi with vnc
Control raspberry pi with vnc

Of course, depending on the configuration of the Raspberry Pi system and the network speed, such a connection can be somewhat delayed.

But at least you can access it graphically remotely.

It consists of these steps:

  • Enable VNC via the settings in Raspberry Pi
  • Use a VNC client on the remote machine you want to access your Pi from (on the same subnet).
  • (optional) Set up a complicated VNC configuration or use Real VNC’s paid option to access the Pi over the internet

Let me show you how to access the Raspberry Pi using VNC software. But first quickly

What is VNC?

The term VNC stands for Computing in virtual networks. Think of it as SSH but with GUI. It allows you to remotely connect to a computer on a network and allows you to control it through the normal GUI as if you were using it physically. VNC corresponds to TeamViewer Type of application.

In our case, VNC helps us control the Raspberry Pi over the network, but as if the mouse, keyboard, and display were physically connected to the Raspberry Pi. VNC is not limited to PC use. You can also control your Raspberry Pi from a phone or tablet!

Several VNC programs are available. I will use RealVNC here. It’s (probably) a proprietary solution by the original developers of the VNC protocol.

Step 1: Enable VNC on the Raspberry Pi

Normally, the required packages should already be installed on the Raspberry Pi OS. However, you can ensure this by reinstalling them.

sudo apt install realvnc-vnc-server realvnc-vnc-viewer

Once you have the required package, enable the VNC service.

There are two ways to enable the VNC service; with the GUI or with the CLI tool raspi-config. I will discuss both.

Method 1: Using the GUI

This is the easiest way to enable VNC service. The steps to do this are as follows (for the standard Raspberry Pi operating system):

  1. Select in the top bar Menu > settings > Raspberry Pi configuration.
  2. In the application view, switch to interfaces Tab.
  3. Make sure the VNC service is set Allowed.
Screenshot of the Raspberry Pi configuration tool with VNC enabled
Screenshot of the Raspberry Pi configuration tool with VNC enabled

Method 2: Using the raspi-config tool.

The ‘raspi-config’ tool is a lifesaver on the Raspberry Pi. It has all different knobs that you can tweak to achieve your desired configuration.

To enable the VNC service, run the following command in your terminal:

sudo raspi-config

This will launch the raspi-config tool in your terminal. Go to interface options and find the option that says VNC and activate it.

Raspi config

Finished! You have now set your Raspberry Pi as your VNC server.

Step 2: Connect to the Raspberry Pi (via LAN)

You have activated the VNC server on Raspberry Pi. Let’s connect with it.

Get the IP address of the Raspberry Pi

There are several ways to get the Raspberry Pi’s IP address. You can check your router for all devices; or if you are already connected to the Raspberry Pi via SSH, it is best to use the “hostname” command as follows:

hostname -I

Running the “hostname” command will give you the IP address assigned to the Raspberry Pi.

Please note that if your Raspberry Pi is not assigned a static IP address by your router, it may change over time.

In my network, the Raspberry Pi received “192.168.11.4” as the IP address. So, that’s what I’m going to use. Yours will be different.

Get the RealVNC client

Just like SSH requires a server and client software, VNC also requires a client. You can visit RealVNC’s website to download the client for the operating system on your PC/phone/tablet.

Download realvnc viewer
Download the RealVNC viewer

Once the installer has downloaded, install using the default method most appropriate for your operating system and launch the RealVNC client.

Connect to the Raspberry Pi

Once you have the RealVNC client installed, open it. They have an address bar at the top (despite major UI redesign). Please enter the IP address of the Raspberry Pi here.

Once you enter the Raspberry Pi’s IP address in the top address bar, you will be prompted for a username and password. Here, use the credentials you use to log into the Raspberry Pi itself – the same ones used for SSH.

RealVNC authentication dialog
RealVNC authentication dialog

My username and password are ‘pi’ and ‘raspberry’ respectively. So I will use these credentials to log in.

Your computer should connect to the Raspberry Pi using a VNC session. Congratulations! 🙂

Optional: Connection to the Raspberry Pi (via the Internet)

You’ve just learned how to connect to the Raspberry Pi on the same network, but what if you’re away from home and want to connect to the device over the internet?

No need to remember an IP address or change your firewall or router configuration. RealVNC handles everything through your RealVNC account.

The downside to this is that you need a paid account. At the time of writing this article, the cheapest subscription available is $3.39 per month (billed annually).

If you’re okay with one more subscription and need to access the Raspberry Pi frequently over the internet, this subscription should be worth it.

Conclusion

I use SSH to remotely connect to my Raspberry Pi. Using VNC might also be a good choice if you need the convenience of the GUI. This works without much effort if the devices are in the same subnet.

I hope you enjoy this quick tutorial useful in accessing your Raspberry Pi with VNC. Let me know if you have any questions and I will do my best to help.


Leave a Reply

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