Cool stuff for Raspberry Pi, Arduino and all electronics hobby projects

Using 2.8” Touchscreen Display on Raspberry PI

Updated on 2014.09.13: this tutorial is for Raspberry Pi model A/B only. If you follow this tutorial on model B+, it will not work. At the time being we could not say it is impossible to use this screen on the model B+, but at least some work on software has to be done before that happens.

This is a cute, tiny 2.8″ touchscreen for Raspberry Pi. It is designed to work as an SPI device, and use the hardware SPI pins (SCK, MOSI, MISO, CE0, CE1). It also has 4 reserved buttons on board, which use 4 GPIO pins (#23, #22, #21, and #18). You can define some special tasks for this buttons, such as “shutdown”, “reset”, “brightness up/down” etc.

Here are the steps to setup everything.

Step 1: Mount the Touchscreen Over the Pi

First off you need to mount this tiny touchscreen over the Raspberry Pi, like this:
PiTFT - 2.8" Touchscreen Display for Raspberry Pi

Step 2: Driver Installation

To install the driver for this touchscreen, you need to login to Raspberry Pi via SSH or you have another display connected to the Pi.
You need to download these driver packages:

cd ~
sudo apt-get update

If your Raspbian is released after January 2014, you may need to download this patch as well:


Let’s install them:

sudo dpkg -i -B *.deb

Again if your Raspbian version is after January 2014, please move the configuration file, as shown below:

sudo mv /usr/share/X11/xorg.conf.d/99-fbturbo.conf ~

Then you need to reboot your Pi:

sudo reboot

 Step 3: Testing Driver

Now you input the commands below, and enter X window. If everything goes fine, you should see the X window in the mini display:

sudo modprobe spi-bcm2708
sudo modprobe fbtft_device name=adafruitts rotate=90
export FRAMEBUFFER=/dev/fb1 


Step 4: Auto Loading the Driver at Boot

If you wish the driver to be loaded at boot, you can modify the /etc/modueles file:

sudo nano /etc/modules

and append two lines as below:


and then modify the adafruit.conf file:

sudo nano /etc/modprobe.d/adafruit.conf

add the following line

options fbtft_device name=adafruitts rotate=90 frequency=32000000

Here we set the driver to rotate the screen 90 degrees (it could be 0, 90, 180 or 270 degrees). You can always change this file with and reboot to let the change take effect.
We also set the refresh frequency of the display to 32MHz, which is good for 20 FPS. If your display doesn’t behave correctly with this frequency, try 16MHz instead.
We need to create the calibration file and the directory to store it:

sudo mkdir /etc/X11/xorg.conf.d
sudo nano /etc/X11/xorg.conf.d/99-calibration.conf

Put the following content into the file and save it.

Section "InputClass"
        Identifier      "calibration"
        MatchProduct    "stmpe-ts"
        Option  "Calibration"   "3800 200 200 3800"
        Option  "SwapAxes"      "1"

If you don’t wish to specify the output device every time, you can modify the .profile file:

sudo nano ~/.profile

and add the line below into the file:

export FRAMEBUFFER=/dev/fb1

 Step 5: Calibration

First we modify the 95-stmpe.rules file:

sudo nano /etc/udev/rules.d/95-stmpe.rules

and add the command below:

SUBSYSTEM=="input", ATTRS{name}=="stmpe-ts", ENV{DEVNAME}=="*event*", SYMLINK+="input/touchscreen"

Execute this command to remove and re-install the touchscreen:

sudo rmmod stmpe_ts; sudo modprobe stmpe_ts

Now we install the calibration application:

sudo apt-get install evtest tslib libts-bin

Input the command below to start calibration, you can always quit with Ctrl+C:

sudo TSLIB_FBDEVICE=/dev/fb1 TSLIB_TSDEVICE=/dev/input/touchscreen ts_calibrate

Type this command to verify the result of calibration, again you can quit with Ctrl+C:

sudo TSLIB_FBDEVICE=/dev/fb1 TSLIB_TSDEVICE=/dev/input/touchscreen ts_test


Step 6: Display a Picture

Use the commands below can download a picture and display it on your mini touchscreen display:

sudo apt-get install fbi
sudo fbi -T 2 -d /dev/fb1 -noverbose -a uugear320x240.jpg


Step 7: As Terminal Display

Well, if you wish to use this display to replace the HDMI/TV output, you are just one step away:

sudo nano /boot/cmdline.txt

Append this after the “rootwait”

fbcon=map:10 fbcon=font:VGA8x8

By doing so, next time when you boot your Pi, this tiny touchscreen will work as the terminal display.

IMG_0098 IMG_0099

Because of the low resolution, using 6×12 font will get better result:

sudo dpkg-reconfigure console-setup

Just follow these configure steps and then reboot your Pi:
UTF-8 -> Guess optimal character set -> Terminus -> 6×12(framebuffer only)

Step 8: Button to Shutdown Your Pi

Do you still remember the 4 reserved buttons? We can define the task we need and associate with them. For example: shutdown the Pi.

sudo nano /etc/modules

Add this to the file:


Again we modify the adafruit.conf file:

sudo nano /etc/modprobe.d/adafruit.conf

Append these to the file, the first button on the left is the one that connect to GPIO #23:

options rpi_power_switch gpio_pin=23 mode=0 
sudo modprobe rpi_power_switch

Done! Now you can enjoy it 🙂

See also

Join Waitlist We will inform you when the product arrives in stock. Please leave your valid email address below.