To access a desktop on your Raspberry Pi we will be using Dataplicity Porthole as well as the TightVNC client for Windows.
For this tutorial we will assume that your Raspberry Pi doesn't have a desktop environment installed. We will install XFCE desktop environment, to have the actual desktop accessible on the Pi. Following that we will install tightvncserver to be able to access that desktop.
sudo apt install -y xfce4 xfce4-goodies tightvncserver
The next thing we'll have to do is to set up an access password for VNC clients. This is done on the first run of your VNC server. Simply run the command below:
You will be asked to provide two passwords. One is an access password and the other is a view-only password. The access password lets you connect to the desktop and interact with it using keyboard and mouse whereas the view-only password will only let a user observe your desktop. The view only password is optional so you can skip setting it up when asked by pressing the enter key on your keyboard.
Now that the password is set up we will configure a startup file for VNC. Firstly, we'll have to shut down our currently running VNC server.
vncserver -kill :1
Then we'll create a backup of current startup file, in case we'd like to revert back to it.
mv ~/.vnc/xstartup ~/.vnc/xstartup.bak
Finally we'll create a new startup file.
printf '#!/bin/bash\nxrdb $HOME/.Xresources\nstartxfce4 &\n' > ~/.vnc/xstartup sudo chmod +x ~/.vnc/xstartup
This will create the following file:
#!/bin/bash xrdb $HOME/.Xresources startxfce4 &
The first line
xrdb $HOME/.Xresources tells the VNC's GUI framework to read the server user's Xresource file.
The second line starts the Xfce in background.
Re-start the VNC server:
Now we're ready to access our Raspberry Pi desktop from our PC.
When you launch porthole you will see a list of forwarded devices. We currently haven't added anything, so the list is empty.
To add a new device click on
Add new button in the centre or at the top menu.
In the next window you will see three steps.
- Assign local port - the port on your PC that you will access to see the data from your Raspberry Pi.
- Select device to be forwarded - choose the Raspberry Pi that you want to connect to from your PC.
- Add remote port - choose the port of your Raspberry Pi that your PC will access.
When all the steps have been completed click on
Assign. Your list of forwarded devices will then be updated.
Launch TightVNC Viewer and it will bring you straight to the login window. Fill it out with the following details:
- Remote Host: localhost:10111.
When done click on
Connect. This will bring you to the authentication window.
This is where you provide your access password that you've set up in the first section of this article. Following that you will see the desktop of your Raspberry Pi.
Please keep in mind that there's a lot of data being transferred in between your Raspberry Pi and your PC in order to provide live desktop experience so the quality and response time might not be exactly as on a local desktop.
Updated 8 months ago