Setting up VNC on the raspberry pi

The Raman spectrometer’s CCD is driven and read by a nucleo F401re, which is (or rather, it will be) connected to a raspberry pi B+.¹ The rpi can then be accessed over VNC (or directly if you prefer).

The following steps may be found at raspberrypi.org, I’m putting it here only for my own sake.

The latest Raspbian Wheezy² image was downloaded and dd’ed onto a microSD card. The standard password was changed to something much more cool. The wireless network was configured after which the rpi was accessed solely through ssh:

ssh pi@192.168.1.250

A VNC server was installed and configured on the rpi:

sudo apt-get install tightvncserver
tightvncserver

A VNC client was installed on my laptop:

sudo apt-get install xtightvncviewer

The file vncboot was created in /etc/init.d/ containing

### BEGIN INIT INFO
# Provides: vncboot
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start VNC Server at boot time
# Description: Start VNC Server at boot time.
### END INIT INFO

#! /bin/sh
# /etc/init.d/vncboot

USER=pi
HOME=/home/pi

export USER HOME

case "$1" in
 start)
  echo "Starting VNC Server"
  #Insert your favoured settings for a VNC session
  su - pi -c "/usr/bin/vncserver :1 -geometry 800x600 -depth 16 -pixelformat rgb565"
  ;;

 stop)
  echo "Stopping VNC Server"
  /usr/bin/vncserver -kill :1
  ;;

 *)
  echo "Usage: /etc/init.d/vncboot {start|stop}"
  exit 1
  ;;
esac

exit 0

The file was rendered executable and make sure it’s run on boot:

chmod 755 vncboot
update-rc.d vncboot defaults

And remote graphical access is now available:

xtightvncviewer 192.168.1.250:1

¹ Please don’t remind me about the rpi 2, it came out a week after I bought the rpi B+ for this project.
² Debian has switched to systemd with Jessie, and so these steps no longer work.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s