VNC

Remote Access to Raspberry Pi


A while ago, we looked at how it is possible to set up a Raspberry Pi on the cheap; i.e. without the need for lots of additional bits and pieces such as monitor, mouse, keyboard, HDMI cable, etc., etc. (see http://www.makerspace-uk.co.uk/value-for-money-raspberry-pi-setup/).

As part of this set up, we looked at using SSH (Secure Shell) to allow us to remotely access a Raspberry Pi by means of a basic command window. However, it is also possible to access your Raspberry Pi remotely using the Graphical User Interface (GUI), and we’re going to look at a couple of different ways of doing this.

VNC

The first method of remotely accessing the Raspberry Pi GUI we’re going to look at is by means of VNC (Virtual Network Computing). This is a way of accessing a graphical desktop on the Raspberry Pi from another computer. In order for this to work, it is necessary to install additional software both on the Raspberry Pi, and on the computer from which you wish to access the Pi. In the case of the Raspberry Pi, it will be necessary to install a VNC server, and for your other computer you will need to install a VNC client application.

The instructions on how to install and set up the VNC server (in this case TightVNC) on your Raspberry Pi can be found at the following link:-

https://www.raspberrypi.org/documentation/remote-access/vnc/

Having set up the VNC Server on your Raspberry Pi, you will also need to install a VNC client package on the computer from which you wish to access the Raspberry Pi. The package that we use is the RealVNC VNC Viewer, which is available for a number of different platforms at the following link:-

https://www.realvnc.com/download/

Once you have your VNC Server running on your Raspberry Pi, and your VNC Viewer client package is installed, run the VNC Viewer. You should see a screen similar to that shown below:-

VNC Viewer

VNC Viewer

In this screen, you will need to enter the IP address of the Pi and VNC session number for the VNC Server that is running on the Pi; in the format <IP address>:<session number>. In the example above, the IP address is 192.168.2.135 and the VNC server session number is 1. On pressing ‘Connect’ you may see the following screen:-

VNC Viewer Warning

VNC Viewer Warning

Depending on whether or not you are bothered about having an unencrypted connection, you may either cancel or continue. Pressing ‘Continue’ should take you to the password prompt screen:-

VNC Viewer Password

VNC Viewer Password

In this screen, enter the password that you set up for the VNC server, and press OK. You should then be logged in to your Raspberry Pi, and should see a screen similar to that below:-

VNC

VNC

myDevices Cayenne

Cayenne is a simple drag and drop IoT builder which allows you to easily access and control your Raspberry Pi devices. In order to start using Cayenne, you will need to go to the following Web site and set up a user account:-

https://www.cayenne-mydevices.com/

Having set up your Cayenne user account, you will be able to add as many Raspberry Pi devices as you wish to your account. The process of adding a Raspberry Pi to your Cayenne account is fairly straight forward. From the Cayenne account web page, click on the ‘Add new…’ link, and select the ‘Device’ option. For the Device Category, select ‘Micro Computer’, and then select ‘Raspberry Pi’. This will take you to a screen similar to that below:-

Cayenne New Raspberry Pi

Cayenne New Raspberry Pi

Clicking on the ‘Generate New Raspberry Pi Installer’ link will generate a new installer script which needs to be executed on the Raspberry Pi. In order to execute this scrip, it will be necessary to log on to your Raspberry Pi using SSH (see our blog article http://www.makerspace-uk.co.uk/value-for-money-raspberry-pi-setup/), and execute the commands shown on the Cayenne web page, which will be something like:-

wget https://cayenne.mydevices.com/dl/rpi_xxxxxxxxxx.sh

sudo bash rpi_xxxxxxxxxx.sh -v

The first of these commands will cause the Raspberry Pi to download the script that was generated by Cayenne. The second command will execute the script to setup the necessary software on your Raspberry Pi. As part of this script, the Raspberry Pi will restart, and you should then see a screen similar to that shown below:-

Cayenne Raspberry Pi

Cayenne Raspberry Pi

From this web page you can access various information about your Raspberry Pi, and it is also possible to establish a remote desktop connection to the Pi by clicking on the ‘Remote Access’ link (note, that in order for this to work, you will need to enable popups for this web site in your Web browser).

One of the really useful features of myDevices is the ability to control the Raspberry Pi GPIO directly from the Web page. By clicking on the ‘GPIO’ link, you should see a Web page similar to that below:-

Cayenne Raspberry Pi GPIO

Cayenne Raspberry Pi GPIO

Clicking on any of the pin boxes labelled as either ‘IN’ or ‘OUT’ will toggle that GPIO pin between being an input or an output. Similarly, when a particular GPIO pin has been defined as an output, clicking on the corresponding box for that pin that is labelled as either ‘LOW’ or ‘HIGH’ will toggle that GPIO pin between having a low or high voltage, and thus switching the pin (and thus any device attached to it) off or on; as demonstrated in the following video:-