How to display pictures on a remote screen? The project combines two devices and rely on open source tools.
- A remote device with an e-ink display connected to an IoT-capable board to receive and display the pictures.
- A control device running an MQTT broker to send the pictures.
Compared to the previous Remote e-Paper Messages Panel project, the Remote e-Paper Pictures Panel doesn't rely on proprietary protocols and infrastructures.
Instead, it uses the lightweight MQTT protocol and the broker can be hosted in any local PC or even a single-board computer (SBC). MQTT relies on the TCP/IP stack. The images are prepared and formatted on the PC to require minimal processing on the remote device.
Pervasive Displays offers a wide range of e-paper screens, from 1.54" up to 12.2", in black-and-white or black-white-red versions, as well as the Pervasive Displays Extension Kit Gen 3, a universal driver board.
The e-paper screens act like a sheet of paper: they only need power during the printing of the text or image. Once the text or image has been printed, the screens no longer need power. They can even be detached: the text or image stays on! A more detailed presentation explains How e-paper works.
Apart from the low power and the persistent display, the e-paper screens offer high readability even in direct sunlight and high resolution up to 130 dpi, 117 dpi on the 2.71" panel used on this project.
Espressif has revolutionised IoT with the affordable and powerful ESP8266 and ESP32 SoCs.
Remote deviceThe remote device consists on the ESP32-DevKitC or ESP32-Pico board, the Pervasive Displays Extension Kit Gen 3 board and a Pervasive Displays e-ink display.
Hardware
For the hardware part, proceed as follow:
- Attach the screen flat cable to the 24-way connector to the Pervasive Displays Extension Kit Gen 3 board.
- Set the jumper to the ≤4.37" position on the Pervasive Displays Extension Kit Gen 3 board.
- Connect the signals 1 to 10 of the Pervasive Displays Extension Kit Gen 3 board to the breadboard with the ESP32 board as shown below. I recommend using the provided cable or a 10-way flat cable with the standard electronic colours.
The e-paper screen requires an external frame-buffer, stored in SRAM. The size of the screen is thus limited by the SRAM available on the ESP32 board, about 128 kB from total of 520 kB. The project here uses a 2.71" monochrome screen.
Software
The application relies on two main libraries:
- The excellent PubSubClient library by Nick O'Leary provides all the features for an MQTT client.
The buffer size is 256 bytes by default, and so needs to be adjusted with setBufferSize() to handle the header and the image. Here, it is set to 6 kB for the 2.71" panel used.
// MQTT
myMQTT.setBufferSize(6144);
myMQTT.setServer(myBrokerIP, 1883);
myMQTT.setCallback(callbackMQTT);
- The PDLS_EXT3_Basic or PDLS_EXT3_Basic_Fast library manages the e-paper screen.
#include "PDLS_EXT3_Basic_Fast.h"
Screen_EPD_EXT3_Fast myScreen(eScreen_EPD_EXT3_271_Fast, boardESP32DevKitC);
All the credentials are stored in a separate header file.
const char* mySSID = "<SSID name>";
const char* myPassword = "<SSID password>";
const char* myBrokerIP = "<MQTT broker IP";
Main deviceThe main device can be any PC or single-board computer (SBC). It hosts the image converter and the MQTT broker. Both are used in command-line mode through the terminal.
Convert the picture
The images native formats are not optimised for IoT. A typical 264x176 BMP image weights 136 kB. Since the e-paper screen is monochrome, the images are going to be translated into the portable bitmap (PBM) format.
The header of the converted image features P4 as magic number and the size of the screen, here 176 horizontal pixels by 264 vertical pixels.
P4
176 264
To do so, the project uses GraphicsMagick, a command-line utility to convert virtually any format into portable bitmap. A converted 264x176 image weights less than 6 kB in PBM format.
To install GraphicsMagick on Linux, run
sudo apt-get install imagemagick
MQTT broker
The project uses Mosquitto as MQTT broker. It comes with useful utilities to publish and subscribe topics.
Recent releases of Mosquitto require a specific configuration to allow external and anonymous connections. Just edit the file /etc/mosquitto/mosquitto.conf and add the three lines below.
listener 1883
protocol mqtt
allow_anonymous true
Run the projectThere are two steps to send a picture to the remote e-paper display.
Convert the picture
First, gm convertsthe picture into the portable bitmap format with the following options;
$
gm convert IMAGE1.BMP -resize 264x176 -rotate 90 PBM:IMAGE1.PBM
- -resize ensures the right dimensions,
- -rotate ensures the right orientation,
- PBM: sets the format.
Send the picture
Then, mosquitto_pub sends the image, with the following options:
$
mosquitto_pub -h 127.0.0.1 -t image/show -f IMAGE1.PBM
- -h 127.0.0.1 defines the IP address of the broker and can be omitted for local host,
- -t image/show sets the topic,
- -f IMAGE1.PBM sends the file of the portable bitmap image.
Finally, the ESP32 receives and displays the image.
Other options
The image/clear topic clears the screen
Going furtherFor a cleaner interface, Node-RED provides a nice dashboard to encapsulate the command-line procedure. The Image button opens a dialogue box to select an image. The Send button is then enabled and sends the image through MQTT.
Pervasive Displays offers a wide range of screens, monochrome and black-white-red, from 1.54" up to 12.2". Larger screens may require an external memory like an SPI SRAM on the Pervasive Displays e-Paper EPD Extension Kit Gen 3 or a PSRAM available on some advanced ESP32 boards. The project hasn't been tested with the black-white-red option.
The MQTT solution is widely used and offers advanced features like quality of service (QoS).
The WiFi radio is power-hungry and obliterates the low-power capabilities of the e-paper screen. So changing for a radio like Bluetooth or sub-1 GHz would enable a year-long autonomy with standard batteries, albeit with a different protocol like MQTT-SN.
Comments