Example Code for Arduino-Display Image and Characters
Last revision 2026/01/12
Display an image (DFRobot logo) and text (website URL) on the 2.13” e-ink display. Users will learn how to use the GxEPD library to draw bitmaps and display text on the e-ink module.
Hardware Preparation
- ESP32 e-Ink Display (SKU: DFR0676) x 1
- Micro USB cable x 1
Software Preparation
- Arduino IDE
- Download and install the GxEPD Library (follow library installation guide)
- Download and install the Adafruit-GFX-Library
Connection
Connect the ESP32 e-ink display module to your computer using a Micro USB cable.
Other Preparation Work
- Install the ESP32 board driver in Arduino IDE (follow steps from Reference).
- Ensure the required libraries (GxEPD, Adafruit-GFX) are installed.
Sample Code
// include library, include base class, make path known
#include <GxEPD.h>
#include "SD.h"
#include "SPI.h"
//Since there are multiple versions of the screen, if there is a flower screen after downloading the program, please test the following four header files again!
#include <GxDEPG0213BN/GxDEPG0213BN.h>
//#include <GxGDE0213B1/GxGDE0213B1.h> // 2.13" b/w
//#include <GxGDEH0213B72/GxGDEH0213B72.h> // 2.13" b/w new panel
//#include <GxGDEH0213B73/GxGDEH0213B73.h> // 2.13" b/w newer panel
int bmpWidth = 232, bmpHeight = 52;
//width:150,height:39
const unsigned char DFRobot[] = {0x00,0x00,0x00,0x7C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x7E,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFE,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFE,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7E,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x7C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x38,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x38,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x38,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x38,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x7C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0xFF,
0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0F,0xFF,0xE0,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x78,0x00,0x3F,0xFF,0xF8,0x00,0x3C,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0xFC,0x00,0x7F,0xFF,0xFE,0x00,0x7E,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0xFE,0x01,0xFF,0xFF,0xFF,0x00,0x7F,0x00,0x00,0x7F,0xFE,0x00,0x1F,0xFF,0xFE,0x7F,
0xFF,0x80,0x3F,0xFF,0x03,0xFF,0xFC,0x01,0xFF,0xF8,0x3F,0xFF,0xFC,0xFE,0x07,0xFF,
0xFF,0xFF,0xC0,0xFF,0x00,0x00,0x7F,0xFF,0xF0,0x1F,0xFF,0xFF,0x7F,0xFF,0xF1,0xFF,
0xFF,0xE3,0xFF,0xFF,0x0F,0xFF,0xFF,0x7F,0xFF,0xFC,0xFF,0x9F,0xFF,0xFF,0xFF,0xF3,
0xFE,0x00,0x00,0x7F,0xFF,0xFC,0x1F,0xFF,0xFF,0x7F,0xFF,0xF1,0xFF,0xFF,0xF3,0xFF,
0xFF,0x9F,0xFF,0xFF,0x7F,0xFF,0xFC,0x7F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFC,0x00,0x00,
0x7F,0xFF,0xFE,0x1F,0xFF,0xFF,0x7F,0xFF,0xF3,0xFF,0xFF,0xF3,0xFF,0xFF,0x9F,0xFF,
0xFF,0x7F,0xFF,0xFC,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E3,0xC0,0x00,0xF3,0xC0,0x07,0x9E,0x00,0x07,0x80,0x3C,0x00,0x00,0x7F,0xFF,0xFF,
0xFF,0xFE,0x00,0x00,0x00,0x7F,0x00,0x3F,0x9F,0xFF,0xF8,0x78,0x3E,0x03,0xC0,0x00,
0xF3,0xC0,0x07,0x9E,0x00,0x07,0x80,0x3C,0x00,0x00,0x60,0x00,0x00,0x00,0x0E,0x00,
0x00,0x00,0x7E,0x00,0xFF,0x9F,0x80,0x00,0x78,0x1F,0x03,0xC0,0x00,0xF3,0xC0,0x07,
0x9E,0x00,0x07,0x80,0x3C,0x00,0x00,0x6F,0xFF,0xFF,0xFF,0xEE,0x00,0x00,0x00,0x7F,
0xFF,0xFF,0x1F,0xC0,0x00,0x78,0x0F,0x83,0xC0,0x00,0xF3,0xC0,0x07,0x9E,0x00,0x07,
0x80,0x3C,0x00,0x00,0x6F,0xFF,0xFF,0xFF,0xEE,0x00,0x00,0x00,0x7F,0xFF,0xFF,0x1F,
0xC0,0x00,0x78,0x07,0xC3,0xC0,0x00,0xF3,0xC0,0x07,0x9E,0x00,0x07,0x80,0x3C,0x00,
0x00,0x6C,0x00,0x00,0x00,0x6E,0x00,0x00,0x00,0x7F,0xFF,0xFE,0x1F,0xC0,0x00,0x78,
0x03,0xE3,0xFF,0xFF,0xF3,0xFF,0xFF,0x9F,0xFF,0xFF,0x00,0x3C,0x00,0x00,0x6C,0x00,
0x00,0x00,0x6E,0x00,0x00,0x00,0x7F,0xFF,0xFC,0x1F,0xC0,0x00,0x78,0x01,0xF9,0xFF,
0xFF,0xF3,0xFF,0xFF,0x9F,0xFF,0xFF,0x00,0x3C,0x00,0x00,0x6C,0x00,0x00,0x00,0x6E,
0x00,0x00,0x00,0x7F,0xFF,0xF0,0x1F,0xC0,0x00,0x78,0x00,0xFD,0xFF,0xFF,0xE3,0xFF,
0xFF,0x0F,0xFF,0xFF,0x00,0x3C,0x00,0x00,0x6E,0x00,0x00,0x00,0xEE,0x00,0x00,0x00,
0x7F,0xFE,0x00,0x1F,0xC0,0x00,0x78,0x00,0x7C,0x3F,0xFF,0x03,0xFF,0xF8,0x03,0xFF,
0xF8,0x00,0x38,0x00,0x00,0x67,0xC0,0x00,0x07,0xCE,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x70,0xF8,0x00,0x3E,0x1E,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7E,
0x1F,0x01,0xF0,0xFE,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7F,0xC3,0xFF,0x87,
0xFE,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7F,0xF8,0x3C,0x3F,0xFE,0x00,0x00,
0x00,0x7E,0x7E,0xD0,0xBF,0x0F,0xD8,0x9F,0x83,0xEC,0x5F,0xB1,0x7F,0x7E,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x7F,0xFF,0x81,0xFF,0xFC,0x00,0x00,0x00,0x7F,0x7E,
0xD9,0xBF,0x0F,0xD8,0x9F,0x83,0xEC,0x5F,0xB1,0x7F,0x7E,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x3F,0xFF,0xFF,0xFF,0xFC,0x00,0x00,0x00,0x63,0x62,0xD9,0xA0,0x03,
0x1F,0x90,0x02,0x0C,0x46,0x31,0x63,0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x1F,0xFF,0xFF,0xFF,0xF0,0x00,0x00,0x00,0x63,0x7E,0xCF,0x3E,0x03,0x1F,0x9F,0x03,
0xCC,0x46,0x31,0x7F,0x78,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0xFF,0xFF,
0xFF,0xC0,0x00,0x00,0x00,0x63,0x6C,0xCF,0x30,0x03,0x18,0x98,0x03,0xCC,0x46,0x21,
0x6E,0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0xFF,0xFF,0xFF,0x80,0x00,
0x00,0x00,0x7F,0x66,0xC6,0x3F,0x03,0x18,0x9F,0x83,0x0F,0xC6,0x3F,0x63,0x7E,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFE,0x00,0x00,0x00,0x00,0x7C,
0x62,0xC6,0x3F,0x03,0x18,0x9F,0x82,0x07,0xC6,0x1F,0x61,0x7E,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x3F,0xFF,0xF8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x0F,0xFF,0xE0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,
0xFF,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0xFF,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7C,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00};
// FreeFonts from Adafruit_GFX
#include <Fonts/FreeMonoBold9pt7b.h>
#include <Fonts/FreeMonoBold12pt7b.h>
#include <Fonts/FreeMonoBold18pt7b.h>
#include <Fonts/FreeMonoBold24pt7b.h>
#include <GxIO/GxIO_SPI/GxIO_SPI.h>
#include <GxIO/GxIO.h>
#define SPI_MOSI 23
#define SPI_MISO -1
#define SPI_CLK 18
#define ELINK_SS 5
#define ELINK_BUSY 4
#define ELINK_RESET 16
#define ELINK_DC 17
#define SDCARD_SS 13
#define SDCARD_CLK 14
#define SDCARD_MOSI 15
#define SDCARD_MISO 2
#define BUTTON_PIN 39
GxIO_Class io(SPI, /*CS=5*/ ELINK_SS, /*DC=*/ ELINK_DC, /*RST=*/ ELINK_RESET);
GxEPD_Class display(io, /*RST=*/ ELINK_RESET, /*BUSY=*/ ELINK_BUSY);
SPIClass sdSPI(VSPI);
const char *Website = "www.dfrobot.com";
bool sdOK = false;
int startX = 9, startY = 20;
void setup()
{
Serial.begin(115200);
Serial.println();
Serial.println("setup");
SPI.begin(SPI_CLK, SPI_MISO, SPI_MOSI, ELINK_SS);
display.init(); // enable diagnostic output on Serial
display.setRotation(1);
display.fillScreen(GxEPD_WHITE);
display.setTextColor(GxEPD_BLACK);
display.setFont(&FreeMonoBold12pt7b);
display.setCursor(0, 0);
sdSPI.begin(SDCARD_CLK, SDCARD_MISO, SDCARD_MOSI, SDCARD_SS);
if (!SD.begin(SDCARD_SS, sdSPI)){
sdOK = false;
} else {
sdOK = true;
}
display.fillScreen(GxEPD_WHITE);
display.drawBitmap(DFRobot, startX, startY, bmpWidth, bmpHeight, GxEPD_BLACK);
display.setCursor(20,95);
display.println(Website);
display.setTextColor(GxEPD_BLACK);
display.update();
// goto sleep
esp_sleep_enable_ext0_wakeup((gpio_num_t)BUTTON_PIN, LOW);
esp_deep_sleep_start();
}
void loop()
{
}
Result
Was this article helpful?
