Skip to content

abcbbck-png/ESP32-4848S040-First-Start

Repository files navigation

ESP32-4848S040 First Start

PlatformIO ESP32-S3 LVGL License

A complete ready-to-use starter project for the ESP32-S3 4.0" 480×480 RGB LCD development board (ESP32-4848S040). Built with ESP-IDF framework for maximum performance and flexibility. Includes properly configured display driver, touch support, and LVGL 9 demo UI.

Demo Preview Demo Preview

Features

  • ESP-IDF — Native framework without Arduino abstraction for optimal performance
  • ST7701S RGB Display — 480×480 16-bit color, 60Hz refresh
  • GT911 Capacitive Touch — Touch I2C controller
  • LVGL 9 — Modern embedded GUI library
  • PWM Backlight Control — Smooth brightness adjustment via slider
  • Runtime Timing Adjustment — UART console for display tuning without recompilation
  • Persistent Settings — NVS storage for timing parameters
  • Clean Architecture — Modular source files, easy to extend

Hardware

Component Specification
MCU ESP32-S3-WROOM-1U-N16R8
Flash 16MB QIO @ 80MHz
PSRAM 8MB Octal @ 80MHz
Display 4.0" IPS LCD, 480×480, RGB565
Display Driver ST7701S (3-wire SPI init + RGB interface)
Touch Controller GT911 (I2C @ 400kHz)
Backlight PWM controlled (GPIO38)

Pin Mapping

Click to expand pinout

RGB Data Bus:

Signal GPIO
R0-R4 11, 12, 13, 14, 0
G0-G5 8, 20, 3, 46, 9, 10
B0-B4 4, 5, 6, 7, 15

Control Signals:

Signal GPIO
DE 18
VSYNC 17
HSYNC 16
PCLK 21

3-Wire SPI (ST7701S Init):

Signal GPIO
CS 39
SCK 48
SDA 47

Touch (I2C):

Signal GPIO
SDA 19
SCL 45

Backlight:

Signal GPIO
PWM 38

Quick Start

Prerequisites

Build & Flash

# Clone the repository
git clone https://github.com/abcbbck-png/ESP32-4848S040-First-Start.git
cd ESP32-4848S040-First-Start

# Build the project
pio run

# Upload to device
pio run -t upload

# Monitor serial output
pio device monitor

Or use the PlatformIO sidebar in VS Code: BuildUploadMonitor

Project Structure

├── src/
│   ├── main.c              # Application entry, LVGL task
│   ├── display.c/h         # ST7701S RGB panel driver
│   ├── touch.c/h           # GT911 touch driver
│   ├── backlight.c/h       # PWM backlight control
│   ├── ui.c/h              # LVGL demo interface
│   ├── timing_config.c/h   # NVS-backed timing parameters
│   ├── uart_console.c/h    # Runtime timing adjustment
│   └── board_config.h      # Hardware pin definitions
├── managed_components/     # ESP Component Registry deps
│   ├── espressif__esp_lcd_st7701/
│   ├── espressif__esp_lcd_touch_gt911/
│   └── lvgl__lvgl/
├── platformio.ini          # Build configuration
├── sdkconfig.defaults      # ESP-IDF defaults
├── partitions.csv          # Flash partition table
└── lv_conf.h               # LVGL configuration

UART Console Commands

Connect at 115200 baud to adjust display timing on-the-fly:

Command Description
help Show available commands
timing Display current timing values
hbp <value> Set HSYNC back porch (shift LEFT +) → save & reboot
hfp <value> Set HSYNC front porch → save & reboot
hpw <value> Set HSYNC pulse width → save & reboot
vbp <value> Set VSYNC back porch (shift UP +) → save & reboot
vfp <value> Set VSYNC front porch → save & reboot
vpw <value> Set VSYNC pulse width → save & reboot
reset Reset to defaults & reboot

Tip: If you see horizontal shifting or tearing, try adjusting porch values. The default configuration (all zeros) works for most panels.

Configuration

Display Timing

Edit board_config.h for compile-time defaults:

#define LCD_HSYNC_BACK_PORCH    0
#define LCD_HSYNC_FRONT_PORCH   0
#define LCD_VSYNC_BACK_PORCH    0
#define LCD_VSYNC_FRONT_PORCH   0

LVGL Settings

Key settings in lv_conf.h:

#define LV_COLOR_DEPTH          16
#define LV_USE_DRAW_SW          1
#define LV_DRAW_BUF_STRIDE_ALIGN 4

Build Configuration

Adjust in platformio.ini:

board_build.f_cpu = 240000000L
board_upload.flash_size = 16MB
board_build.flash_mode = qio

Using as a Base Project

Recommended workflow for building your own application:

  1. Replace the UI — Modify src/ui.c with your own screens and logic
  2. Add custom modules — Create new .c/.h files in src/ and register them in src/CMakeLists.txt
  3. Add ESP-IDF components — Declare new dependencies in src/idf_component.yml
  4. SDK-level settings — Configure only via sdkconfig.defaults (avoid editing sdkconfig directly)

The project structure is intentionally modular — display, touch, and backlight drivers are decoupled from application logic.

Resources

License

This project is licensed under the MIT License — see the LICENSE file for details.


Made with ❤️ for the ESP32 community

About

A complete ready-to-use starter project for the ESP32-S3 4.0" 480×480 RGB LCD development board (ESP32-4848S040)

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages