Source: https://mokxi.com/learn/arduino-e-paper-display

Learn

# An e-paper display on an Arduino: a shelf price tag

Intermediate

Written by the Mokxi team

Start building free Open the editor

Or see every lesson.

- 455 parts on the bench
- 43 boards running now
- 1.00x real time, on every board

Press Run, wait for the refresh, then press the button

The Shelf label example: a 2.9 inch SSD1680 panel with GxEPD2. Wait for the full refresh, then press the button for a partial one.

E-paper (also called e-ink) is the screen in e-readers and electronic shelf labels. It looks like printed paper, reads well in sunlight, and keeps its picture with the power off, so a label can show a price for years on a coin cell. The catch is speed: a full refresh takes seconds.

The circuit above is an Uno driving a 2.9 inch, 296 by 128 pixel e-paper panel with the GxEPD2 library, as the price tag on a shop shelf. It draws the label once with a full refresh, then puts the panel to sleep. Press the button and it marks the price down with a quick partial refresh of the price alone. Press Run and give it about six seconds.

## What you need

- An Arduino Uno
- A 2.9 inch SPI e-paper module, 296x128, SSD1680 (such as Waveshare’s)
- A pushbutton
- A breadboard and jumper wires

## Wiring

Part and pin | Goes to | Note

e-paper VCC | 3.3 V | The panel runs on 2.2 to 3.7 V

e-paper GND | GND |

e-paper SDA (DIN) | Pin 11 | SPI data (MOSI)

e-paper SCL (CLK) | Pin 13 | SPI clock

e-paper CS | Pin 10 |

e-paper DC | Pin 9 | Command or data

e-paper RES (RST) | Pin 8 |

e-paper BUSY | Pin 7 | High while the panel refreshes

Button | Pin 2 and GND | INPUT_PULLUP, so pressed reads LOW

## How e-paper works

Inside the panel are millions of tiny capsules of black and white particles with opposite charges. A voltage across a pixel pulls the black ones to the top or the white ones, and they stay there when the voltage goes away. That is why the picture lasts with no power, and why changing it takes a while: the particles have to move.

The panel has its own controller, here an SSD1680, with memory for the picture. The Arduino writes the new picture into that memory over SPI, then tells the controller to refresh. While the refresh runs, the controller holds its BUSY pin high, and it ignores what you send.

## The sketch

The display is set up with GxEPD2_290_BS(10, 9, 8, 7): CS, DC, RES and BUSY. GxEPD2 draws with the Adafruit GFX calls, inside a firstPage() / nextPage() loop. Then hibernate() puts the controller into deep sleep, where it draws nothing, and the picture stays on the glass.

Watch the serial monitor and the timing. The label takes about six seconds from Run: nearly three to draw the picture and send it, then about three for the full refresh, with BUSY high. Then "label drawn". Press the button and the price changes from $4.99 to $2.99 with a partial refresh that takes about 0.3 seconds, and the serial monitor says "marked down". Press again for "full price".

The shelf label sketch

## Why it draws in pages

A full picture for this panel is 128 x 296 / 8 = 4,736 bytes, one bit a pixel. The Uno has 2,048 bytes of RAM in all, so the picture cannot be held at once. GxEPD2’s answer is paging: it keeps a buffer for a strip of the screen, runs your drawing code once for each strip, and sends each strip as it is done.

The two lines at the top of the sketch size that buffer to 800 bytes, which for this panel is 50 rows. 296 rows in strips of 50 is six strips, so the code inside the do ... while (display.nextPage()) loop runs six times. That is why everything you draw has to be inside the loop, and why it must draw the same thing every time around.

On an ESP32, with plenty of RAM, you can give the template the full height and the loop runs once.

## Full and partial refresh

A full refresh drives every pixel through black and white a few times, which is the flashing you see on a real panel. It takes about three seconds here and clears any ghost of the old picture. A partial refresh changes only a window, here the price, without the flashing, in about 0.3 seconds.

Partial refreshes leave faint ghosts behind over time, so real products do a full refresh every so often, say every few dozen partial ones. And refreshing every second is a bad idea: it is slow, and a panel’s life is counted in refreshes. E-paper suits things that change now and then: a price, the weather, a to-do list.

## Common mistakes

BUSY not connected. The Uno cannot tell when the panel is done, so it sends its next commands into a refresh that is still running, and the panel ignores them. Pull the BUSY wire in the circuit above: the serial monitor still says "label drawn", but the glass stays blank.

The wrong panel class. GxEPD2 has a class for each panel and controller (GxEPD2_290_BS, GxEPD2_290_T94_V2 and many more). The wrong one gives a blank, noisy or half-drawn screen. Match the class to the back of your panel.

Drawing outside the page loop, or drawing something different each pass. Every pass must draw the whole picture.

Powering it from 5 V. The panel is a 3.3 V part. Waveshare’s module boards say they take 3.3 V or 5 V logic; a bare panel on a plain adapter wants 3.3 V on every pin.

Leaving it awake. Call hibernate() after each refresh; the picture stays, and the panel draws almost nothing.

## Questions

Which library should I use for an e-paper display?

GxEPD2, by Jean-Marc Zingg. It supports most Waveshare and Good Display panels, draws with Adafruit GFX calls, and handles paging on boards with little RAM like the Uno.

Does an e-paper display need power to keep the picture?

No. The particles stay where they were put, so the picture stays with the power off. Power is only needed to change it.

How long does an e-paper refresh take?

A full refresh takes about three seconds on a 2.9 inch panel like this one; a partial refresh about 0.3 seconds. Color panels with red or yellow take much longer, 15 seconds or more.

Why is my e-paper display not updating?

Check BUSY first, then that the panel class matches your panel, then the SPI wires. A wrong class is the most common reason for a blank panel.

Related

## Keep going

SPI Explained: Clock, Data and Chip Select Arduino ST7735: 1.8 Inch Color TFT Wiring and Code Arduino OLED Display (SSD1306) Tutorial Arduino Nokia 5110 LCD: Wiring, Contrast and Code How the 2.9 inch e-paper panel is modeled The Shelf label project Intermediate The Arduino Uno simulator The project page, with the full sketch Intermediate

## Build this for real

Open the editor, change a value and watch the number move with it. Nothing to install, and no account needed.

Start building free Open the editor
