🛠 Controlling GPIO and e-paper display

M5Stack PaperDIY Assembly Kit (ESP32-S3) · debutant · Apprenez à manipuler les broches GPIO et à afficher du texte sur l'écran e-paper du Kit PaperDIY avec l'ESP32-S3.

Objectifs

This tutorial guides you through discovering digital inputs/outputs (GPIO) and displaying text on the ED047TC1 e-paper display of your M5Stack PaperDIY kit. You will learn to configure a pin as an output to control an external peripheral (or an internal LED if available) and initialize the display to write text. This kit, featuring the ESP32-S3-WROOM-1-N16R8 module, offers great flexibility with its 16 MB of flash and 8 MB of PSRAM, ideal for managing complex e-paper display buffers.

Matériel nécessaire

Étapes

Open the Arduino IDE. Go to File > Preferences and add the M5Stack board manager URL: https://m5stack.oss-cn-shenzhen.aliyuncs.com/resource/arduino/package_m5stack_index.json. Once added, go to Tools > Board > Boards Manager, search for M5Stack, and install the M5Stack package.

  1. Environment Preparation

In the IDE, select M5Stack > M5Paper as the board type. Select the corresponding serial port. The ESP32-S3 module uses a specific architecture; ensure compilation options (Partition Scheme) are default to optimize the 16 MB flash usage.

  1. Project Configuration

Go to Sketch > Include Library > Manage Libraries. Search for and install the M5GFX library, which drives the ED047TC1 screen via the 8-bit parallel interface. Also install M5Unified for simplified management of common peripherals.

  1. Library Installation

Create a new sketch and paste the following code. This code initializes the system, configures a GPIO pin as output (simulating control), and displays text on the e-paper screen.

  1. Test Code Writing
#include <M5Unified.h>

void setup() {
  M5.begin();
  // Initialize e-paper display
  M5.Display.init();
  M5.Display.fillScreen(WHITE);
  M5.Display.setCursor(10, 10);
  M5.Display.setTextSize(2);
  M5.Display.print("Hello PaperDIY!");
  // Screen update (required for e-paper)
  M5.Display.update();
  
  // Configure a GPIO pin as output (generic example)
  // Use a free pin not used by display or SD
  pinMode(2, OUTPUT); 
}

void loop() {
  // Empty loop for this static example
  delay(1000);
}

Click the Upload button. Once finished, observe the screen. The text should appear black on a white background. Note that the e-paper screen does not refresh continuously like an LCD; the update() call is crucial to send data to the electronic ink pixels.

  1. Upload and Execution

Vérification

Verify that the text "Hello PaperDIY!" is displayed on the 4.7-inch screen (960x540 pixels). If the screen remains white, check USB connections and ensure the correct serial port is selected. Ensure the 140 mAh battery is correctly connected if you unplug USB, as the M5PM1 chip manages low-power consumption.

Pour aller plus loin

Explore the 16 gray levels offered by the ED047TC1 screen using M5.Display.setBrightness() or gradients. Try reading the state of a physical button connected to a GPIO pin using digitalRead() to interact with the display. WiFi 4 and Bluetooth 5.0 LE connectivity can then be enabled to send data remotely.

Other tutorials for this board

Code examples for this board

← Back to the board 🛠 All tutorials