5-Inch Touch Screen Display with Raspberry Pi

Difficulty
Easy
Steps
12

The 5 inch LCD HDMI Display for Raspberry Pi 3  supports 800x480 resolution and has touch screen control capabilities. But it requires a few modifications before it can be used. 

In this guide, we will show you how to attach it to the Pi, then get it up and running quickly!

Some examples of what you could build with it includes a Raspberry Pi tablet, handheld game console or a digital photo frame.

Step 1  The Kit


There are four parts to the kit. 

  • The 5-inch LCD touch screen
  • A HDMI connector
  • Stylus pen
  • Screws and stand-offs

Step 2  Turn on backlight switch

We will turn the backlight on by flicking the switch. 

This is located on the back side of the LCD screen.

Step 3  Attach LCD to Raspberry Pi

  • Plug the LCD into the Raspberry Pi
  • Connect the HDMI connector to the HDMI interface on the LCD and the Pi.
    • Note: You should connect the LCD to the Raspberry Pi Model B or Raspberry Pi Zero with an HDMI cable rather than the HDMI connector.
  • Turn on the 'backlight' switch on the back of the LCD

Step 4  Copy LCD driver and xinput calibrator to Pi

  • This driver is for Raspbian after 180303 version. 
  • The second thing you will need later is the xinput calibrator: Xinput-calibrator_0.7.5-1_armhf.zip
    • Open up the .zip folder. The file you will need to copy over is: xinput-calibrator_0.7.5-1_armhf.deb
  • Copy both of them into the microSD card's "boot" folder. You can do so using a microSD card reader connected to your computer.

Step 5  Insert microSD card into Pi

If you have a NOOBS microSD card with Raspbian, please insert it into the Raspberry Pi now.

Then connect the power supply to start up Raspbian.

Don't have a NOOBS microSD card? Not to worry, please follow our guide on how to create a NOOBS MicroSD card.

Connect a keyboard as well as mouse to the Raspberry Pi and then power it on.

Note: If you have previously configured the Raspberry Pi with a different display i.e. our 7-inch display, please start with a fresh copy of Raspbian, or else the calibration will be off. 

Step 6  Connect to a network

To download the driver for the touch driver, you will need a network connection.

So connect to your network:

  • Click on the WIFI icon on the top right-hand corner of the desktop.
  • Click on 'Turn On Wi-Fi'
  • Then choose your network connection.
  • Enter credentials and save.

Step 7  Open a terminal window

Right now, you might notice some black borders.

We will change some settings so that the screen will be fully used. 

Click on the terminal window icon on the top left hand corner of the desktop.

With a terminal window open, run the following command:

 sudo nano /boot/config.txt

Step 8  Add these lines to config.txt

For the screen to display in landscape mode, add the following lines to the end of the config.txt file:

max_usb_current=1

hdmi_group=2

hdmi_mode=87

hdmi_cvt 800 480 60 6 0 0 0

hdmi_drive=1

Press CTRL+X , then press 'Y' and finally hit the 'Enter' key to save. 

Type sudo reboot in the terminal to restart the Pi. Once booted up again, you will notice that the black borders are now gone!


Step 9  Install touch driver

Enter the following commands in a terminal window to install the touch driver:

tar xzvf /boot/LCD-show-*.tar.gz 

cd LCD-show/

chmod +x LCD5-show

./LCD5-show

Step 10  Rotate the screen

The screen orientation can be set using these commands:

0 degree rotation:

cd LCD-show/

./LCD5-show 0

90 degree rotation:

cd LCD-show/

./LCD5-show 90

180 degree rotation:

cd LCD-show/

./LCD5-show 180

270 degree rotation:

cd LCD-show/

./LCD5-show 270


For this guide, we will rotate it 90 degrees so that it can be viewed in a portrait orientation.

Step 11  Touch screen calibration

Finally, we will calibrate the touch screen.

1. Enter the following command to install xserver-xorg-input-evdev:
sudo apt-get install xserver-xorg-input-evdev

2. Make sure that evdev.conf has a higher number than 40-libinput.conf. To do so, rename it with the following command:
sudo cp -rf /usr/share/X11/xorg.conf.d/10-evdev.conf /usr/share/X11/xorg.conf.d/45-evdev.conf 

3. Now we will download a program called xinput_calibrator, the software you had added to your Pi in Step 4. So open up the boot folder and double-click on the file, 'xinput-calibrator_0.7.5-1_armhf.deb'

4. To calibrate the touchscreen, click on Menu > Preference > Calibrate Touchscreen. Follow the prompts.

Step 12  Create a 99-calibration.conf

1. Navigate to the '/etc/X11' directory:

cd /etc/X11

2. Make a folder called 'xorg.conf.d'

sudo mkdir xorg.conf.d

3. Create a file '99.calibration.conf' using the command:

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

4. Enter the touch parameters you obtained in the previous step. (See third image)

5. Save file with CTRL+O 

6. Reboot the Pi with:

sudo reboot

The 5-inch display's touch functionality should now be precise!