Tuesday 29 May 2012

Pi but not on TV

Raspberry Pi has an HDMI socket and a composite socket, both can be used to connect up to a TV, but what if your TV is being used by the rest of the family? Well if you connect R-Pi to Ethernet you can use another computer to take control of your R-Pi.
When you first start R-Pi running Debian it presents you with a login prompt and a terminal session. You can start a similar remote session using Secure Shell, ssh. You need to run the ssh server on R-Pi and then use a ssh client on the monitoring computer.
On the SD card the boot partition has a file called boot_enable_ssh.rc. If you rename the file to boot.rc when the R-Pi boots it will start the ssh server automatically. You now need to know what the IP address is of the R-Pi. By default R-Pi connects to a network by getting its IP address from DHCP. The Linux command nmap will show you devices within a range on my home network I use nmap -sP 192.168.0.0/24 which pings addresses within the range and reports devices it finds. This should help you find the address of your R-Pi. To connect to R-Pi from a Linux terminal use ssh pi@192.168.0.2 (substitute the address of your R-Pi) and you should see a prompt for the password for the user pi. You can now run any command just as normal. To connect from Windows (or Linux) you could use PuTTY as your ssh client, which does work well.
The next issue is to see the actual desktop of R-Pi. This would let you use the graphical interface remotely. The usual way is to use VNC. To run a VNC server on the R-Pi you need to install it, using the command sudo apt-get install tightvncserver. This will fetch the tightvncserver software from a repository and install it.
The command to start the VNC server is
vncserver :1 -geometry 1024x768 -depth 16 -pixelformat rgb565
The first time you run this you will be prompted to set access passwords. Once it is running you can now connect from a PC to see the GUI interface. The :1 above sets the port to use, the screen size, colour depth and pixel format are all set, you can change these to suit your needs and your monitor size. To access the screen you need to run a VNC client, I just use the Remote Desktop Viewer and use its VNC protocol. Supply the IP address and port (e.g. 192.168.0.2:1) and enter the password you chose above. You should see the R-Pi GUI screen without hogging the TV.

No comments:

Post a Comment

Thank you for taking the time to add a comment.

I have decided, regrettably, to review comments before they are published to ensure that offensive or inappropriate comments do not get shown.

Genuine comments are always welcome and will be published as quickly as possible.