ESP32-8048S043 (Sunton 4.3” / CYD) Config

Just wanted to share a basic working config for this device (ESP32-8048S043) :slight_smile:

Heads-up: I try to keep the configs in these posts updated but sometimes the configs in my repo are more up-to-date!

Here are the device-specific bits of the config separated out from everything else:

esphome:
  platformio_options:
    build_flags: "-DBOARD_HAS_PSRAM"
    board_build.esp-idf.memory_type: qio_opi
    board_build.flash_mode: dio
    board_upload.maximum_ram_size: 524288

esp32:
  board: esp32-s3-devkitc-1
  variant: esp32s3
  flash_size: 16MB
  framework:
    type: esp-idf
    # these versions prevent artifacting
    version: 5.1.2
    platform_version: 6.5.0
    # Required to achieve sufficient PSRAM bandwidth
    sdkconfig_options:
      COMPILER_OPTIMIZATION_SIZE: y
      CONFIG_ESP32S3_DEFAULT_CPU_FREQ_240: y
      CONFIG_ESP32S3_DATA_CACHE_64KB: y
      CONFIG_ESP32S3_DATA_CACHE_LINE_64B: y
      CONFIG_SPIRAM_FETCH_INSTRUCTIONS: y
      CONFIG_SPIRAM_RODATA: y
      CONFIG_ESPTOOLPY_FLASHSIZE_16MB: y # fix warning about 2mb found

psram:
  mode: octal
  speed: 80MHz

output:
  - id: gpio_backlight_pwm
    platform: ledc
    pin: 2
    frequency: 1220

light:
  - id: backlight
    name: Backlight
    platform: monochromatic
    output: gpio_backlight_pwm
    restore_mode: ALWAYS_ON

display:
  - platform: rpi_dpi_rgb
    update_interval: never
    auto_clear_enabled: false
    color_order: RGB
    rotation: 90
    dimensions:
      width: 800
      height: 480
    de_pin: 40
    hsync_pin: 39
    vsync_pin: 41
    pclk_pin: 42
    pclk_inverted: true
    pclk_frequency: 14MHz # unsure about this
    hsync_front_porch: 8
    hsync_pulse_width: 4
    hsync_back_porch: 8
    vsync_front_porch: 8
    vsync_pulse_width: 4
    vsync_back_porch: 8
    data_pins:
      red: [45, 48, 47, 21, 14]
      green: [5, 6, 7, 15, 16, 4]
      blue: [8, 3, 46, 9, 1]

i2c:
  sda: 19
  scl: 20
  scan: true

touchscreen:
  platform: gt911
  address: 0x5D
  update_interval: 16ms

I like to keep device-specific code like that its own file separate from everything else so that I can use the Packages component to import it into multiple relevant projects, rather than duplicate the whole thing into each one. In my case I save it into a file called templates/ESP32-8048S043.yaml.

In the spirit of not duplicating code into multiple projects, I create another file that is not device-specific but is common/repetitive among all my projects. In my case I chose to call it templates/common.yaml and it has code like so:

esphome:
  name: "${device_name}"
  friendly_name: "${friendly_name}"

logger:
  level: INFO

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password

web_server:
  port: 80

ota:
  - platform: esphome

api:

Finally, this is how I use both of the above files together in a project.:

substitutions:
  device_name: sunton-43-test-device
  friendly_name: Sunton 4.3 Test Device

packages:
  common: !include templates/common.yaml
  device: !include templates/ESP32-8048S043.yaml
  # dashboard: !include templates/dashboard_800x480.yaml

#sensor: ...

Note: The contents of the dashboard package referenced above aren’t in this post but I have it in the example to illustrate the power of setting up a config this way. In my case templates/dashboard_800x480.yaml is a file that I’ve created with HA sensors and LVGL pages in it, and it can be reused on any of my devices that support the same resolution as this one.

If someone wants to help get this device listed on devices.esphome.io then be my guest! I was too lazy to dig into that but hopefully posting here is just as helpful.

Concerns / Potential Improvements

  • I suspect the framerate could be improved but I am not sure if that’s related to this config or not, and it’s only noticeable if you have animations or widgets that requrie scrolling.

More in my GitHub repo

2 Likes