Introduction: Connecting Your Raspberry Pi to a Linux Laptop
I have been involved with the Raspberry Pi (RasPi) now for over four months and found myself with five computers in my work area and needed to reduce their footprints and monitors on my workbench/desk. Upon reading an article about connecting the RasPi to a Laptop , I began my project. I use [#] as reference found in Step 5. Figure 1 is a photo of my system with a RasPi monitoring TV.
My project began with the RasPi. It already has the SD Card with the Operating System (OS) Raspbian installed. My Laptop has the OS Ubuntu installed. There is no discussion about the installation of either OS; details can be found in [2, 3]. This project is described in five steps:
Step 1 - Initial System Set-Up
Step 2 - Install VNC Server
Step 3 - IP Addresses
Step 4 - Install VNC Viewer
Step 5 - Final System Set-Up
Step 1: Initial System Set-up
- Laptop - Toshiba Qosmio with Ubuntu 14.04 (a Linux OS)
- Ethernet cable
- Micro USB Cable
Wireless keyboard/mouse dongle subsystem*
- Wireless internet dongle
- Raspberry Pi: Model B+ (RasPi)
- SD Card with Raspbian (a Linux OS)
*The wireless subsystem could be replaced by USB keyboard and USB mouse.
Additional RaspPi Software:
- VNC Server
Additional Laptop Software:
- VNC Viewer
Instruction Level: Intermediate
- Should have some knowledge of Linux terminal commands
- Should have SD card with Raspbian installed or know how to program SD card.
You can physically connect the RasPi to the Laptop using an Ethernet cable. The desktop GUI (Graphical User Interface) of the RasPi can be viewed through the Laptop display using a 100Mbps Ethernet connection between the two. There are many softwares available that could establish connection between the RasPi and the Laptop, but the best - in my opinion, is the VNC Server software installed on the RasPi and the VNC Viewer software installed on the Laptop. The VNC Server on the RasPi allows the RasPi's desktop to appear remotely on the laptop. You can put the pi anywhere, and still control it. Also, internet can be shared between the Laptop’s and RasPi over Ethernet. This also lets you access internet on the RasPi and connect RasPi to Laptop display.
Figure 2 is a block diagram of the initial Laptop/RasPi system. The dotted lines indicate wireless connections to the Internet and the wireless keyboard/mouse to the RasPi. The final system will no longer require the TV or the wireless keyboard/mouse.
Examine Figure 3 as to the RasPi cable and dongle connections. Figure 4 illustrates the SD Card installation to the RasPi. Connect up all the cabling and install the dongles. Do not connect micro-USB (the RasPi power connector) until the TV and Laptop are powered up. After powering up the Laptop, connect the power connector to the RasPi. The TV should show the booting process of the RasPi and then (give it some time) the RasPi GUI should appear (Figure 5).
Step 2: Install VNC Server on RasPi
Using the connected HDMI display on your RasPi, you should install VNC server in the RasPi.. Open the Terminal and type the following commands to install VNC:
$ sudo apt-get update
$ sudo apt-get install tightvncserver
It is assumed that the RasPi has been connected to the internet and please note that a $ is placed in front as an indication of a Linux command.
Figure 6 illustrates the results of update and tightvnc installation.
Starting VNC Server on RasPi
For starting VNC, enter the following command:
$ vncserver :1
Upon prompt, enter and confirm a password. This will be asked only once, during first time setup. Enter an 8 digit password. Note that this is the password you will need to use connecting to the RasPi remotely. You will also be asked if you want to create a separate “read-only” password – respond with no (n).
The VNC Server is now running on the RasPi and connection to it can be be made, but now the Laptop must be setup with the VNC Client to connect to the RasPi.
VNC Server Runs upon Boot-Up
The following information was taken from .
Adding Tightvnc to systemd startup
To have tightvncserver startup automatically we need to create a new startup file. This needs to be stored in the /etc/systemd/system/ directory and end with the suffix ".service". I called this tightvncserver.service.
$ sudo nano /etc/systemd/system/tightvncserver.service
The following is to be entered... without the line numbers:
- Description=TightVNC remote desktop server
- ExecStart=/usr/bin/tightvncserver :1
You may need to change the user name on line 8. It is currently set to pi which is the default username on the RasPi Raspbian image. Set this to whatever username you want to login to tightVNC as. Do not put root as the user.
Change the file so it is owned by root
$ sudo chown root:root /etc/systemd/system/tightvncserver.service
Make the file executable by running
$ sudo chmod 755 /etc/systemd/system/tightvncserver.service
It's a good idea to test the script at this point rather than waiting until after a reboot. This is done using:
$ sudo systemctl start tightvncserver.service
Don't worry if you get the following error message, which is because you've already started tightvnc
A VNC server is already running as :1
Enable Startup at Boot
$ sudo systemctl enable tightvncserver.service
As you boot up, tightvnc will now start. I'd recommend you reboot at this point to make sure it's working but youc an just stop and start the service using the systemctl command instead.
Note that this is designed for running only one instance of tightvnc on the computer. If you want to be able to start and stop specific instances of tightvnc then you will need to tweak the startup script appropriately.
Step 3: IP Addresses
This step checks that the Laptop and the RasPi can communicate.
Laptop IP Address
With the Laptop terminal enter:
$ ifconfig eth0
It should return the Laptop IP address something as
inet addr: 192.168.3.100.
RasPI IP Address
Now, with the RasPi terminal enter:
$ ifconfig eth0
It should return the RasPi IP address something as
inet addr: 192.168.3.200
If not, change it match the Laptop IP with the last three digits different than the Laptop IP.
While in the Raspi terminal enter
$ ping 192.168.3.100
You should get a series of returns indicating packets of bytes from the Laptop.
Go to the Laptop terminal enter:
$ ping 192.168.3.200
You should get a series of returns indicating packets of bytes from the RasPi (Ctrl^C to exit).
Step 4: Install VNC Viewer on Laptop (Client Side)
Download VNC client from  and install it. At first run of VNC Viewer, Figure 7 will appear, but you'll have to put in your RasPi IP address in the space for VNC Server:. Click connect and enter the 8-digit password that you used to create the VNC Server. Append password with :1. This denotes port number, then press Connect. Figure 8... don't forget the user name which may be pi. Click OK. You will get a warning message, press ‘Continue’:
Finally, the RasPi desktop GUI itself should appear as a VNC window as in Figure 5. You will be able to access the GUI and do everything, as if you were using the RasPi’s keyboard, mouse and monitor directly. As with SSH, since this is working over your network, your RasPi could be situated anywhere as long as it is connected to your network.
Step 5: Final System Set-up
Since the RasPi can now be viewed and controlled with the Laptop, there no need for the TV, HDMI cable, and the wireless keyboard/mouse or dongle.
We have a be nice policy.
Please be positive and constructive.