Wednesday, 13 January 2016

#5 Booting Up Raspberry Pi - The Easy Way [Part 2].

Raspbian OS [using VNC server]

If you have directly landed on this page, I recommend you to
read the previous post. click here for my previous post.

This is 4th post on Raspberry Pi tutorial.
If you want the list of posts click here. 
From the previous tutorials, we know what is raspberry pi. We know it's specifications and we had seen two methods to set up the raspberry pi. We then installed the OS and then decided to go with the easy method of setup. In the last tutorial we connected the Raspberry pi to the computer through LAN wire and putty. We then logged in to the raspberry pi. 

So in this tutorial let us see how to get that desktop GUI, so that it becomes easy for us to deal with RPi and do stuffs like programming. [Terminal is something I don't like to deal with. It is powerful but not good to interact with].

I hope you have downloaded the VNC Viewer for windows if not it's here.

  • So picking up from where we left, we have successfully logged in to the raspberry pi. [from the previous post] Now first thing that we have to do is configure some things on RPi. Type the command below and it will take you to the configuration menu.
sudo raspi-config
  • Now you need to select the 1.Expand Filesystem option and hit Enter button. It will process and then it will show a dialog box click OK. After this the configuration menu will appear again. You can change the password if you want :)  [use UP and DOWN arrow keys to scroll]. Next thing is hit Finish [use LEFT and RIGHT arrow keys to access select and finish]. It will ask if you want to reboot hit yes. 
  • Now your connection will be lost close putty. let the Pi reboot. what we did was expanded the filesystem so that it will access the whole SD card memory and not just the chunk of it. This will give you a lot of memory for applications or storing other files.
  • Once the green light stops blinking it means the RPi is ready. Open putty, enter the IP and log in to RPi again.
  • Now lets update the RPi OS before installing any other packages [Internet required obviously]. Type the following commands :- 
sudo apt-get update
  • Once this is done then type the following command to update the software packages 
sudo apt-get upgrade
  • Once this is complete type the following command to install the VNC server on the RPi
sudo apt-get install tightvncserver
Click to enlarge
  • It will ask if you want to install the package ? Type Y and proceed. Once this is installed now let us set up the VNC Server
  • Type 'vncserver :1' and hit enter it will now create a server named 1. It will ask you to set the password. After setting up the password it will ask if you want view-only password ? Y will always show your password and N will keep it hidden. Choose whatever you want, I prefer 'N'.
click to enlarge
  • WHATEVER WE DID ABOVE WAS A ONE TIME PROCESS. so we have the RPi OS updated and VNC server package installed and set up. so lets use it.
  • Now close down this putty session and open new putty again. Enter the IP address and on the left hand side go to SSH and click tunnels.
  • Here type the number '5901' under source port. [1 because we created a server named 1, it would have been 5902 if we would have created vncserver :2].
  • In destination type your IP address then a colon and the source port eg:- 192.168.0.103:5901 and click on add. you will see something appearing under forwarded ports. That's it click on open.
 
Click to enlarge
  • Log in using 'pi' and password as 'raspberry'. This time we opened up the port through tunneling.
  • Open up the VNC Viewer and type localhost:5901 and hit enter type the password that you set for the vncserver and you will see a desktop GUI to deal with :)


  • Congratulations you have successfully set up the RPi and you are ready to use the desktop for programming and other purposes. Explore the desktop browse the net etc. Have Fun & Enjoy :)
After all this when I want to log in again what is to be done ? It is simple
  1. You will have to connect the RPi and give it power, check its IP address.
  2. Open putty, type the IP and log in.
  3. Type vncserver :1 and close putty. 
  4. Open putty again type the IP address > Go to the SSH > tunnels > then type the source port 5901 > click on destination > type 'IP address:5901' and click add. After this click open.
  5. Open VNC viewer on desktop type localhost:5901 and enter the password.
  6. That's it you have the Raspberry Pi desktop in front of you !!
Have Fun :) 

Visit the next post on 'How to do File Transfers between Raspberry Pi & PC ?'.
click here.

Like My Facebook Page :- https://www.facebook.com/VirajShelkeOfficial
Doubts and suggestions are welcomed in the form of comments.
Thank you for reading.
Follow my blog & stay tuned :)