hello-ecran.ino
The case's first screen hit: text, 16-bit colors and drawing primitives through the M5Stack library. The dashboard is ready — just plug sensors in.
Hardware required
An M5Stack Core Basic/Gray (ESP32 in an enclosure with a 320×240 TFT, A/B/C buttons, speaker, microSD slot, 110 mAh battery). None: the screen is in the case.
Wiring
No wiring. Power over USB-C (or the internal 110 mAh battery). The backlight goes off with M5.Lcd.setBrightness(0).
How it works
M5.begin initializes screen, buttons, buses and power; the ILI9341 driver draws into a partial framebuffer and printf/writeDirect avoid String allocations. In the Arduino IDE (esp32 package), board « M5Stack-Core-ESP32 »; install the « M5Stack » (or M5Unified) library from the Library Manager, then Upload.
Going further
Draw level bars for sensors, or show the NTP time from the dedicated sketch.
hello-ecran.ino
// Hello TFT ILI9341 — bibliotheque « M5Stack » (Gestionnaire de bibliotheques).
#include <M5Stack.h>
void setup() {
M5.begin();
M5.Lcd.fillScreen(TFT_BLACK);
M5.Lcd.setTextColor(TFT_YELLOW, TFT_BLACK);
M5.Lcd.setCursor(10, 10);
M5.Lcd.setTextSize(3);
M5.Lcd.println("M5Stack OK");
M5.Lcd.setTextSize(1);
M5.Lcd.setTextColor(TFT_WHITE);
M5.Lcd.drawRect(5, 5, 310, 230, TFT_DARKGREY);
}
void loop() {
M5.Lcd.setCursor(10, 90);
M5.Lcd.printf("millis : %8lu\n", millis());
M5.Lcd.printf("heap : %8u o\n", ESP.getFreeHeap());
M5.Lcd.printf("rssi : %5d dBm\n", WiFi.Rssi());
delay(250);
}