Driver Installation

The first step to setup the display is to install the necessary drivers. Depending on your exact hardware, you have a couple of options. After the driver setup, there are a couple of additional steps below.

Option 1. BrainCraft HAT Setup

If you have an Adafruit BrainCraft HAT, you'll first want to head over to the Adafruit BrainCraft HAT - Easy Machine Learning for Raspberry Pi guide and go through the setup process there. Specifically, you'll want to follow the Audio Setup, Fan Service Setup, and Display Module Install pages. This will guide you through all the pieces needed to prepare the Pi.

Option 2. PiTFT Setup

If you have just a bare PiTFT, you'll want to install the PiTFT Drivers. There is a new installer script now, so it can be installed with just a few commands. First, start by installing a few dependencies and downloading the repo:

cd ~
sudo pip3 install --upgrade adafruit-python-shell click
sudo apt-get install -y git
git clone
cd Raspberry-Pi-Installer-Scripts

Next, choose the install command based on your display. For the 2.4", 2.8", or 3.2" Resistive touchscreens, use the following command:

sudo -E env PATH=$PATH python3 --display=28r --rotation=90 --install-type=mirror

For the 3.5" Resistive touchscreen, use the following command:

sudo -E env PATH=$PATH python3 --display=35r --rotation=90 --install-type=mirror

For the 2.8" Capacitive touchscreen, use the following command:

sudo -E env PATH=$PATH python3 --display=28c --rotation=90 --install-type=mirror

When you get asked to reboot, reboot!

After it reboots, you should now see your desktop on the display.

Make the TFT the Default Display

With the Desktop Environment, you can set the default display by setting an environment variable. To set the TFT as the display where the window is drawn, there are a few ways to do this depending on the level of permanence that you would like to give it. Each way involves setting the DISPLAY environment variable to :0.

The first way is to prefix every command with DISPLAY=:0. This sets the enviroment variable until the command is done executing. So if you wanted to run libcamera-hello, you would type out:

DISPLAY=:0 libcamera-hello

The second way is to set the variable for the remainder of the SSH terminal session. To do this, just run the command every time you SSH into the Pi:

export DISPLAY=:0

The third way is to set it in a file that automatically runs each time you connect with SSH such as .bashrc. Of course this also assumes you continue using bash as your default shell. To make a backup of your current .bashrc file and add it, just run these commands:

cp ~/.bashrc ~/.bashrc.backup
echo "export DISPLAY=:0" >> ~/.bashrc
source ~/.bashrc

For the sake of simplicity, this guide will assume you are using one of the latter two methods. If you wanted to use the first method, just prefix it to any command that uses the camera such as the libcamera apps or any of the rpi-vision demos.

This guide was first published on Sep 04, 2019. It was last updated on Mar 08, 2024.

This page (Display Setup) was last updated on Mar 08, 2024.

Text editor powered by tinymce.