Autostarting Raspberry Pi Using VNC Viewer

From ESE205 Wiki
Jump to navigation Jump to search

Autostarting Raspberry Pi Using VNC Viewer


The Raspberry Pi is an incredible tool to use for many different types of engineering projects. The Pi is a mini-computer; it can be programmed, function as a web browser, and store memory, among other things. However, in order to use the Pi, you must have access to a micro USB (power source), a monitor, an HDMI cord, and a keyboard (as well as a micro SD card that must always be in the Pi). In many engineering projects involving the Pi, it takes a considerable amount of time using the Pi across many different sessions. This leads to complications, as Pi users are restricted to working in environments where they have access to monitors, keyboards, and HDMI cords. VNC viewer is a helpful way to launch the Pi interface on a computer, but that setup also takes time.

The purpose of this tutorial is to save engineers time in their product development. Once this tutorial is completed, the Pi will be able to autostart using only its power source plugged into a computer, keyboard-free, monitor-free, and HDMI-free.

Using VNC Viewer

Configure Raspberry Pi

Refer to the following tutorial for instructions on how to configure the Pi:

Before you deploy this tutorial, make sure to check which version of Raspberry Pi you have. If you have a Raspberry Pi 3, step 4 of the tutorial does not apply, and to connect to wifi directly on the Pi. If you run into issues during the configuration, be sure you are using the most recent version of NOOBS or Raspbian on the official Raspberry Pi page.

Preliminary Downloads

Downloading VNC on the Pi

Use the command "vncserver" in terminal on the Pi to install the necessary VNC software.

Downloading VNC Viewer on Your Computer

Go to the URL , to create a VNC Viewer account and for the free download. Be sure to write down your username and password.

Finding Your Pi's IP Address'

To find your Pi's IP address, first open terminal. Once in terminal, type in the command "sudo ifconfig". Upon entering this command, you will receive lots of of information about your pi. To find the necessary IP address for autostart, look for the section of the output that reads "wlan0". Under this section, there IP address will be listed after it says "inet addr:". Write down this IP address to use later.

Terminal Display After ifconfig Command

Terminal Display after ifconfig.

Launch of VNC

Now, you should be able to launch VNC from your computer. Run the Raspberry Pi using the monitor, keyboard, HDMI, and MicroUSB. Now Launch the VNC Viewer, log into your VNC Viewer Account, and type in the Pi's IP address for the server you would like to access. An icon will appear with the corresponding IP address. Click on this icon, and a display of the Raspberry Pi server will appear on the screen, matching that displayed on the monitor.

VNC Viewer with Pi Icons

VNC Viewer with Pi Icons.

Coding Pi to Autostart

In this section, we code the Pi so that no HDMI, monitor, or keyboard is required during startup.

Pi Programming in Terminal

Find Where to Enter the Code

To build the program for autostart, we must first access the correct directory to enter the code. To do so enter the following terminal commands:

// Start of terminal commands //

cd ~

cd .config


cd autostart

nano tightvnc.desktop

// End of terminal commands //

You may run into problems here. The Raspberry Pi 3 has all of the directories already created with the most recent download of NOOBS (as well as Raspbian) loaded on the microSD card. However, it is possible that the autostart directory is not already available on the Pi. If you run into this error, restart the process with the following code:

// Start of terminal commands //

cd ~

cd .config

mkdir autostart


cd autostart

nano tightvnc.desktop

// End of terminal commands //

Enter the Code

Now that you are in the correct place, enter the following the code to set up the autostart ability. Now, where you are at in terminal, enter the following code:

// Start of terminal code //

[Desktop Entry]



Exec=vncserver :1


// End of terminal code //

To save the code you just entered, hit control-O. To exit terminal, hit control-X.


Now, you no longer need a monitor, keyboard, or HDMI cord to launch your Pi; you can simply plug in your Pi, open the VNC viewer on your computer, click on the icon with your Pi's corresponding IP address, and do your Pi work directly from your computer!

There are some limitations, however. Every so often, the IP address on the Pi can change if you move locations. If you do your project work in the same location, this problem is less apparent, however, over time, IP addresses still can change. If this occurs, repeat the "finding IP address" portion of the tutorial, and add the new IP address to your VNC viewer. Click on the new icon on VNC Viewer to launch the Raspberry Pi server from your computer from now on.

Hopefully now setting up to do any Pi work is less of a hassle!