I get asked a lot about controlling my headless Raspberry Pi setup and while there are many ways of doing it lately have been using VNC and have started recommending that to everyone. Some command line purists will say that VNC is overkill and I do agree with that as 95% of things that I do on my Raspberry Pi are command line based and could just as easily be accomplished via SSH but I like having the option of using the GUI so for now at least VNC is the way I am going.
Setting up VNC on the Raspberry Pi is straight forward. If your Raspbian is up-to-date VNC is built in and just needs to be enabled. Below I will take you through a fresh install of Raspbian and setup of VNC.
First what will you need?
- Raspberry Pi 3+B (nice to start with a kit as they will typically include a case and power supply)
- MicroSD Memory Card
- Micro USB Power Supply
- Raspberry Pi Case
To begin the installation process you will need a MicroSD Memory Card, and the ability to format and burn an image to that MicroSD Memory Card. I am sure most of you know how to do these steps already, but I will give my recommendations, for formatting I prefer to use SD Memory Card Formatter for Windows and to burn the image Etcher.
Memory Card Preparation:
- Insert MicroSD Memory Card into a computer
- Open SD Memory Card Formatter for Windows
- In SD Memory Card Formatter for Windows Select the Drive that corresponds to your Memory Card
- In SD Memory Card Formatter for Windows Click Format and wait for it to finish
- Download the Raspbian disk image from https://www.raspberrypi.org/downloads/raspbian/
- Open Etcher.
- In Etcher Select the previously Downloaded Image
- In Etcher Select the Drive that corresponds to your Memory Card
- In Etcher Click Flash and wait for Etcher to Finish
Raspberry Pi Setup:
- From the Raspbian Desktop Click on Menu (The Raspberry Pi Icon in the top Left)
- Click on Preferences
- Click on Raspberry Pi Configuration
- Click on Interfaces
- Click the Radio Icon for Enabled next to VNC
- Click OK on that dialog box (You will be prompted to Reboot the Raspberry Pi, do this!)
- Next, we need to get the IP Address of the Raspberry Pi you can do this by launching Terminal from the Raspbian Desktop
- Type ifconfig and hit Enter
- Look for the number nest to “inet addr” it should look something like 192.168.1.1
- Download the VNC Viewer from RealVNC
- Launch the VNC Viewer on your Computer
- Enter the IP Address of your Raspberry Pi
- Click OK (the first time you connect you will get a message saying “VNC Server not Recognized” click Continue)
- You will then be prompted to log in using the credentials of your Raspberry Pi (if you have not changed them the username will be PI and the Password with be Raspberry)
If everything went well, you will not be looking at your Raspian Desktop. What you might want to do next is enable VNC from an external network and that is pretty simple to do. VNC runs on port 5900 so what you need to do is forward port 5900 of your Raspberry Pi to your external IP Address. I will not go into how to do that here as it varies greatly depending on your ISP, Modem and Router.
What do you use for remote connection of your Raspberry Pi? Let me know in the comments below.
I am passionate about the IoT and connected devices. Using connectivity to automate our lives will empower civilization to achieve greatness.