2.8inch Capacitive Touch LCD

From Waveshare Wiki
Jump to: navigation, search
2.8inch Capacitive Touch LCD
2.8inch Capacitive Touch LCD.jpg

I2C, SPI
2.8inch, 240×320
{{{name2}}}

{{{name3}}}

{{{name4}}}

{{{name5}}}

Overview

Parameters

(Please make sure the power supply voltage and logic voltage are the same, otherwise it will not work properly.)

Items Parameters
Supply Voltage 3.3V/5V
LCD Type TFT
Communication Interface Display: SPI
Touch: I2C
Controller Display: ST7789
Touch: CST328
Resolution 240(H) x 320(V)
Display Size 43.20 (H) x 57.60 (V) mm
Pixel Pitch 0.180 x 0.180 mm
Dimensions 73.06(H)x 50.54(V) mm

Interface Description

  • 13PIN connector:
LCD PIN FUNC Description
VCC 3.3V/5V Please make sure the power supply voltage and logic voltage are the same, otherwise it will not work properly
GND GND Ground
MISO SPI Input SPI Slave Device
MOSI SPI Output SPI Slave Device
SCLK SPI Clock Pin SPI Clock Pin
LCD_CS SPI Chip Selection SPI Chip Selection Pin
LCD_DC LCD Selection Signal Pin LCD Signal Control Pin, L: Command; H: Data
LCD_RST LCD Reset LCD Reset Pin, Low Active
LCD_BL LCD Backlight Control LCD Backlight Control, Adjust PWM Duty Cycle Control
TP_SDA Touchpad Data Pin Touchpad Data Pin
TP_SCL Touchpad Clock Pin Touchpad Clock Pin
TP_INT Touchpad Interrupt Pin Touchpad Interrupt Pin, Interrupt When Press It
TP_RST Touchpad Reset Pin Touchpad Reset Pin, Low Active
  • 18PIN FPC slot:
PIN NO. LCD PIN FUNC
1 VCC 3.3V/5V
(Please make sure the power supply voltage and logic voltage are the same, otherwise it will not work properly)
2 LCD_BL LCD Backlight Control
3 GND GND
4 SCLK SPI Clock Pin
5 MOSI SPI Output
6 MISO SPI Input
7 LCD_DC LCD Signal Selection Pin
8 LCD_RST LCD Reset
9 LCD_CS SPI Chip Selection
10 NC Not Connected, internally not connected
11 NC Not Connected, internally not connected
12 TP_RST Touchpad Reset Pin
13 TP_SCL Touchpad Clock Pin
14 TP_SDA Touchpad Data Pin
15 TP_INT Touchpad Interrupt Pin
16 NC Not Connected, internally not connected
17 NC Not Connected, internally not connected
18 NC Not Connected, internally not connected

Working with Raspberry Pi

Please note that the following example is run on Raspberry Pi 4.

Hardware Connection

  • 13PIN connector:
LCD PIN Raspberry Pi (BCM)
VCC 3.3V
GND GND
MISO NC
MOSI 10
SCLK 11
LCD_CS 8
LCD_DC 25
LCD_RST 27
LCD_BL 18
TP_SDA 2
TP_SCL 3
TP_INT 4
TP_RST 17

Enable SPI & I2C Interface

  • Open the Raspberry Pi terminal and input the following commands to enter the config interface:
sudo raspi-config
  • Select "Interfacing Options -> SPI -> Yes" to enable the SPI interface.

2.8inch Capacitive Touch LCD RaspberryPi explain 2.png

2.8inch Capacitive Touch LCD RaspberryPi explain 1.png

2.8inch Capacitive Touch LCD RaspberryPi explain 3.png

  • Continue to enter the config interface:
sudo raspi-config
  • Select "Interfacing Options -> I2C -> Yes" to enable the I2C interface:

2.8inch Capacitive Touch LCD RaspberryPi explain 2.png

2.8inch Capacitive Touch LCD RaspberryPi explain 4.png

2.8inch Capacitive Touch LCD RaspberryPi explain 5.png

  • Reboot the Raspberry Pi:
sudo reboot
  • Check /boot/config.txt, you can see 'dtparam=i2c_arm=on' and 'dtparam=spi=on' are written.
more  /boot/config.txt

2.8inch Capacitive Touch LCD RaspberryPi explain 6.png

  • To ensure SPI is not occupied, it is recommended to disable other drivers. You can use "ls /dev/spi*" to check whether SPI is occupied, and when the terminal outputs "/dev/spidev0.0" and "/dev/spidev0.1", SPI works normally.
ls /dev/spi* 

2.8inch Capacitive Touch LCD RaspberryPi explain 7.png

Python Environment Usage

Install Libraries

  • Install libraries:
sudo apt-get update
sudo apt-get install python3-pip
sudo apt-get install python3-pil
sudo apt-get install python3-numpy
sudo pip3 install spidev
sudo pip3 install Pillow

Examples

  • Download the following demos:
cd
wget https://files.waveshare.com/wiki/2.8inch-Capacitive-Touch-LCD/2.8inch_Capacitive_Touch_LCD_RaspberryPi.zip
  • Install unzip environment (optional, skip this step if using the command to unzip):
sudo apt-get install unzip
  • Enter the file location, and execute the command to unzip:
unzip 2.8inch_Capacitive_Touch_LCD_RaspberryPi.zip -d ./2.8inch_Capacitive_Touch_LCD

2.8inch Capacitive Touch LCD Python.png

  • Enter Python file folder:
cd 2.8inch_Capacitive_Touch_LCD/Python
  • Run the sample demo and you can see the LCD displays three pictures, and then input:
sudo python 2inch8_LCD_test.py

Usage in C Environment

Install Libraries

  • Install libraries:
git clone https://github.com/WiringPi/WiringPi
cd WiringPi
./build
gpio -v
  • Run "gpio -v" to check whether it is 2.70 version, if not, the installation fails.
  • Download example files.
  • Enter the file directory, and run the demo.

Example Operation

  • Download the sample demo:
cd
wget https://files.waveshare.com/wiki/2.8inch-Capacitive-Touch-LCD/2.8inch_Capacitive_Touch_LCD_RaspberryPi.zip
  • Install unzip environment (optional, skip this step if using the command to unzip):
sudo apt-get install unzip
  • Enter the file location, and execute the command to unzip:
unzip 2.8inch_Capacitive_Touch_LCD_RaspberryPi.zip -d ./2.8inch_Capacitive_Touch_LCD

2.8inch Capacitive Touch LCD Python.png

  • Enter C file folder:
cd 2.8inch_Capacitive_Touch_LCD/C
  • Clean compilation files and compile again:
sudo make clean
sudo make -j
  • Run the sample demo and you can see the LCD displays three pictures, and then input:
sudo ./main

Working with Raspberry Pi Pico

Hardware Connection

  • 13PIN header:
LCD PIN Raspberry Pi Pico
VCC 3.3V
GND GND
MISO NC
MOSI 11
SCLK 10
LCD_CS 9
LCD_DC 14
LCD_RST 13
LCD_BL 15
TP_SDA 6
TP_SCL 7
TP_INT 16
TP_RST 17

Python Environment

Preparation

  1. Install Thonny. (Thonny Python IDE (Windows V3.3.3))
  2. Press the "BOOTSEL" key on the Raspberry Pi Pico, and release it after powering.
  3. A new disk will appear on your computer, extract the Raspberry Pi Pico firmware and copy the firmware (suffix uf2) to that disk (the disk will automatically disappear if the copy is successful).
  4. Open Thonny, click on "Python x.x.x" at the bottom right, and select "Configure interpreter".
  5. Select "Interpreter" in the pop-up window -> select "MicroPython (Raspberry Pi Pico)" as the interpreter -> select "Auto-detect port" as the port.
  6. Click on "Stop", and the Shell window will show "MicroPython v1.20.0-50-g786013d46 on 2023-05-04; Raspberry Pi Pico with RP2040 Type "help()" for more information. " is a successful connection.

The following is the procedure for points 4 and 5:
TF-Luna LiDAR Range Sensor Pico10.png
The successful connection is shown below:
TF-Luna LiDAR Range Sensor Pico11.png

Sample Demo

  • Download the sample demo.
  • Unzip the sample demo and open Thonny.
  • Enter the sample file folder and open "RaspberryPi_Pico/Python" file folder.
  • Upload the " LCD_2inch8_Touch.py" file to "Raspberry Pi Pico".

2.8inch Capacitive Touch LCD RaspberryPi Pico example 1.png

  • Open the uploaded file:

2.8inch Capacitive Touch LCD RaspberryPi Pico example 2.png

  • Run the demo to realize touchpad functions:

2.8inch Capacitive Touch LCD RaspberryPi Pico example 3.png

  • Please modify the file name "LCD_2inch8_Touch.py" as "main.py " if you want the demo to automatically run after powering on.

Working with ESP32S3

Please note that the following examples use firmware version 2.0.11. Higher versions may cause the functions to be incompatible and fail to display.

Hardware Connection

  • 13PIN connector:
LCD Pin ESP32S3
VCC 3.3V
GND GND
MISO NC
MOSI 45
SCLK 40
LCD_CS 42
LCD_DC 41
LCD_RST 39
LCD_BL 5
TP_SDA 1
TP_SCL 3
TP_INT 4
TP_RST 2

Environment Set-up

ESP32-C6-DEV-KIT-N8-Arduino01.png

  • Enter Arduino IDE after installation.

ESP32-C6-DEV-KIT-N8-Arduino02.png

  • Go to the board manager, search for esp32, select the latest version of esp32 by Espressif Systems at the bottom, and click install (if it doesn't install correctly, you can try using a phone hotspot).

ESP32-S3-DEV-KIT-N8-Arduino07.png

  • Restart the Arduino IDE after installation, and then you can use it.

ESP32-S3-DEV-KIT-N8-Arduino09.png

If the installation fails

  • Failed to install 2.0.11 version:

ESP32-S3-DEV-KIT-N8-install.png

ESP32-S3-DEV-KIT-N8-install02.png

  • Click on the path from the resource manager "c:\Users\Waveshare\AppData\Local\Arduino15\staging\packages" (Waveshare is the user name of the computer, and you need to turn on "Show Hidden Files").

ESP32-S3-DEV-KIT-N8-install03.png

  • Unzip the downloaded files to the packages file folder:

ESP32-S3-DEV-KIT-N8-install04.png

  • Install it again:

ESP32-S3-DEV-KIT-N8-Arduino07.png

  • Restart the Arduino IDE after installation and you're ready to go!

ESP32-S3-DEV-KIT-N8-Arduino09.png

Install Libraries

  • Please note whether the library has been previously installed, if so, please save the original library to prevent errors and failures when running other programs.
  • Enter "2.8inch_Capacitive_Touch_LCD\ESP32S3\LVGL_Arduino" file folder, double-click LVGL_Arduino.ino to open the example.
  • Search the lvgl library and install it (this step is for setting the library file folder in Arduino environment, if you have installed other libraries (the following file folders exist), you do not need to execute this step.)

2.8inch Capacitive Touch LCD ESP32S3 example 2.png

2.8inch Capacitive Touch LCD ESP32S3 example 4.png

  • Enter the storage path of the library file: "c:\Users\Waveshare\AppData\Local\Arduino15\packages\libraries" ("Waveshare" is the computer username).

2.8inch Capacitive Touch LCD ESP32S3 example 3.png

  • Delete the lvgl library downloaded before (skip this step if not installed):

2.8inch Capacitive Touch LCD ESP32S3 example 5.png

  • Install two libraries in the sample file.
  • Copy the provided library to "c:\Users\Waveshare\AppData\Local\Arduino15\packages\libraries" ("Waveshare" is the computer username):

2.8inch Capacitive Touch LCD ESP32S3 example 7.png

  • Finish library installation.

Sample Demo

  • Open the sample demo again.
  • Select the model and COM port, compile and program the sample.

2.8inch Capacitive Touch LCD ESP32S3 example 9.png

  • Three operation interfaces can be observed after successful programming.

Working with Arduino

Hardware Connection

  • 13PIN connector:
LCD Pin Arduino
VCC 5V
GND GND
MISO NC
MOSI 11
SCLK 13
LCD_CS 10
LCD_DC 7
LCD_RST 8
LCD_BL 9
TP_SDA SDA
TP_SCL SCL
TP_INT 3
TP_RST 4

Sample Demo

  • Download and unzip sample demo.
  • Enter the sample demo file folder "2.8inch_Capacitive_Touch_LCD\Arduino\LCD_2inch8_Touch", double click on LCD_2inch8_Touch.ino to open the sample:

2.8inch Capacitive Touch LCD Arduino example 1.png

  • Select the device and the port, compile and program the demo:

2.8inch Capacitive Touch LCD Arduino example 2.png

Resource

Document

Schematic

Datasheet

Demo

FAQ

 Answer:

Please check if the GPIO levels of the board are consistent with the product's supply voltage!

{{{5}}}


Support



Technical Support

If you need technical support or have any feedback/review, please click the Submit Now button to submit a ticket, Our support team will check and reply to you within 1 to 2 working days. Please be patient as we make every effort to help you to resolve the issue.
Working Time: 9 AM - 6 PM GMT+8 (Monday to Friday)