Last month I ordered a Raspberry Pi for learning purpose. I heard a lot of about this mini computer and waited until its 2nd generation comes to market to get one. Depending on purposes, there are a lot of kits for Raspberry Pi in the market (from starter to professional). I myself don’t know what I can do with this minicomputer, therefore, I just buy at least hardware first (listed in the next section). Just enough so that Raspberry Pi runs and I can remote access it. So my first project is pretty simple: go shopping and make remote access to Raspberry Pi with VNC (Virtual Network Computing). In this post, I will write down the steps I’ve done to finish this mini project.
1. Hardware
– As I mentioned above, the hardware list below is just enough to make Raspberry Pi work. It’s really uncomfortable if you try to make a bigger project with this set of hardware. You should buy more components to make things more comfortable.
– First of all, we need a Raspberry Pi. B+ is the newest model and I also recommend it. It’s more powerful than model A or B. Even that B+ is the most powerful model, it is still ‘slower’ than our desktop. So let’s invest some dollars more to avoid the stress of performance later. Raspberry Pi Model B+ (B PLUS) 512MB Computer Board
– Second, we need a microSD card for hard disk. Raspberry Pi needs also an operating system which we have to install on this microSD card. I choose SanDisk Extreme 32GB UHS-I/U3 Micro SDHC Memory Card Up To 60MB/s Read With Adapter-SDSDQXN-032G-G46A [Newest Version]. You can use another card but you should get at least 16Gb if you want to set up some bigger projects later.
– Next, we need a case for protecting our mini computer from dust and water. You can make yourself a case from Lego stone or buy one like this Premium Clear Case for Raspberry Pi B+ (B Plus) . Please note that the case must be also for B+ model. If you choose the wrong case, they won’t be fit to each other.
– One power supply over Micro USB port. I have a smartphone with Micro USB port, so I reuse this power supply for Raspberry Pi. That means when I want to charge my phone, I have to unplug the Raspberry Pi and vice versa. It’s a little uncomfortable but it works.
– A LAN network cable. I connect Raspberry Pi directly to my router to give Raspberry Pi an Internet connection.
– After assembling, my Raspberry Pi looks like following
2. Software
2.1 Operating system
– Raspberry Pi is a mini computer, it requires also an operating system. Go to Raspberry Pi homepage http://www.raspberrypi.org/downloads/ and get a distro for your purpose. I select Raspbian as my choice. If you want an XBMC Media Centre, you can select between OPENELEC or RASPBMC
– Go to http://sourceforge.net/projects/win32diskimager/ and download Win32DiskImager. Install and run it. Select the Raspbian image and drive of SD card. Then click on Write.
– It takes a while for writing the image to the microSD card. When writing finishes, the operating system is also successfully installed.
2.2 SSH
– Plugin power cable and network cable. Raspberry Pi will automatically start in seconds. Go to the admin control panel of your router and get the IP address of Raspberry Pi
– Go to http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html . Download putty. Start putty and build a SSH connection to Raspberry Pi
– The default username and password are pi and raspberry
2.2 Install VNC
– SSH connection allows us to execute commands on Raspberry Pi. But I’m not the fan of typing command, I really don’t find it’s ‘cool’ when typing command. So in this section, I’ll try to make remote access to UI of Raspbian and control Raspberry Pi over UI. So I need to install TightVNC package
sudo apt-get install tightvncserver
– Run TightVNC Server which will prompt you to enter a password and an optional view-only password. Remember this password because you’ll need it later
tightvncserver
– Start a VNC server from the terminal. For example we start a session on VNC display zero (:0) with full HD resolution:
vncserver :0 -geometry 1920x1080 -depth 24
– To check if VNC server works, go to http://www.tightvnc.com/download.php . Download TightVNC and install it. Start TightVNC Viewer, then connect to Raspberry Pi
– And here is how the Raspbian look like
2.3 Start VNC on boot
– If you would like to start VNC at booting, you can follow these steps
– Log into a terminal on the Raspberry Pi as root
sudo su
– Navigate to the directory /etc/init.d/
cd /etc/init.d/
– Create a new file here containing the following script
### 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 export USER='pi' eval cd ~$USER case "$1" in start) echo "Starting VNC Server" #Insert your favoured settings for a VNC session su $USER -c '/usr/bin/vncserver :0 -geometry 1280x800 -depth 16 -pixelformat rgb565' ;; stop) echo "Stopping VNC Server" su $USER -c '/usr/bin/vncserver -kill :0' ;; *) echo "Usage: /etc/init.d/vncboot {start|stop}" exit 1 ;; esac exit 0
– Save this file as vncboot
– Make this file executable
chmod 755 vncboot
– Enable dependency-based boot sequencing
update-rc.d /etc/init.d/vncboot defaults
– If enabling dependency based boot sequencing was successful, you will see this
update-rc.d: using dependency based boot sequencing
– But if you see this
update-rc.d: error: unable to read /etc/init.d//etc/init.d/vncboot
then try the following command
update-rc.d vncboot defaults
Reboot your Raspberry Pi and you should find a VNC server already started.
3. Conclusion
The first project is pretty successful, I can make a remote access on it now. Over VNC, Raspberry Pi is pretty slow because of hardware limitation but we can’t require good performance from it with such hardware specification. I keep on learning on this platform and try to make some interesting projects with this mini computer. I hope I can build a small sweet robot with Raspberry Pi.
4. Update
4.1 04.02.2015
If you want to format SDCard then use SD Formatter from following link https://www.sdcard.org/downloads/formatter_4/ to wipe Raspberry Pi installation.
Can VNC work with OpenELEC?
Officially, no. But you can try with OpenELEC Addon http://openelec.tv/forum/search?q=vnc