Raspberry Pi is an inexpensive small form factor PC that can behave like a standard computer in many respects. Users can use this innovative mini-computer for all kinds of functions, from setting up an operating system to surfing the web, to using it as a server or a media center, and much more besides. Discover 10 interesting Raspberry Pi projects to try out at home.
Despite its minimal dimensions, the Raspberry Pi is appealing due to its various ports (USB, network), and its good computing performance. The minicomputer is a component of many electronic DIY projects, and a popular platform for a wide variety of server applications. The direct operation of the Pi via mouse, keyboard, and monitor is not always possible, which is why a separate desktop PC is often used to manage the operating system and resources of the Raspberry remotely. Usually an SSH connection to the Pi is established for this, which enables quick and easy access to the command line. Alternatively, using a VNC server on the Raspberry Pi also allows remote access to the user interface. This article will show you what that means, and how to do it.
- VNC server on Raspberry Pi: what does this mean exactly?
- Setting up VNC on the Raspberry Pi: requirements
- Tutorial: how to set up VNC on Raspberry Pi
- Step 1: install or update VNC Connect on the Raspberry Pi
- Step 2: activate VNC server on Raspberry Pi
- Step 3: check connection settings
- Step 4: install VNC Viewer on external
- Step 5: establishing a direct connection to Raspberry Pi (in the local network)
- Step 6: establishing a cloud connection to the Raspberry Pi VNC server
- Step 7: adjust screen resolution of Raspberry Pi
- Step 8: performance optimisation for VNC on Raspberry Pi Zero and Pi 1
VNC server on Raspberry Pi: what does this mean exactly?
VNC (virtual network computing) is a client-server software which can be used to display and control the screen content of the target system (server) on another system (client). For this purpose, keyboard entries, mouse movements, and clicks on the client side are transferred directly to the remote computer. So, if you install and activate VNC on a Raspberry Pi, you can easily install, configure, and manage the minicomputer from another PC. VNC is based on the cross-platform network protocol remote framebuffer protocol (RFB), which transmits the content as bitmaps and uses TCP port 5900.
This guide explains how to set up a VNC server on the Raspberry Pi to operate it remotely. Of course, it is also possible to install a VNC client on the minicomputer itself and control another PC remotely in the same way.
Setting up VNC on the Raspberry Pi: requirements
VNC software is designed to be as resource-efficient as possible. The more resources other applications running on the Raspberry Pi require, the more relevant this point becomes. In principle, however, there are no restrictions on the choice of the Raspberry Pi model: you can set up and run a VNC server both on a first-generation Pi just as well as on the latest version.
For a long time, the choice of suitable software fell on either the X11VNC or TightVNC server programs. Both are suitable for the Raspberry Pi and are still used on the minicomputer today. Ever since PIXEL was integrated into the user interface in Raspbian, the standard operating system with VNC Connect also has its own virtual network computing application on board – all you have to do is activate it to use the remote technology. The prerequisite is that you use at least Raspbian Jessie – otherwise you have to download and install the client-server software first.
VNC Connect and X11VNC allow direct one-to-one access to the currently visible screen of the Raspberry Pi. TightVNC, on the other hand, transmits virtual versions of the original view, allowing multiple users to log on to the VNC server simultaneously (similar to the traditional terminal server concept).
Tutorial: how to set up VNC on Raspberry Pi
In the following tutorial, we will show you how to set up and use a VNC server on your device. As an example, we use the simple and uncomplicated installation and setup of the client and server components of VNC Connect – the already mentioned standard VNC suite from Raspbian – for this purpose.
Step 1: install or update VNC Connect on the Raspberry Pi
In the first step, make sure you have the latest version of VNC Connect installed on your Raspberry Pi by entering the following commands in the terminal:
sudo apt-get update sudo apt-get install realvnc-vnc-server sudp apt-get install realvnc-vnc-viewer
Raspbian updates both the server application and the client. If you are still using an older version of Raspbian or another operating system on your Raspberry Pi, you must first download VNC Connect. Simply visit the official homepage of the developer RealVNC, and select the installation file for Raspberry Pi in the download centre.
Step 2: activate VNC server on Raspberry Pi
Once you have updated the software you can start the server. You can do this either via the user interface or via the command line.
To do the first, simply open the main menu (raspberry icon) and then select “settings” and “Raspberry-Pi configuration. Switch to the interfaces tab and set the VNC entry to “enabled”.
If you want to switch on the VNC server on your Raspberry Pi via the command line, you need the configuration tool raspi-config, which can be started as follows:
Go to the “interfacing options” menu item and then scroll to the “VNC” option to activate it. After activating the server, it will now always start automatically when you boot the Raspberry Pi.
Disabling the VNC server works in the same way – just select the opposite options.
Step 3: check connection settings
Once VNC Connect is installed and activated on the Raspberry Pi, restart the device and you will find the icon for the VNC server in the system tray of the user interface. Click on this icon to get an overview window of the remote access application's connectivity and security. The left side shows the IP of your Raspberry, which you need to connect to the VNC client. Make a note of the address so that you can have it ready on the external computer later. Alternatively, the IP can be found via the following terminal command:
On the right-hand side, find a signature and keywords used to verify your identity. Both should be displayed by a message when you initiate the VNC connection later. This way you can make sure that the targeted system is your Raspberry Pi.
If you want to access your Raspberry Pi regularly via VNC, it is recommended to assign a fixed IP address.
Step 4: install VNC Viewer on external
After having run the VNC server on your Raspberry Pi, you can focus on the separate computer from which you want to remotely control your Raspberry Pi. First, install the client application, VNC Viewer. RealVNC provides free installation files for various operating systems for this purpose. This allows the client to be installed on Windows, macOS, and Linux PCs, among others. There are also client apps for Android and iOS, and a chrome extension that allows VNC Viewer to run from the Google browser. You can download these from the Real VNC Download Center.
Step 5: establishing a direct connection to Raspberry Pi (in the local network)
The fastest and easiest way to use VNC technology is via a direct connection between the client computer and the Raspberry Pi. It is required that both devices are connected to the same local network (LAN or WiFi), and that the IP of the Raspberry is known. If this is the case, start VNC Viewer, enter the address in the address line provided, and start the connection setup with the enter key.
The client application will then open a pop-up message with a signature and keywords for identity verification.
You will then be asked to enter your user name and password. This is the Raspberry Pi user account – by default use the credentials as following: user “pi” with the password “raspberry” To prevent access by unauthorised users, it is advisable to change this standard data (preferably before starting the VNC server).
Step 6: establishing a cloud connection to the Raspberry Pi VNC server
If you do not want to or cannot connect the client system and the Raspberry Pi via a local network, you also have the option of establishing the VNC session via the internet instead. For this kind of cloud connections, you only need a RealVNC account. This is also free and can be created quickly. For the registration process, visit the RealVNC homepage and enter your e-mail address in the sign-up box.
The log-in data for your newly created RealVNC account (e-mail address and password) is now required twice – in the VNC server application on the Raspberry Pi, and on the client side in VNC Viewer. In the server program, add a link to the account by entering the mail and password under the “licensing” menu item and then press “sign in.” On the client device, simply log on with the account in VNC Viewer. The Raspberry Pi is then automatically listed as an available host, so simply double-click on the icon to establish the VNC connection.
Step 7: adjust screen resolution of Raspberry Pi
If the remote connection to the Raspberry Pi VNC server is established, it may be necessary to change the screen resolution of the Pi for two reasons:
- Performance may be limited because the resolution is too high
- The default resolution may have been used, because the Raspberry was only used in headless mode without a connected monitor, for example, and is therefore too low
You can find the corresponding customisation options in the tool raspi-config already in use, which you start with the familiar terminal command:
Select the “Advanced Options” menu item and then search for the “Resolution” entry. Here you can select the desired resolution before closing the tool and command line.
If you want more control over the HDMI setting of your Raspberry Pi, you can also make changes in the /boot/config.txt configuration file. With the entry HDMI-mode, define, for example, the corresponding values of one of more than 50 different HDMI output formats. A detailed explanation and a complete list of possible values can be found in the official online manual.
Step 8: performance optimisation for VNC on Raspberry Pi Zero and Pi 1
If you set up the VNC server on a Raspberry Pi 1 or Zero, the performance is not always stable due to the somewhat weaker computing power of these older models. If you are active on a secure, local network, you can alleviate this problem by disabling encryption – and thereby reducing CPU usage.
turning off encryption is only possible for direct connections, not for cloud connections.
Open the VNC server menu on your Raspberry Pi and open the options. Select the expert mode and set the encryption parameter to “AlwaysOFF.” The changes do not affect active sessions, so you must close and restart existing connections in order for the changes to take place.