Difference between revisions of "2.13inch e-Paper HAT (B)"

From Waveshare Wiki
Jump to: navigation, search
Line 215: Line 215:
=== Documentation ===
=== Documentation ===
{{Commom Instruction of SPI e-paper}}
{{Commom Instruction of SPI e-paper}}
* [[:File:2.13inch-e-paper-hat-b-schematic.pdf|Schematic]]
* [[:File:2.13inch_e-Paper_HAT_Schematic.pdf|Schematic]]
=== Demo code ===
=== Demo code ===

Revision as of 11:07, 15 October 2018

2.13inch e-Paper (B)

212x104, 2.13inch E-Ink display raw panel
2.13inch e-Paper HAT (B)
2.13inch-e-paper-hat-b-5 1.jpg

212x104, 2.13inch E-Ink display HAT for Raspberry Pi, three-color, SPI interface



Primary Attribute
Category: OLEDs / LCDs, LCD
{{{userDefinedInfo}}}: {{{userdefinedvalue}}}
Brand: Waveshare
English: Waveshare website
Chinese: 官方中文站点
Onboard Interfaces
Related Products


Note: The raw panel require a driver board, If you are the first time use this e-Paper, we recommend you to buy the HAT version or buy more one driver hat for easy use, otherwise you need to make the driver board yourself. And this instruction is based on the version with PCB or driver board.

212x104, 2.13inch E-Ink display HAT for Raspberry Pi, three-color, SPI interface



VCC 3.3V
CS SPI chip select (Low active)
DC Data/Command control pin (High for data, and low for command)
RST External reset pin (Low for reset)
BUSY Busy state output pin (Low for busy)

Working principle


This product is an E-paper device adopting the image display technology of Microencapsulated Electrophoretic Display, MED. The initial approach is to create tiny spheres, in which the charged color pigments are suspending in the transparent oil and would move depending on the electronic charge. The E-paper screen display patterns by reflecting the ambient light, so it has no background light requirement. Under sunshine, the E-paper screen still has high visibility with a wide viewing angle of 180 degree. It is the ideal choice for E-reading.

Communication protocol

SPI timing

Note: Different from the traditional SPI protocol, the data line from the slave to the master is hidden since the device only has display requirement.

  • CS is slave chip select, when CS is low, the chip is enabled.
  • DC is data/command control pin, when DC = 0, write command, when DC = 1, write data.
  • SCLK is the SPI communication clock.
  • SDIN is the data line from the master to the slave in SPI communication.

SPI communication has data transfer timing, which is combined by CPHA and CPOL.

  1. CPOL determines the level of the serial synchronous clock at idle state. When CPOL = 0, the level is Low. However, CPOL has little effect to the transmission.
  2. CPHA determines whether data is collected at the first clock edge or at the second clock edge of serial synchronous clock; when CPHL = 0, data is collected at the first clock edge.
  • There are 4 SPI communication modes. SPI0 is commonly used, in which CPHL = 0, CPOL = 0.

As you can see from the figure above, data transmission starts at the first falling edge of SCLK, and 8 bits of data are transferred in one clock cycle. In here, SPI0 is in used, and data is transferred by bits, MSB first.

How to use

Working with Raspberry Pi

Installing libraries required

If you want to connect your E-paper screen to Raspberry Pi, you should install some necessary libraries, or else the Demo (click to download) below may work improperly. For more information about how to install the Raspberry Pi libraries, please visit the website: Libraries Installation for RPi.

You can find the detailed presentation about the installations of libraries wiringPi, bcm2835 and python.

Hardware connection

Here is the connection between Raspberry Pi 3B and E-paper.

e-Paper Raspberry Pi 3B
3.3V 3.3V
DC Pin22/GPIO25
RST Pin11/GPIO17

Expected result

1) After the corresponding libraries installed, you can copy the relative programs into your Raspberry Pi, and then enter the corresponding file.

  • BCM2835: Execute the command: make, to compile the code and generate a file epd. Execute the command: sudo ./epd, the program will run.
  • WringPi: Execute the command: make, to compile the code and generate a file epd. Execute the command: sudo ./epd, the program will run.
  • Python: Execute the command: sudo python main.py

2) Image will be displayed on the screen.

  • Note:The refresh rate of this module is slow, and it will flicker for several times during refreshing (about 15s). Please be patient.

Working with Arduino

Hardware connection

e-Paper UNO PLUS (3.3V)
3.3V 3V3
CS D10

Expected result

  1. Copy the libraries file of Arduino demo code to the libraries folder which is under the installation directory of Arduino IDE, it usually is C:\users\username\documents\arduino\libraries. You can also designate the location on Arduino IDE--> File -->Preferences -->Sketchbook location
  2. Upload the project.
  3. E-paper will display the image.


  • The refresh rate of this module is slow, and it will flicker for several times during refreshing (about 15s). Please be patient.
  • The RAM of Arduino UNO is only 2K. However, it need at least 10K storage space for completely update one frame and couldn’t refresh partially (That is, unable to completely update one frame by refreshing partial of it for several times). So the Arduino example we provide can only displaying static image.

Working with the STM32 development board

  • Here we use STM32F103ZE development board.
  • The demo code is based on HAL, so you can port the demo code to other STM board with STM32CubeMX.
  • The demo code can be compiled successfully in Keil v5

Hardware connection

Connecting to the STM32F103ZE:

e-Paper STM32F103ZE
3.3V 3V3

Expected result

  1. Open the project (epd-demo.uvprojx), which is under the MDK-ARM directory.
  2. Click Build to compile the project.
  3. Click Download to load the code to your board.
  • Reset, the screen will display image.
    Note: The refresh rate of this module is slow, and it will flicker for several times during refreshing (about 15s). Please be patient.

Code analysis

Here, we will analyze the driving code and take the demos for Raspberry Pi based on WiringPi library as examples.

Hardware interface function

The functions of drive code like DigitalWrite, DigitalRead, SendCommand, SenData and DelayMs call the interface functions which are provided by hardware device (epdif.h, epdif.c, epdif.cpp) to respectively implements the functions that Control IO Level, Read IO Level, Send SPI Command, Send SPI Data and Delay For Millisecond. If you want to port the demo code, you need to implement all the interfaces of epdif (e-paper display interface) according to the corresponding hardware device.

Note that Raspberry Pi uses hardware chip select while transmitting SPI data. So we needn’t set the CS pin to LOW before transmitting data, and the code will set it automatically while transmitting. However, for Arduino and STM32, etc. you need to explicitly set the CS pin to LOW with codes to start the SPI transmission of module.

Send Commands and Data (SendCommand and SendData)

SendCommand and SendData are used to send commands and data to module respectively. What the difference between them is that, D/C pin is set to LOW for sending commands and HIGH for sending data. If the D/C pin is LOW, the data transmitted from SPI interface to module will be recognized as commands and executed. If the D/C pin is HIGH, the data will be recognized as normal data. Generally, normal data will follow the command, works as parameter or image data.

Reset (Reset)

Module will reset if RST pin is LOW. It is used to restart the module after powered on or awakened. After restarting, you need to initialize module with initialization function (Init) for working properly.

Initialization (Init)

After powering on the module, initialization function (Init) will configure the parameters of module. It can also wake up module from sleep mode. Process of initialization: :reset --> booster soft start --> power on --> panel setting --> VCOM and data interval setting --> resolution setting.

Display a Frame (DisplayFrame)

DisplayFrame is used to send a frame to module, and the screen will refresh and display it.

Process: Send command data start transmission 1 --> Send data of black area --> Send command data start transmission 2 --> Send data of red area --> Refresh the screen.


  • One frame consist of images of black area and red area, so we need to send two images for displaying one frame,
  • 1 byte = 8 pixels, doesn’t support Gray scale (can only display black and white). A bit set stands for a white pixel, otherwise a bit reset stands for black/red.

For example:

0xC3:8 pixels □□■■■■□□
0x00:8 pixels ■■■■■■■■
0xFF:8 pixels □□□□□□□□
0x66:8 pixels ■□□■■□□■
  • This module doesn’t support partial refresh.
  • The refresh rate of this module is slow, and it will flicker for several times during refreshing (about 15s). Please be patient.

Sleep mode (Sleep)

Sleep can make the module go into sleep mode to reduce the consumption.

Process: power off --> deep sleep

If you want to wake up the module from sleep mode, you need to give a LOW pulse to RST pin. Then maybe you need to reconfigure the parameter of power (According to the batches, some of them need to reconfigure, some needn’t). So if you want to wake up module, you had better use the Init function instead of Reset. Reset function and relative commands will be executed while executing the Init function.

How to display an image

There are two ways to display pictures. One is display directly and other is indirectly.

Display directly: Read the data of pictures with library functions, and decode. Then convert it to arrays and send to module. About how to implement it, you can refer to the python examples of Raspberry Pi. (The C demo doesn’t display pictures directly)

Display indirectly: Converting pictures to relative arrays on PC and save as c file. Then you can use the c file on your project. This chapter we will talk about how to convert a picture to array.

  1. Open a picture with drawing tool comes with Windows system, create a new image, and set the pixel to 104x212.
  2. Because this module can only display two gray level (Only black and white), we need to convert picture to monochrome bitmap before converting it to array. That is, File --> BMP picture --> Monochrome Bitmap.
    There are two monochrome bitmap on examples pack, which are used for demonstration (raspberrypi/python/black.bmp and raspberrypi/python/red.bmp).
  3. Use Image2Lcd.exe software to generate corresponding array for picture (.c file). Open picture with this software, set the parameters:
    • Output data type: C language array
    • Scanning mode: vertical scanning
    • Output gray: single color (gray level of two)
    • Maximum width and height: 104 and 212
    • Include the data of Image Header: Don’t check
    • Inverse color: Check (Check: the white on image will be inversed to 1, and black is inversed to 0)
  4. Click “Save”, to generate .c file. Copy the corresponding array into your project, and you can display picture by calling this array.



Demo code



Working requirements of e-Paper?
  • Two-color B/W e-paper
    • 【Working】Temperature: 0~50°C; Humidity: 35%~65%RH
    • 【Storage】Temperature: ≤30°C; Humidity: ≤55%RH; Max storage time: 6 months
    • 【Transport】Temperature: -25~70°C; Max transport time: 10 days
    • 【Unpack】Temperature: 20°C±5°C; Humidity: 50%RH±5%RH; Max storage time: Should be assembled in 72h
  • Three-Color e-Paper
    • 【Working】Temperature: 0~40°C; Humidity: 35%~65%RH
    • 【Storage】Temperature: ≤30°C; Humidity: ≤55%RH; Max storage time: 3 months
    • 【Transport】Temperature: -25~60°C; Max transport time: 10 days
    • 【Unpack】Temperature: 20°C±5°C; Humidity: 50%RH±5%RH; Max storage time: Should be assembled in 72h

When store three-color e-Paper, please refresh it to white, and keep the screen upward. Note that you need to update it at least every three months.

What do you need to note about e-Paper refreshing?
  • Refresh mode
    • Full refresh: e-Paper flicker when full refreshing to remove ghost image for best display.
    • Partial refresh: It don't flicker if you use partial refresh (only some of the two-color e-paper support partial refresh). Note that you cannot use Partial refresh all the time, you should full refresh e-paper regularly, otherwise, ghost problem will get worse even damage.
  • Refresh rate
    • When using, you should set the update interval at least 180s.(except Partial supportable types)
    • Please set the e-Paper to sleep mode or power off it directly, otherwise, the e-Paper is damaged because of working in high voltage for long time.
    • You need to update the content of three-color e-Paper at least one time every 24h to avoid from burn-in problem.
  • Working place
  • We recommend you to use the e-Paper indoor. If you need to set the e-paper outdoor, Please place the e-paper in shadow and protect it from UV. When you designed you e-paper product, you should take care about the working situation like temperature, humidity, etc.

How much could the flexible e-paper be bended
  • The IC part of e-Paper cannot be bended, you can bend the display area in degree larger than 60°C

Why the e-Paper cant work with Arduino?

The I/O level of Arduino is 5V, and the e-Paper should be driven with 3V3. If your Arduino cant drive the e-Paper successfully, please try to convert the level to 3.3V

You can also try to connect the Vcc pin to the 5V of Arduino to see whether the e-Paper works, but we recommend you not to use 5V for a long time.

Why does the color of e-Paper look a little black or grey?

You can try to change the value of Vcom on demo codes.

Three-color e-paper looks more red/yellow than the picture on website?

Because of different batch, some of them have aberration. Store the e-Paper right side up will reduce it. And if the e-Paper didn't be refreshed for long time, it will become more and more red/yellow. Please use the demo code to refresh the e-paper for several times in this case.

Why my e-paper has ghosting problem after working for some days

Please set the e-paper to sleep mode or disconnect it if you needn't refresh the e-paper but need to power on your development board or Raspberry Pi for long time.Otherwise, the voltage of panel keeps high and it will damage the panel

Why the FPC of the e-Paper is broken after using for some times?
Please make sure you have used it in correct way.

E-Paper FAQ FPC.jpg


Mail.png Contact your seller (fast response and most recommended)

or send emails to [email protected] (not fast enough but please be patient) for help.

Our working time: 09:00-18:00 (UTC+8 Monday to Saturday)