A simple method to use your laptop as a Raspberry Pi display if you don't have an HD monitor.
I came up with this tutorial one day when my friend Suvigya and I were struggling to work on the Raspberry Pi, because we did not have any HD displays. Hence, I came up with this tutorial so others in the same situation would be able to use their laptop display as a monitor for their Raspberry Pi.
As we know, Raspberry Pi is known as the “Pocket-Size PC”, but for debugging and project purposes it's cumbersome to carry an additional display for it. Also, many of us don't have access to an HDMI display, so, we figured out a way to easily connect a Raspberry Pi to a laptop display. Sit back and enjoy this simple tutorial!
How Does It Work?
To connect a Raspberry Pi to a laptop display, you can simply use an ethernet cable. The Raspberry Pi’s desktop GUI (Graphical User Interface) can be viewed through the laptop display using a 100Mbps ethernet connection between the two. There are many software programs available that can establish a connection between a Raspberry Pi and your laptop. We used VNC server software to Connect the Pi to our laptop.
Installing the VNC server on your Pi allows you to see the Raspberry Pi’s desktop remotely, using the mouse and keyboard as if you were sitting right in front of your Pi. It also means that you can put your Pi anywhere else in your home and still control it. Also, the internet can be shared from your laptop’s WiFi over Ethernet. This also lets you access the internet on the Pi and connect it to your laptop display.
Setting Up Your Raspberry Pi
Before moving to connect your Raspberry Pi to your laptop display, you need an SD card with the OS preinstalled, or install Raspbian on a blank SD card. If you’re not familiar with Raspberry Pi commands, check out this tutorial for Basic Linux Commands. You will find lots of blogs and tutorials on preparing an SD card for the Raspberry Pi. If you are a beginner, you can simply download this free beginner’s guide eBook. This will show how to install the OS for the Raspberry Pi. You can also buy SD cards with the Raspian and NOOBs operating systems preinstalled.
After setting up your SD Card, insert it into the Raspberry Pi. Next, connect your micro USB cable to the Raspberry Pi to power it. Also, connect your Raspberry Pi to the laptop via an ethernet cable and connect a keyboard and mouse to it. Now, connect the HDMI display (the HDMI is only required to run the Pi for the first time) and power on your Pi. Follow the next steps to connect your Raspberry Pi to a laptop display.
Sharing Internet Over Ethernet
This step explains how you can share your laptop internet with the Raspberry Pi via Ethernet cable.
In Windows: To share internet with multiple users over Ethernet, go to Network and Sharing Center. Then click on the WiFi network:
Click on Properties (shown below), then go to Sharing and click on "Allow other network users to connect". Make sure that the networking connection is changed to "Local Area Connection":
Note: Doing this will provide a dynamic IP to the ethernet port on your laptop and other devices connected to your laptop. Now, to check the IP assigned to your laptop, click on the new local area connection link created:
As shown above, the IP assigned to my laptop is 192.168.137.1. To check the IP assigned to the connected ethernet device, do the following. Considering that the IP assigned to your Laptop is 192.168.137.1 and subnet mask is 255.255.255.0 :
- Open command prompt
- Ping the broadcast address of your IP. (Type) Eg: ping 192.168.137.255
- Stop the ping after 5 seconds.
- Check the reply from device: arp –a
Setting Up the VNC Server to Connect Your Raspberry Pi to a Laptop Display
If you have an HDMI display: Using the connected HDMI display on your Pi, you should install VNC server on your Raspberry Pi. Open the LX-Terminal and type the following commands to install VNC:
$ sudo apt-get update
$ sudo apt-get install tightvncserver
$ sudo apt-get install tightvncserver
If you don’t have an HDMI display: If you do not have a display even for one-time setup, then no need to worry. Install Putty as per your Windows configuration and via SSH you can connect with your Raspberry Pi. As you get access to your Pi terminal, run the same commands as above to install VNC.
Starting VNC Server on Pi:
To start VNC, enter the following command in the SSH terminal:
$ vncserver :1
You will be prompted to 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 to connect to your Raspberry Pi remotely. You will also be asked if you want to create a separate “read-only” password – say no (n).
Yippeee!….The VNC server is now running on your Pi and we can now attempt to connect to it. First, we must switch to the laptop, from which we want to control the Pi. Then set up a VNC client to connect to the Pi.
Setting Up the Client Side (Laptop)
Download VNC client and install it. When you first run VNC viewer, you will see following:
Enter the IP address of your Raspberry Pi given dynamically by your laptop (you got the address from the earlier step) and append with :1 (denoting port number) and press connect. You will get a warning message, press ‘Continue’:
Enter the 8 digit password which was entered in the VNC server installation on your Raspberry Pi:
Finally, the Raspberry Pi desktop should appear as a VNC window. You will be able to access the GUI and do everything as if you were using the Pi’s keyboard, mouse, and monitor directly. As with SSH, since this is working over your network, your Pi can be situated anywhere as long as it is connected to your network.
Running VNC Server During Startup in the Raspberry Pi GUI
Connecting to your Raspberry Pi remotely with VNC is fine as long as your Pi does not reboot. If it does, you either have to connect with SSH and restart the VNC Server or arrange for the VNC Server to run automatically after the Raspberry Pi reboots. To ensure that the VNC starts automatically each time when booting up, run the following commands in the terminal:
Open “.config” folder from the Pi's: user folder (it is a hidden folder).
$ cd /home/pi $ cd .config
Create a folder called “autostart” in it. Also, create a file called “tightvnc.desktop” in that folder. You can use any known text editor to create the files. I used gnome-text-editor for this:
$ mkdir autostart $ cd autostart $ gnome tightvnc.desktop
Edit the contents of the file with the following text and save the file:
[Desktop Entry] Type=Application Name=TightVNC Exec=vncserver :1 StartupNotify=false
Now next time you reboot your Pi, vncserver will start automatically and will seamlessly connect your Raspberry Pi to a laptop display.
Whenever you want to do something with your Pi, just connect it to your laptop with an ethernet cable and power it. Then open VNCViewer, mention the IP address of your Pi, and you can use your laptop's display as the Raspberry Pi's monitor.