Connect Raspberry Pi to Your Laptop Screen and Keyboard

by chauhannaman98 in Circuits > Raspberry Pi

18037 Views, 13 Favorites, 0 Comments

Connect Raspberry Pi to Your Laptop Screen and Keyboard

mP8ko3C8TXPBvU7iwHvfCn.png

Learn how you can use Laptop's screen, touchpad and keyboard as peripherals for the Raspberry Pi using the VNC Server.

Supplies

  1. Raspberry Pi
  2. Ethernet Cable
  3. Power Adapter(EU) / US Standard
  4. SD Card
  5. Laptop

Story

image-asset_ISc5s4dKae.png
This project has been sponsored by PCBWay. They are the most cost-effective and quality-oriented PCB manufacturers. You can order your prototype PCBs in a small quantity, as small as 5 pcs of PCB. In addition to the standard PCBs, we could also support advanced PCBs, FPC/rigid-flex PCBs and other related services. To get your instant quote for different types of PCBs, click here. They sponsor me so that I can keep making interesting projects for you.

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. So 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 100 Mbps 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. 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 click here and know more about this. This will show how to install the OS for the Raspberry Pi. You can also buy SD cards with the Raspbian and NOOBs operating systems preinstalled. I would suggest you install the latest full Raspbian OS image from the official Raspberry Pi website as it is having VNC Server in the OS package.

After setting up your SD Card, insert it into the Raspberry Pi. Next, connect your power adapter 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.

Note: You need a screen and a mouse after booting a new OS into Pi for the first time as by default, the SSH and VNC are disabled in Pi. Without SSH disabled, we cannot enable the PuTTY Configuration.

Sharing Internet Over Ethernet

network_and_sharing_center_Nm1CKmKDPS.jpg
sharing_1_iVmO3ScUTf.jpg
sharing_2_t7d9hg2tiw_Eimaf8XcCn.jpg
sharing_3_1bu28voidz_ika4fbvE7G.jpg

This step explains how you can share your laptop internet with the Raspberry Pi via Ethernet cable. In Windows: To share the 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 the connection of the Raspberry Pi. In my case, it is Ethernet.

Finding IP for PuTTY Configuration

By default, the laptop will give a dynamic IP to the Raspberry Pi. Thus, we have to find out the IP address of Pi now.

As shown above, the IP assigned to my Pi is 192.168.137.144. To check the IP assigned to the connected Ethernet device, do the following. Considering that the IP assigned to your Pi is 192.168.137.144 and the subnet mask is 255.255.255.0.

  1. Open the command prompt.
  2. Ping at raspberrypi.mshome.net.
  3. Stop the ping after 5 seconds.

Here, it is 192.168.137.154. Note this somewhere.

PuTTY Configuration and VNC on Raspberry Pi

putty_config_2_xvhm9q8itr_NdQt73zFDf.jpg
putty_config_DEAJJ2ynLZ.jpg

  1. In the Host Name, enter the IP Address we noted from the command line.
  2. Ensure that the Connection Type is SSH.
  3. Hit Enter or click on Open to proceed.
  4. Now, a new window will open. It looks like a normal terminal window of the computer but it is Raspberry Pi's terminal window accessible on your laptop.
  5. It is display- login as:
  6. Enter pi as the username.
  7. Enter the password you set for the Raspberry Pi. The default password is raspberry
  8. If the password is correct, the Pi will load and you will access the terminal window of the Pi.
  9. Now, you need to start the VNC Server. Enter after the $ sign - sudo vncserver :1
  10. This is to initialize the VNC Server on the Raspberry Pi.

VNC Server and VNC Viewer on Laptop

vnc_1_WU1kiwBXLT.jpg
vnc_2_lVT6q6LeyP.jpg
pi_desktop_1_zvqMUPxk7F.jpg
pi_desktop_2_rrtytz6hvm_mGS6HN7eCy.jpg

Now, Raspberry is ready to connect using VNC. We just need to install the VNC server on the laptop.

  1. Download VNC Client and install it. Now, download the VNC Viewer and install it on the laptop.
  2. Open the VNC Server and the VNC Viewer now.
  3. In the VNC Viewer, click on File > New Connection.
  4. Enter IP Address and in Options > Picture Quality, select High.
  5. Click OK. Now, double click on the IP Address.
  6. Enter pi in Username and your Pi's password (default is raspberry).
  7. Click on Remember Password so that you don't have to enter this next time.
  8. Click on OK.

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, then 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 the “.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. Good job! Whenever you want to do something with your Pi, just connect it with an Ethernet cable to your laptop and power it. Then open the VNC Viewer, mention the IP address of your Pi, and you can use your laptop’s display as the Raspberry Pi’s monitor.

You can now easily build your Raspberry Pi projects without any need to buy an additional display. There are numerous projects based on RasPi which you can build and assemble on PCB boards for connecting extra peripherals like sensors, power supply, extensions, relays, actuators, etc. You can design your PCB and submit your Gerber files on PCBWay. They give you instant quotes here and provides a wide variety of specifications and additional services.