Getting VNC working on Raspberry Pi

Sep 14, 2014 | | Say something

VNC is a program that allows one computer to remotely view and control another. There are many versions of VNC, it will need to be installed on the Raspberry Pi and also any other computer that it is desired to access the Rpi from. It does not have to be the same version on both machines.

I followed the instructions given here

http://myraspberrypiexperience.blogspot.co.uk/p/setting-up-vnc.html

It worked fine, but requires manually starting on the Rpi each time it is booted. The author provides other instructions to make the start-up automatic

http://myraspberrypiexperience.blogspot.co.uk/2012/08/start-vnc-automatically.html

Below is a combination of both so that you can follow the steps as one.

If you do not have a version of vnc on the computer you intend to access the Rpi from then you need to get one and install it. The recommended version is UltraVNC, it is available from http://www.uvnc.com/downloads/ultravnc.html if you need instructions to install this then refer to the original article or the website or elsewhere.

The article also refers to setting up SSH on the Rpi and using PuTTY on the host, these are not essential and I already had these set up on my Rpi.

The article suggests you might want to configure your Rpi with a static IP address. I would say that if you can in your router set up a fixed IP address for the Rpi. The difference is with a static IP address set on the Rpi, the router doesn’t know about it and could allocate the same IP address to another device on the network, this will cause a conflict and things not to work. Whereas a fixed IP address is set within the router, so it knows about it and won’t allocate that IP address to any other device except your Rpi. To configure this you will need to search elsewhere for detail on your specific router.

You will need to know the IP address of your Rpi and there are a few ways to get this, refer to the original article or on the Internet if you are unsure of how to do this.

That’s the preliminaries out of the way, so now download the vnc server.

sudo apt-get install tightvncserver

Once installed, the vnc server will need to be started, this is sufficnet if you want to do it manually and not have it automatically start at boot up.

vncserver :1 -geometry 1280×800 -depth 16 -pixelformat rgb565

Note that on first run, you will be prompted to enter a password for external connection and one for view-only.

The part of the command –geometry 1280×800 sets the size on the remote screen, you might want to alter these values to suit your monitor or screen.

Having run the vnc server and set passwords, it is time to make the vnc server fire up when the Rpi boots, to do this you will need to create a file.

sudo nano /etc/init.d/tightvncserver

The file contents should be as follows

# First configure the user you want to run this under – this will generally be pi, unless you’ve created your own users

export USER=’pi’

eval cd ~$USER

# Check the state of the command – this’ll either be start or stop

case “$1″ in

start)

# if it’s start, then start vncserver using the details below

su $USER -c ‘/usr/bin/vncserver :1 -geometry 1280×800 -depth 16 -pixelformat rgb565′

echo “Starting vncserver for $USER ”

;;

stop)

# if it’s stop, then just kill the process

pkill Xtightvnc

echo “vncserver stopped”

;;

*)

echo “Usage: /etc/init.d/vncserver {start|stop}”

exit 1

;;

esac

exit 0

# remember if you alter this file then do sudo chmod 755 /etc/init.d/tightvncserver

 

That completes the file, save and exit.

Once that’s done make sure the file has the right propertied by typing the following:

sudo chmod 755 /etc/init.d/tightvncserver

NOTE: Important to do this step every time you modify this file, else you might find the server does not start on booting up.

And now just add your file to the list of startup actions by typing the following:

sudo update-rc.d tightvncserver defaults

Reboot and check that remote logging via VNC is possible

Posted in: Raspberry Pi

Leave a Reply

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

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>