Home > Other >Special Application Circuits > How to connect TFT LCD to Raspberry Pi

How to connect TFT LCD to Raspberry Pi

Source: InternetPublisher:拿铁三分糖 Keywords: HDMI touch screen display Raspberry Pi Updated: 2024/12/24

Raspberry pi is a credit card sized compact computer which is very popular nowadays for IoT applications and high computing applications like data science, python, machine learning etc. Many applications require an external display to be connected with Raspberry Pi. In such cases, Raspberry Pi has its own HDMI interface to connect external display like TV or monitor. But in some applications, a compact display is suitable and touch screen input is preferred through GUI applications. For these applications, HDMI touch screen display can be used. Today we will connect 5 inch HDMI touch screen display with Raspberry Pi and will also learn to calibrate the touch screen to improve its accuracy.

Materials used

Raspberry Pi 3 B (in my case)

5-inch 800x480 TFT display with touch screen

16 GB Micro SD card

HDMI Connector

Stylus

5V, 2.4 AMP Power Supply

USB keyboard

USB Mouse

5-inch 800x480 TFT touch screen display

pYYBAGL2BASAWy-DAAWjdm45AcE073.png

The 5" Touchscreen Raspberry Pi Display is a TFT HDMI display that is very compact and can be used with Raspberry Pi A, B, Pi B+/2B and 3B models. Built-in resistive touch screen, supports backlight control, power saving and supports HDMI input. It acts as a computer monitor with a resolution of 800x480 pixels.

feature:

5-inch HDMI monitor

800x480 px high resolution pictures and large screen.

Built-in resistive touch screen with backlight control to reduce power consumption.

Wide viewing angle

Fast response time and full color display.

Technical Specifications:

Size: 5 inches

Resolution: 800 * 480

Display Controller: XPT2046

LCD interface: SPI

Touch type: Resistive

LCD screen type: TFT

Connecting 5-inch TFT LCD to Raspberry Pi

1. Place the LCD on top of the Raspberry Pi:

poYBAGL2A_-AJ20CAAYv3qKwCm0629.png

The first step to connect the LCD with the Raspberry Pi is to connect the LCD with the pi using the GPIO connector. The display comes with four corner brackets for mounting. Then, place the LCD on top of the Raspberry Pi so that it slides into the GPIO slots and the HDMI port will line up perfectly on the other side. Be careful when connecting the LCD to the Pi as the LCD uses only 26 pins to connect with the Pi.

2. Connect the HDMI connector:

poYBAGL2A_uAYVjqAARF8TkPv_A455.png

With the LCD placed on top of the Raspberry Pi, connect the HDMI connector included in the LCD box between the Pi and the LCD as shown below:

3. Connect the power supply:

After completing all the above steps, we need to power the Raspberry Pi and the LCD. There is also a USB plug on the LCD for separate power, but as long as your Pi has a good 2.4 amp power supply, it does not require a separate power supply for the LCD.

4. Turn on the LCD backlight switch:

After the power is on, turn on the backlight .

Installing drivers for the 5-inch LCD in 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:

sudo nano /boot/config.txt

pYYBAGL2A_eARe74AAC0eOpn24s965.png

Next, simply append the following line to your configuration file.

max_usb_current = 1

hdmi_group=2

hdmi_mode=87

hdmi_cvt 800 480 60 6 0 0 0

hdmi_drive=1

poYBAGL2A_KAXq3SAAGiG6F0MO4143.png

Note: In some cases, you only need to uncomment the above statements in your config. file, if the file already contains the above statements in a commented line.

2. Download the driver:

First download the driver from github. This can be done by typing the following command in the Raspberry pi terminal.

git clone https://github.com/waveshare/LCD-show.git

poYBAGL2A--AIgRHAAIVKEkVuT8035.png

3. Enable the display:

After the driver is successfully installed, we can use the following command to turn on the display:

cd LCD-show/

chmod +x LCD5-show

./LCD5-show

《》4. Restart the Raspberry Pi

poYBAGL2A-uAYpCFAASk1r7lqr8166.png

After running the above command, the pi will automatically reboot and the screen should now work. This can be seen in the image below:

pYYBAGL2A-eAdx9GAAcJ8tsFBjU474.png

Raspberry Pi touch screen calibration

The last part of the process is to calibrate the touch screen for optimal working. For this we should install an application called " xinput-calibrate " in our pi.

In order to install the program we have to run the following command:

pYYBAGL2A-OAWnZfAABnzZTujBw474.png

sudo apt-get install -y xinput-calibrator

After the above program is successfully installed, click the menu button on the Raspberry Pi taskbar and select Preference -> Calibrate Touchscreen. Then follow the prompts to complete the touch screen calibration. The touch screen calibration window should look like this:

poYBAGL2A9-ANRYDAAFus0TOeiQ993.png

Simply touch the red marked point with the stylus, then touch all 4 consecutive red points on the screen, and the calibration parameters will be prompted on the screen as shown below:

Just save the above parameters and reboot the Raspberry Pi. Now, our display settings are complete and we can use the 5-inch touch screen with LCD without any problems.

This is how TFT LCD is connected with Raspberry Pi and can be used to build applications like games, alarm clocks, tablets, etc.

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号