Dylanli
Posts: 28
Joined: Mon May 24, 2021 6:03 am

How to connect Raspberry Pi using 5" HDMI touch screen

Fri Jun 18, 2021 3:55 am

The Raspberry Pi (Raspberry Pi) is a very compact card-based computer that is very popular today in a variety of IoT applications as well as big data computing applications such as data science, python, and machine learning. Many applications require an external display in order to connect to the Raspberry Pi. The Raspberry Pi comes with an HDMI port to connect to an external display such as a TV or monitor. However, in some applications, a compact display is appropriate and preferred for input via the GUI application touch screen. For these applications, an HDMI touchscreen can be used. In this post, we connect a 5" HDMI touchscreen to the Raspberry Pi and will also learn to calibrate the touchscreen to improve its accuracy.

Components used

● Raspberry Pi development board

5-inch 800x480 TFT display with touch screen

● 16GB Micro SD card

● HDMI connector

Stylus

● 5V power supply

● USB keyboard

● USB mouse

Connecting a 5-inch TFT LCD to a Raspberry Pi

1. Place the LCD on top of the Raspberry Pi.
The first step in connecting the LCD to the Raspberry Pi is to use the GPIO connector to connect the LCD to the Raspberry Pi. The display comes with four angled pins for mounting. The LCD is then placed on top of the Raspberry Pi so that it plugs into the GPIO slot and the HDMI port is perfectly aligned on the other side. Be careful when connecting the LCD to the Raspberry Pi, as the LCD only uses 26 pins to connect to the Pi.

2. Connect the HDMI connector.
After placing the LCD on the top of the Raspberry Pi, connect the HDMI connector included in the LCD box between the Pi and the LCD.

3. Connect the power supply.
After completing all of the above steps, we need to provide power to the Raspberry Pi and the LCD. There is also a USB plug on the LCD that provides a separate power supply, however, as long as you have a good 2.4 Amp power supply for the Raspberry Pi, you do not need a separate power supply for the LCD.

4. Turn on the backlight switch of the LCD.
After turning on the power, turn on the backlight power switch on the back of the LCD.
Install the driver for the 5" LCD in the Raspberry Pi.

Installing drivers for a 5" LCD in a Raspberry Pi

1. Edit some parameters in the configuration file.
Before downloading the LCD driver, make some changes in the configuration file as shown below. The configuration file can be found using the following command.

Code: Select all

sudo nano /boot/config.txt
Next, simply add the following lines of code to the configuration file.

Code: Select all

max_usb_current=1
hdmi_group=2
hdmi_mode=87
hdmi_cvt 800 480 60 6 0 0 0
hdmi_drive=1
2. Download the driver.
First download the driver from github. This can be done by entering the following command in the Raspberry pi terminal.

Code: Select all

git clone https://github.com/waveshare/LCD-show.git
3. Enable the display.
After successful installation of the driver, we can enable the display using the following command.

Code: Select all

cd LCD-show/
chmod +x LCD5-show
./LCD5-show
4. Reboot the Raspberry Pi
After running the above command, the Raspberry Pi will automatically reboot and the LCD should now be working.

Touch screen calibration for Raspberry Pi
The last step is to calibrate the touchscreen for optimal work. To do this, we should install an application called "xinput-calibrator" in the Raspberry Pi.
To install this application, we need to run the following command.

Code: Select all

sudo apt-get install -y xinput-calibrator
After successfully installing the above program, click the "Menu" button on the Raspberry Pi taskbar and then select "Preference -> Calibrate Touchscreen". Then follow the prompts to complete the touchscreen calibration. The touchscreen calibration window is shown below.
Simply touch the red marked spot with the stylus and then similarly touch all 4 consecutive red spots on the screen, which should then prompt the calibration parameters on the screen.
Just save the above parameters and restart the Raspberry Pi. Now, our display setup is complete and we can use this 5" touch screen.

Return to “Other projects”