🛠 Afficher du texte sur l'écran 135×240

M5StickC Plus2 (M5Stack) — ESP32-PICO-V3-02 "stick" wearable kit (SKU K016-P2) · debutant · Schéma : IMG-m5stack-stick-c-plus-2-debutant-1-m5stick-c2-afficher-texte.svg — M5StickC Plus2 orange vu de face, écran 1,14" affichant des lignes de texte vertes, flèches vers l'écran ST7789 et les boutons A et B.

Objectives

Discover the 1.14" 135×240 screen (ST7789V2 controller, SPI: MOSI=G15, CLK=G13, DC=G14, RST=G12, CS=G5, backlight G27) of the M5StickC Plus2 and display your first lines of text using the M5Unified library, the officially recommended library (the old M5StickCPlus2.h is marked Deprecated by M5Stack).

Hardware

Complete code

// M5StickC Plus2 — hello écran (M5Unified + M5GFX depuis le gestionnaire de libraries)
#include <M5Unified.h>

void setup {
  auto cfg = M5.config;
  M5.begin(cfg);                      // init ST7789V2 135x240 (broches officielles)
  M5.Display.setRotation(1);          // paysage : 240 x 135
  M5.Display.fillScreen(TFT_BLACK);
  M5.Display.setTextColor(TFT_GREEN, TFT_BLACK);
  M5.Display.setTextSize(2);
  M5.Display.setCursor(4, 4);
  M5.Display.println("StickC Plus2");
  M5.Display.setTextSize(1);
  M5.Display.setTextColor(TFT_WHITE, TFT_BLACK);
  M5.Display.printf("Flash: %u MB\n", (unsigned)(ESP.getFlashChipSize / 1048576));
  M5.Display.printf("PSRAM: %s\n", psramFound ? "2 MB OK" : "absente");
}

void loop {
  M5.update;
  M5.Display.setCursor(4, 110);
  M5.Display.printf("millis = %lu ", (unsigned long)millis);
  vTaskDelay(100 / portTICK_PERIOD_MS);
}

Expected verification

Upon power-up, the screen displays "StickC Plus2" in green, followed by "Flash: 8 MB" and "PSRAM: 2 MB OK"; a millis line scrolls at the bottom. The device powers on by holding the C button for more than 2 seconds (revision v2, without PMIC AXP192).

Common errors

Other tutorials for this board

Code examples for this board

← Back to the board 🛠 All tutorials