electroSome

Using Raspberry Pi through VNC

vnc

vnc

Contents

Virtual Network Computing (VNC), is a graphical desktop sharing system used to remotely control a computer’s desktop from another computer. It uses Remote Frame Buffer Protocol (RFB). It transmits keyboard strokes and mouse movement from the controller to the remote host and relays back the graphical screen updates from the host, over a network like Ethernet.

Installing a VNC server like TightVNC on Raspberry Pi enables the user to remotely access the desktop of Pi and perform necessary operations. This is particularly useful when the Pi is setup such that it can’t be accessed physically to connect a monitor, keyboard and mouse.

Setup VNC server on RaspberryPi

$ sudo apt-get install tightvncserver
TightVNC install
$ tightvncserver
TightVNC run
$ vncserver :0 -geometry 1920x1080 -depth 24
TightVNC start

Note: The resolution given here is 1920×1080. If the fonts appear to be of wrong size add -dpi 96 to the end of the above command.

You can use one of the free VNC Client programs available over internet, here we are using Tight VNC Client.

sudo apt-get install xtightvncviewer

Accessing through VNC

TightVNC client
TightVNC client authentication
TightVNC client desktop

To Automate the above Process on Boot

It is particularly useful to start VNC server on boot for avoiding the hassle of running above script manually.

sudo bash
cd /etc/init.d
nano vncboot
TightVNC location
VNCUSER='pi'
eval cd ~$VNCUSER
case "$1" in
 start)
   su $VNCUSER -c '/usr/bin/tightvncserver :1'
   echo "Starting TightVNC server for $VNCUSER "
   ;;
 stop)
   pkill Xtightvnc
   echo "Tightvncserver stopped"
   ;;
 *)
   echo "Usage: /etc/init.d/tightvncserver {start|stop}"
   exit 1
   ;;
esac
exit 0

Note : You may change the user pi to any user of your choice.

TightVNC boot script
chmod 755 /etc/init.d/vncboot

Note: For some operations like GPIO commands from python shell, it is necessary to run the shell as root. For this replace the user ‘pi’ in the above code to ‘root’ and change the owner of the file as root using the following command,

sudo chown root:root /etc/init.d/vncboot
update-rc.d vncboot defaults
TightVNC boot permission

From now on VNC server is automatically started on each boot with display number :1.

Exit mobile version