Connect with us

How To

How to Connect Raspberry Pi to Laptop Using VPN Server?

Published

on

Many Raspberry Pi users don’t have any Monitors, for those people this article provides a simple method to use the laptop as a Raspberry Pi display If you don’t have the HD monitor. As we all know that the Raspberry Pi is known as the “Pocket-Size PC“, but for debugging and project purposes it is difficult to carry the additional display for it. And many people don’t have access to the HDMI display So that it will be pretty easy to connect Raspberry Pi to laptop display.

Connect Raspberry Pi to Laptop
Connect Raspberry Pi to Laptop

How Does It Work?

In order to connect the Raspberry Pi to your laptop display, you can simply use the ethernet cable. The Raspberry Pi’s desktop GUI (Graphical User Interface) which can be viewed through the laptop display using a 100Mbps ethernet connection between the two. There are various software programs available which can establish the connection between Raspberry Pi and laptop. We used the VNC server software to connect the Pi to our laptop.

Connect Raspberry Pi to Laptop
Connect Raspberry Pi to Laptop

Installing the VNC server on the Pi enables you to see the Raspberry Pi’s desktop remotely, using the mouse and keyboard, So that you can put your Pi anywhere in your home and still control it easily. And the internet can be shared from your laptop’s WiFi over the Ethernet. This allows you to access the internet on the Pi and connect it to your laptop display.

Setting Up the Raspberry Pi

Before heading to connect the Raspberry Pi to your laptop display, you need the SD card with the preinstalled OS or install Raspbian on the blank SD card. When you are not familiar with the Raspberry Pi commands, you can look for the tutorials on preparing the SD card for Raspberry Pi. You can even buy the SD cards with the Raspbian and NOOBS operating system preinstalled. After setting up the SD card, insert it into the Raspberry Pi. Then connect your micro USB cable to Raspberry Pi to power it. You can also connect your Raspberry Pi to the laptop display.

Sharing Internet Over Ethernet

This step explains how you can share your laptop internet with the Raspberry Pi through the Ethernet cable. In windows, you can share the internet with the multiple users over Ethernet, go to the Network and Sharing Center. Then click on the WiFi network:

Connect Raspberry Pi to Laptop
Connect Raspberry Pi to Laptop

Click on the properties, then go to the Sharing and click on “Allow other network users to connect“. Just make sure the network connection is changed to “Local Area Connection”:

Connect Raspberry Pi to Laptop
Connect Raspberry Pi to Laptop

Doing this will provide the dynamic IP to the ethernet port on the laptop and other connected devices on your laptop. Now check the IP assigned to your laptop, click on the new local area connection link created:

Connect Raspberry Pi to Laptop
Connect Raspberry Pi to Laptop
Connect Raspberry Pi to Laptop
Connect Raspberry Pi to Laptop

As given in the above image, the IP assigned to our laptop is 192.168.137.1. To check the IP assigned to the connected Ethernet device, you can do the following. Consider that the IP assigned to the laptop is 192.168.137.1 and the subnet mask is 255.255.255.0:

  • Open the command prompt
  • Ping the broadcast address of your IP. Eg: ping 192.168.137.255
  • Stop the ping after 5 seconds.
  • Check reply from the device: arp –a

Setting Up the VNC Server to connect Raspberry Pi to Laptop Display

If you have the HDMI display: Using the connected HDMI display on your Pi, You should install the VNC server on your Raspberry Pi Now Open the LX-Terminal and type the following commands to install VNC:

$ sudo apt-get update

$ sudo apt-get install tightvncserver

If you don’t have the HDMI display: If you don’t have the display even for the single time setup, then don’t need to worry.  install the Putty based on your Windows configuration and through the SSH, you can connect with your Raspberry Pi. As you get access to the Pi terminal, run the same commands as above to install the VNC

Starting VNC Server on Pi:

To start VNC, enter the following command in the SSH terminal:

$ vncserver :1

You will be insisted to enter and confirm the second password. This will be asked only once, during the first time setup. Enter the 8 digit password. Note that this is the password. This will be asked only once, during the first time setup. Enter the 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 the separate “read-only” password – say no (n).

The VNC server is now running on the Pi and you can now try to connect to it. First, we must switch to the laptop, from which you want to control the Pi. Then set up the VNC client to connect to the Pi.

Setting Up the Client Side (Laptop)

Download the VNC client and install it. When you first run the VNC viewer, you will see the following:

Connect Raspberry Pi to Laptop
Connect Raspberry Pi to Laptop

Enter IP address of your Raspberry Pi given dynamically by your laptop (you got it from the earlier step) and append with: 1 (denoting port number) and press connect. You will get the warning message, press ‘Continue‘:

Connect Raspberry Pi to Laptop
Connect Raspberry Pi to Laptop

Now enter the 8 digit password which was entered in VNC server installation on the Raspberry P:

Connect Raspberry Pi to Laptop
Connect Raspberry Pi to Laptop

Finally, the Raspberry Pi desktop will appear as the VNC window. You can access the GUI and do everything as if you were using the Pi’s keyboard, mouse, and monitor directly. As with SSH, because it is working over your network, your Pi can be located anywhere as long as it is connected to your network.

Connect Raspberry Pi to Laptop
Connect Raspberry Pi to Laptop

Running VNC Server During Startup in the Raspberry Pi GUI

Connecting to your Raspberry Pi remotely with the VNC is fine as long as the Raspberry Pi doesn’t reboot. If it does restarts then you have to connect with the 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 the folder called “autostart” in it. Also, create the file called “tightvnc.desktop” in that folder. You can use any familiar text editor to create the files. Here we used gnome-text-editor for this:

$ mkdir autostart
$ cd autostart
$ gnome tightvnc.desktop

Edit the contents of that file with the following text and save the file:

[Desktop Entry]
Type=Application
Name=TightVNC
Exec=vncserver :1
StartupNotify=false

Now you can reboot your Pi, VNC Server will start automatically and will seamlessly connect your Raspberry Pi to the laptop display. Whenever you need to do something with your Pi, just connect it to the laptop with an ethernet cable and power it. Then open VNCViewer, mention the IP address of your PI, and you can use the laptop’s display as a Raspberry Pi’s monitor.

Read also: x86 Raspberry Pi

Thank you for reading this post.

Facebook

Trending

Would you like to receive notifications on latest updates? No Yes