When using the Raspberry Pi, it is often inconvenient to setup an individual monitor, keyboard, mouse, and power supply for the device.
However, your current computer already has all of these things built into it, and through the power of SSH and VNC, you can use your own computer's screen and keyboard to control the Raspberry Pi over a USB connection.
This can make for an extremely convenient and portable development environment for the Raspberry Pi, and allows full control over the Pi with only a laptop and a USB-C cable.
This tutorial will work either on any computer or tablet with an SSH client and a USB port (basically all computers)
This tutorial assumes that you have installed Rasbperry Pi OS or Ubuntu. This may not work for different operating systems.
Turn off your Pi and remove the SD card. Upon plugging it into your computer and mounting the card, you should see the following files:
Search for the SD card in your computer's file manager, and locate the files
cmdline.txt and add the option
modules-load=dwc2,g_ether to the end of the file.
config.txt and add the line
dtoverlay=dwc2 under the header
[all] (the one below
Eject the SD card with the new configuration and put it back into the Raspberry Pi.
Note that if this is the first time you are booting with this SD card,
cmdline.txt is overwritten and will need to be edited afterwards. If you are newly installing an operating system onto the SD card, this can be combatted by booting the Pi, letting it run for a moment, and then unplugging it and putting the SD card back into the computer.
The Raspberry Pi does not draw large amounts of current, so it is actually possible to power the Pi just by plugging it into a USB-C port on your laptop!
Plug a standard USB-C cable into the power socket on the Raspberry Pi, and plug the other end into your laptop or tablet.
Next, open a command line application on your computer:
We will be accessing the Pi over SSH.
You need to tell the computer where to SSH into. You do this with either the syntax
The syntax for the command you will enter into your terminal is
If I preconfigured my username as
bobby and my hostname as the default
raspberrypi.local, I can SSH into the Raspberry Pi with the command:
You will likely be prompted to authenticate the new device, and enter the password you setup earlier.
Once logged in, you will be greeted with a welcome screen similar to this:
This means that we were successful! This is a terminal window which runs commands on the Raspberry Pi. Try typing in commands such as
pwd, and you can see the directories and files on the Pi.
This section and beyond is only necessary if you desire a Destop Environment. Note that Raspberry Pi OS Lite does not come pre-installed with a desktop environment or a VNC server.
Virtual Network Computing, or VNC, is a technology that allows a computer to remotely access the GUI on a different machine. We can use VNC on the Raspberry Pi to use the desktop interface.
A VNC server already comes pre-installed on Raspberry Pi OS, so we don't need to worry about installing it!
To enable it, first SSH back into the Raspberry Pi. Go the the configuration menu by tying in the following command:
You will be greeted with a page like this:
Navigate to Interface Options > VNC and enable the VNC server.
Your computer must have a VNC client to access the Raspberry Pi. Here's how to download one for your operating system:
brew install --cask vnc-viewer
The default Screen Sharing app tends to throw an error message regarding "incompatible" software. So far, the only way I've found to get around this is to first VNC into the Pi on a different computer and open VNC Configuration > Security, then disable encryption and change the password type from built-in UNIX to VNC password. Understandably, this may not be a good idea, and requires a separate computer, so I would recommend installing VNC Viewer instead.
sudo apt-get install -y vnc-viewer
Open your VNC Client app and enter the hostname, username, and password when prompted.
If successful, you will get a window popup, with a GUI of the Raspberry Pi Operating System, and complete control over the Pi.
In the top-right corner of the screen, you can configure the VNC server on your Raspberry Pi.