A few weeks ago, I got my hands on a 7.5" e-paper display from Waveshare, which cost me $65. Typically, such displays cost about $500 (display, driver board, accessories, etc.). So, the Waveshare display, despite its low resolution, was a bargain. I connected the display to a $5 ESP-WROOM-32 development board to build a low-cost prototype e-reader for PDF documents.

Hardware setup

The following schematic outlines the electrical connections between the MCU and the display:

Circuit diagram

The VCC and GND pins of the display are connected to the 3V3 and GND pins of the MCU.

The white button, responsible for switching the e-reader on and off, connects GPIO15 of the ESP32 to its 3V3 pin via a 10k resistor. The yellow and blue buttons, used for turning pages, connect GPIO21 and GPIO22 to GND.

Getting the PDF ready

To use the e-reader, first, execute the pdftoebm.py script on a computer that has Poppler (for PDF processing) and ImageMagick installed to convert the PDF document to a bitmap:

$ python -m pdftoebm -o <output_path> <pdf_document>

Then, upload the resulting a.ebm file to the HTTP server pointed to by the EBM_ARCH_URL in the Kconfig.projbuild file. If the HTTP server requires TLS, run the following command to obtain the root certificate for the server and replace the contents of the cert.pem file with the last certificate in the chain of certificates:

$ openssl s_client -showcerts -connect <hostname>:443 </dev/null

The Espressif SDK for ESP32 requires secure HTTP connections by default. If your server does not support TLS, switch this setting off in the SDK configuration (by running the idf.py menuconfig command) to bypass the TLS requirement, and remove references to the cert.pem file in the main.c file.

Finally, build and upload the program to the ESP32 by issuing the command idf.py build flash.

How does it work?

The pdftpebm.py script converts each page of the PDF to a monochrome image of the same size and resolution as the display. For an 800x480 display, it arranges the PDF pages as a series of 48KB bitmaps in the a.ebm file.

When the ESP32 starts up, it connects to WiFi (requires a 2.4GHz access point) and downloads the first three 48KB blocks of the a.ebm file using the HTTP Range header. These 144KB correspond to the first three pages of the document.

Whenever the user presses the yellow or blue button, the e-reader transfers the relevant page from DMA-capable memory in the MCU to the display over SPI while downloading another page from the HTTP server.

Finally, when the user presses the white button, ESP32 shuts down all its systems except the RTC module and enters a state of deep sleep. When the user presses the white button again, the e-reader wakes up from deep sleep and restores pages based on the reading progress found in RTC memory.

Files: source.tar.gz