1.3inch LCD HAT B

1.3inch LCD HAT B
1.3inch LCD HAT B

The 1.3inch LCD Display Module is a compact and high-quality screen designed for versatile DIY projects. Featuring an 8-pin SPI interface and a 240 × 240 resolution, this display is powered by the ST7789 controller, ensuring smooth and efficient performance. Pre-soldered with nut copper pillars, it offers easy installation and stability. Provides demo code for platforms such as Raspberry Pi and Arduino. It can draw dots, lines, rectangles, and circles, as well as display images and text in both English and other languages. Offers greater playability and DIY potential.

1. Product Features

  • Built-in ST7789 controller
  • 240 × 240 resolution
  • Uses SPI interface, requiring fewer pins
  • Ultra-compact size with pre-soldered nuts for easy installation
  • Provides example programs for Raspberry Pi and Arduino development boards

2. Interface Definition

Please refer to the table below for module specifications and details:

SpecificationDetails
Model1.3INCH LCD HAT B
ChipST7789
Operating Voltage3.3V
Color DisplayRGB 65K colors
Resolution240 × 240
Communication Interface4-wire SPI
Mounting Holes2.5mm diameter
LCD Display Area23.4mm (L) × 23.4mm (W)
Dimensions29mm (L) × 26mm (W)
Table 2. Module Specifications

3. Usage

Since the Bookworm system no longer supports the WiringPi library, the sample code for that platform uses the lgpio library instead. For Bullseye systems, the WiringPi-based examples still apply.

3.1 Hardware Interface Configuration Instructions

3.1.1 Raspberry Pi Hardware Connection

The following table shows the pin connections between the LCD module and Raspberry Pi:

Raspberry Pi to LCD Wiring Diagram
LCD InterfacePin FunctionBCM NumberWiringPi Number
VCC3.3V
GNDGND
DINMOSIGPIO1014
CLKSCLKGPIO1112
CSCE0GPIO810
RSTP2GPIO272
DCP6GPIO256
BLP5GPIO245
Table 3. Raspberry Pi to LCD Pin Mapping

The wiring diagram for the connection between the Raspberry Pi and the LCD display is shown below:

Raspberry Pi Wiring Diagram

3.1.2 Arduino Hardware Connection

The following table shows the pin connections between the LCD module and Arduino UNO:

LCD InterfaceArduino UNO
VCC5V
GNDGND
DIND11
SCKD13
CSD10
RSTD9
DCD8
BLD7
Table 4. Arduino UNO to LCD Pin Mapping

The wiring diagram for the connection between the Arduino and the LCD display is shown below:

Arduino Wiring Diagram

3.2 Demonstration Code

3.2.1 Installing the WiringPi Library

On the Raspberry Pi, run the following commands to install WiringPi:

sudo raspi-config
sudo apt-get install wiringpi
wget https://project-downloads.drogon.net/wiringpi-latest.deb
sudo dpkg -i wiringpi-latest.deb
gpio -v    # If version 2.52 appears, installation succeeded

For Bullseye systems, use:

git clone https://github.com/WiringPi/WiringPi
cd WiringPi
./build
gpio -v    # If version 2.70 appears, installation succeeded 

If you see ImportError: No module named 'wiringpi' when running Python examples, install:

Python 2.x:

 pip install wiringpi 

Python 3.x:

 pip3 install wiringpi 

To build manually:

 git clone --recursive https://github.com/WiringPi/WiringPi-Python.git
cd WiringPi-Python
sudo python setup.py install    # For Python 2.x
sudo python3 setup.py install  # For Python 3.x 

If SWIG errors occur, install SWIG first:

 sudo apt install swig 

3.2.2 Installing the LGPIO Library

On Bookworm systems, the example programs use the lgpio library. Install via:

 wget https://github.com/joan2937/lg/archive/master.zip
unzip master.zip
cd lg-master
make
sudo make install 

3.2.3 Demonstration Program

Enable and test the SPI interface:

 sudo raspi-config
# Select: Interfacing Options → SPI → Yes
ls /dev/spi*  # Should list /dev/spidev0.0 and /dev/spidev0.1 

Installing Python Libraries

For Python 3 environment, install PIL, numpy, and spidev:

 sudo apt-get install python3-pil
sudo apt-get install python3-numpy
sudo apt-get install python3-pip
sudo pip3 install spidev 

C Example Program

The C demo is divided into two layers:

  • Lower Layer: Contains lcd_1.3inch.c and lcd_1.3inch.h, handling GPIO initialization and LCD control.
  • Application Layer: Contains lcd_gui.c and lcd_gui.h, responsible for drawing shapes, images, and text.

Font files (named "font*") provide character data; details are in fonts.h. Raspberry Pi demos use ".bmp" images. Arduino UNO demos omit ".bmp" due to memory constraints; images are embedded in image.cpp.

To run the C demo:

 cd 1.3inch_lcd/c
sudo make clean
sudo make
sudo ./main 

Python Example Program

Python demo (Raspberry Pi only) leverages PIL, reducing code complexity. Run with:

 cd 1.3inch_lcd/python
python3 gui.py 

4. Resources

Schematic (PDF)

Arduino Demo Codes (ZIP)

Product Page

ST7789 Datasheet (PDF)