2.9inch E-paper Display Expansion Module HAT

Product Introduction

1.1 Product Overview

This product is a 2.9-inch 4-color ink screen, supporting black, white, yellow and red 4 color display.Its resolution is 296x128, using SPI communication mode, and supporting global refresh mode.The driver board is designed based on the 40-pin interface of Raspberry Pi, making it compatible with Raspberry Pi series boards. We provide example programs in C and Python for Raspberry Pi. A reserved SPI control interface allows easy integration with main control boards such as Arduino, STM32, and ESP32. We also offer example code for Arduino, STM32, and ESP32, which supports displaying images, English and numerical characters, and drawing points, lines, rectangles, and circles.

1.2 Product Features

  • Resolution296x128
  • SPI interface, requiring fewer
  • Onboard level-shifting chip, compatible with 3.3V and 5V microcontroller interfaces
  • Designed based on the Raspberry Pi 40-pin GPIO interface, compatible with Raspberry Pi series boards
  • Reserved SPI communication interface for easy integration with main control boards such as Arduino, STM32, and ESP32
  • Provides open-source example programs for Raspberry Pi, Arduino, STM32, and ESP32 development boards

1.3 Product Specifications

Pixels

296x128

Display Colors

4 colors: black, white, yellow, red

Level-Shifting Chip

TXS0108EPWR

Signal Interface

SPI

Power Supply Voltage

3.3V/5V

Full Refresh

20s

Display direction

Landscape, Portrait

Operating temperature

0℃-40℃

FPC Interface

0.5mm pitch 24 Pin

Refresh power consumption

9.9mW

Standby power consumption

0.003mW

Explanation of the refresh process (refresh time: the entire process from the beginning of the screen action to the stabilization of the screen):

Global refresh: During the refresh process, the screen will flash many times.

1.4 Interface Definition

VCC

3.3V/5V

GND

Power ground

RST

External reset pin (low level reset)

BUSY

Busy status output pin

D/C

Data/Command control pin (high level for data, low level for command)

MOSI

SPI communication MOSI pin

CS

SPI chip select pin (active low)

CLK

SPI communication SCK pin

1.5 Product Dimensions

Dimensions

82mm x 38.1mm

Display area

66.90mm x 29.06mm

1.6 Product Advantages

E-paper uses "microcapsule electrophoretic display" technology for image display. Its working principle involves charged nanoparticles suspended in a liquid that migrate under the influence of an electric field, creating a display effect close to traditional printed paper through reflection under ambient light. Once refreshed, it requires no power and can maintain the displayed image for a long time. E-paper can clearly display images under various lighting conditions, including ambient and natural light, without the need for backlighting, and offers an almost 180° viewing angle. Due to its paper-like display quality, it is commonly used in e-readers, labels, and similar applications.

1.7Application

Suitable for e-book readers, electronic price tags, industrial and logistics labels, digital signage, billboards, conference nameplates, electronic memos, etc.

1.8 Resource Overview

The overview of the driver resources is shown in the figure below:

① 2.9-inch black-white-yellow-red 4-color ink screen

② E-paper screen connector

③ SPI control interface connector

④ Level-shifting chip TXS0108EPWR

⑤ SPI lines count selection switch(default is "0" position)

Accessories List

12.9-inch black-white-yellow-red 4-color ink screen(with driver board) x1

2PH2.0 8PIN connector cable 20cm x1

Ⅲ Usage

All the demo codes provided by this product are based on the 4-wire SPI mode, so the BS selection switch on the back of the board is set to "0" by default.

3.1Raspberry Pi Example Usage

The example code for the Raspberry Pi platform is divided into two versions: lgpio and wiringpi. The bookworm system uses the lgpio library, while the bullseye system uses the wiringpi library.

3.1.1Raspberry Pi Platform Interface Definition

Figure 3-1 Raspberry Pi interface diagram

The following figure shows the wiring diagram between the Raspberry Pi and the ink screen:

The example programs for the Raspberry Pi board use the BCM numbering for pin definitions with the lgpio library and the wiringpi numbering with the wiringpi library. The pin wiring definitions for the Raspberry Pi board are as shown in the table below:

E-paper Interface (E-paper Connector)

Pin Function

BCM Numbering

wiringpi Numbering

VCC

3.3V

GND

GND

BUSY

Busy Signal Pin

24

5

RSTN

Reset

17

0

D/C

Command/Data Select

25

6

SDA

SPI Data Out/Slave In

10

12

SCL

SPI Clock

11

14

CSB

SPI Chip Select

8

10

LED1

4

7

LED2

18

1

K1

27

2

K2

22

3

Table 3-1 Driver Board and Raspberry Pi Pin Definitions

3.1.2 wiringpi Library Installation

sudo apt-get install wiringpi
wget https://project-downloads.drogon.net/wiringpi-latest.deb

Upgrade Raspberry Pi 4B Version:

sudo dpkg -i wiringpi-latest.deb
gpio -v

If version 2.52 appears, it indicates that the installation has been successful.

  • For the Bullseye branch system, use the following command:
git clone https://github.com/WiringPi/WiringPi
cd WiringPi
. /build
gpio -v

Running "gpio -v" will show version 2.70. If it doesn't appear, it means there is an installation error.

If an error message "ImportError: No module named 'wiringpi'" appears when running a sample program in Python version, run the following command:

  • For Python 2.x version
    pip install wiringpi
  • For Python 3.x version
    pip3 install wiringpi

Note: If the installation fails, you can try the following compiled installation.

git clone --recursive 
https://github.com/WiringPi/WiringPi-Python.git

Note: The --recursive option can automatically pull submodules. Otherwise, you need to download them manually.

Enter the newly downloaded WiringPi-Python folder and use the following commands to compile and install:

  • For Python 2.x version
sudo python setup.py install
  • For Python 3.x version
sudo python3 setup.py install

If the following error occurs:

In this case, enter the command sudo apt install swig to install SWIG. After completing the installation, run sudo python3 setup.py install to compile and install. If you see similar information, it indicates that the installation was successful.

3.1.3 lgpio Library Installation

For the Bookworm system, the example programs use the lgpio library. The installation command for this library is:

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

3.1.4 Enable the SPI Interface

sudo raspi-config

Enable the SPI Interface:

Interfacing Options->SPI->Yes

Check the enabled SPI devices:

ls /dev/spi*

This will print: "/dev/spidev0.0" and "/dev/spidev0.1"

3.1.5 Python Library Installation

The example program uses the Python 3 environment. To run the Python example program, you need to install the PIL, numpy, and spidev libraries. Enter the following commands to install them:

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

3.1.6 C Version Example

Using the lgpio library as an example, navigate to the /demo codes/raspberry_pi/lgpio/c directory:

sudo make clean
sudo make
sudo ./main

After entering the above commands, you can observe the e-paper display.

3.1.7 Python Version Example

Using the lgpio library as an example, navigate to the /demo codes/raspberry_pi/lgpio/python directory.

sudo python3 gui_demo.py

After entering the above commands, you can observe the e-paper display.

3.2 Arduino Example Usage

3.2.1 Hardware Interface Configuration

Table 3-2 shows the wiring definitions between the Arduino Mega and the e-paper display:

E-paper Interface

Arduino Mega

VCC

5V

GND

GND

CS

D53

CLK

D52

MOSI

D51

DC

D8

RST

D9

BUSY

D10

Table 3-2 E-paper Display and Arduino Mega Pin Definitions

The following diagram shows the wiring diagram between the Arduino Mega and the ink screen:

Table 3-3 E-paper Display and Arduino UNO Pin Definitions:

E-paper Interface

Arduino UNO

VCC

5V

GND

GND

CS

D7

CLK

D13

MOSI

D11

DC

D10

RST

D9

BUSY

D8

Table 3-3 E-paper Display and Arduino UNO Pin Definitions

The following diagram shows the wiring diagram between the Arduino UNO and the ink screen:

3.2.2 Example Usage

Open the project file /demo codes/Arduino_MEGA/Arduino_MEGA.ino or /demo codes/Arduino_UNO/Arduino_UNO.ino in the Arduino IDE. Select the correct Board and Port based on your setup. Click Verify, and once the verification is successful, upload it to the module. Observe the e-paper display.

Note: Due to the small memory resources of Arduino, when using Arduino related routines, it is not possible to refresh and display multiple pictures at the same time, please refresh as few pictures as possible, and use as few font types as possible at the same time when using the GUI display in the routine, otherwise there will be a prompt that the memory is exceeded.

3.3 STM32 Example Usage

The example code is based on STM32F103RBT6.

3.3.1 Hardware Interface Configuration

E-paper Interface

STM32 Interface

VCC

3.3V

GND

GND

CS

PB12

CLK

PB13

MOSI

PB15

DC

PA8

RST

PA11

BUSY

PA12

Table 3-4 E-paper Display and STM32 Pin Definitions

The following diagram shows the wiring diagram between STM32 and the ink screen:

3.3.2 Example Usage

Open the example in the directory /demo codes/STM32 using Keil uVision5 software. After compiling without errors, download it to the module and observe the e-paper display.

3.4ESP32 Example Usage

The example program uses the ESP32 module ESP32-WROOM-32E.Model of the board in the IDE:NodeMCU-32S

E-paper Interface

ESP32 Interface

VCC

3.3V

GND

GND

CS

IO27

CLK

IO18

MOSI

IO23

DC

IO14

RST

IO33

BUSY

IO13

Table 3-5 E-paper Display and ESP32 Pin Definitions

The following figure shows the wiring diagram between ESP32 and the ink screen:

3.4.1 Example Usage

Open the project file /demo codes/Arduino_ESP32 using the Arduino IDE. Select the correct Board and Port based on your setup. Click Verify, and once the verification is successful, upload it to the module and observe the e-paper display.

3.5 Image Creation and Mode Extraction

3.5.1 Image Creation

The screen supports 4 kinds of color display.They are black,white,red and yellow.The above 4 colors are standard colors.You can actually refer to the color table of the drawing software.When making pictures,you need to make a picture with 296x128 resolution into a bitmap that only contains black,white,red and yellow 4 colors.And save the picture in BMP or JPG format.

3.5.2 Mode Extraction

You can use the Image2Lcd software for mode extraction. This software is provided in the compressed package. To achieve the effect shown in Figure 3-2, follow the mode extraction parameter settings as shown in Figure 3-3:

1. Open the image that needs to be extracted;

2. Output data type: Select "C language array (*.c)".

3. Scanning method: Select "Vertical Scanning";

4. Output grayscale: select "4 gray";

5. Maximum width and height: Select "296" and "128", and click the arrow behind to confirm;

6. As shown in the figure below, only the third item is checked;

7. "Color Inversion" does not need to be checked;

8. Click "Save" to save the converted array to a file with the extension ".c", and the 296x128 resolution image will generate a 9472 byte image array;

9. Finally, replace the corresponding array in the example program code with the array from the ".c" file.

Picture Impression Explanation:

In the Image2Lcd software, when the grayscale output is set to "4 Grayscale", the corresponding relationship is as follows:

The original color of the picture

Converted color

Red

Dark gray

Yellow

Light gray

Black

Black

White

White

As mentioned in point 8 above, a picture with a resolution of 296x128 will generate an image array with a size of 9472 bytes, that is, 9472x8=75776bit, and the actual ink screen has 296x128=37888 pixels.It can be known that one pixel is represented by 2 bits (75776/37888 = 2).

In the Image2Lcd software, the corresponding relationship between the converted colors and the 2-bit

binary code is as shown in the following table:

The original color of the picture

Converted color

Binary representation of the converted color in the Image2Lcd software

Red

Dark gray

10

Yellow

Light gray

01

Black

Black

11

White

White

00

In the ink screen, the representation of the four colors of black, white, red and yellow is different from the representation in the Image2Lcd software.

The color representation in the ink screen and its corresponding relationship with 2-bit

binary is as shown in the following table:

The colors displayed on the ink screen

2 binary numbers that should be written to the ink screen

White

01

Yellow

10

Red

11

Black

00

From the above table, it can be seen that the 9472-byte array obtained from the converted image in the Image2Lcd software cannot be directly written to the ink screen.It needs to be converted. The following figure is the conversion relationship between the array generated by Image2Lcd and the data written to the ink screen:

After the above conversion, the binary number of the original image converted in the Image2Lcd software is replaced by the binary number corresponding to the color of the original image in the ink screen.

When a byte is passed in, take 0xF5 as an example:

0xF5 -> 11 11 01 01

Every two digits of it do the "&" operation with 0x03 (0000 0011). According to the operation result to determine the color, the following table is the corresponding relationship between the operation result and the color:

The original color of the picture

Converted binary numbers in Image2Lcd software

"&" operation result

Result substitution

The color of the result of the substitution is the corresponding in the ink screen

Black

11

11

00

Black

B