One of Waveshare's many beautiful development boards, programmed here with the fast LovyanGFX library — starting with a simple "Hello World" sketch.
Waveshare offers several beautiful development boards, including this one. I bought the version without battery and without touch control. It features a 240 × 240 pixel display, and there are three buttons on the board: GPIO 0 (flash), GPIO 5 (pwr) and GPIO 4 (key). All three buttons can be used in a sketch.
As you can see in the photo, I created a relatively complex sketch for this circuit board (home energy management). The LovyanGFX.hpp graphics library is well suited for rendering fast sprites on screen. However, figuring out the correct display settings turned out to be quite a journey. That's why we'll stick to a simple "Hello World" sketch here.
/*
* Hello World – Waveshare ESP32-S3-LCD-1.54 (240×240, ST7789, IPS)
* Library : LovyanGFX
* Board : ESP32S3 Dev Module
* USB CDC On Boot: Enabled
*
* Confirmed pins:
* MOSI → 39 | SCLK → 38 | DC → 45 | CS → 21 | RST → 40 | BL → 46
*/
#define LGFX_USE_V1
#include <LovyanGFX.hpp>
class LGFX : public lgfx::LGFX_Device {
lgfx::Panel_ST7789 _panel;
lgfx::Bus_SPI _bus;
lgfx::Light_PWM _light;
public:
LGFX(void) {
{
auto cfg = _bus.config();
cfg.spi_host = SPI2_HOST;
cfg.spi_mode = 0;
cfg.freq_write = 40000000;
cfg.freq_read = 16000000;
cfg.spi_3wire = true;
cfg.use_lock = true;
cfg.dma_channel = SPI_DMA_CH_AUTO;
cfg.pin_sclk = 38;
cfg.pin_mosi = 39;
cfg.pin_miso = -1;
cfg.pin_dc = 45;
_bus.config(cfg);
_panel.setBus(&_bus);
}
{
auto cfg = _panel.config();
cfg.pin_cs = 21;
cfg.pin_rst = 40;
cfg.pin_busy = -1;
cfg.panel_width = 240;
cfg.panel_height = 240;
cfg.offset_x = 0;
cfg.offset_y = 0;
cfg.offset_rotation = 0;
cfg.dummy_read_pixel = 8;
cfg.dummy_read_bits = 1;
cfg.readable = false;
cfg.invert = true; // IPS panel
cfg.rgb_order = false;
cfg.dlen_16bit = false;
cfg.bus_shared = false;
_panel.config(cfg);
}
{
auto cfg = _light.config();
cfg.pin_bl = 46;
cfg.invert = false;
cfg.freq = 44100;
cfg.pwm_channel = 7;
_light.config(cfg);
_panel.setLight(&_light);
}
setPanel(&_panel);
}
};
LGFX display;
void setup(void) {
Serial.begin(115200);
display.init();
display.setRotation(0);
display.setBrightness(255);
display.fillScreen(TFT_BLACK);
display.setTextDatum(MC_DATUM);
display.setFont(&fonts::FreeSansBold12pt7b);
display.setTextColor(TFT_YELLOW);
display.drawString("ESP32-S3", display.width() / 2, 55);
display.setFont(&fonts::FreeSansBold18pt7b);
display.setTextColor(TFT_CYAN);
display.drawString("Hello", display.width() / 2, 110);
display.setFont(&fonts::FreeSansBold18pt7b);
display.setTextColor(TFT_GREEN);
display.drawString("World!", display.width() / 2, 150);
display.setFont(&fonts::Font2);
display.setTextColor(TFT_LIGHTGREY);
display.drawString("LovyanGFX 240x240", display.width() / 2, 200);
display.drawRoundRect(10, 10, display.width() - 20, display.height() - 20, 12, TFT_DARKGREY);
Serial.println("Ready.");
}
void loop(void) {}
Curious about other displays? Check out the full overview, including TM1637, SSD1306, SH1106, ST7735, ST7789, e-paper, the Lilygo TTGO T-Display and T-Display S3. See also the more elaborate energy management project on this Waveshare board, with live P1 meter data.