ESP32-8048S050 (Sunton 5.0” / CYD) Config

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

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: 270
    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-8048S050.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-50-test-device
  friendly_name: Sunton 5.0 Test Device

packages:
  common: !include templates/common.yaml
  device: !include templates/ESP32-8048S050.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

1 Like

Thanks for posting these. Do you have a git repo someplace with all this stuff in it?

1 Like

You’re very welcome!

I’m planning to create a Git repo with all of the configs I use and some simple LVGL examples that work with them, as well as a few other neat things I’ve been doing thanks to the Packages feature.

I’m currently trying to get the 3.5" Elecrow CrowPanel working and once that’s good to go I think I’ll start the Git repo.

I don’t know how many more of these ESP devices I’ll end up with but I found it difficult to find working configs for most of them so I wanted to make sure it was easier for others than it was for me. I also felt that it was important to separate out the bits of the config that are actually for the device vs all the other things that people tend to share in theirs which muddy the waters and make things seem more daunting than they need to be.

2 Likes

I uploaded my project on GitHub :slightly_smiling_face:

Hope it helps in some way or another!

Nice I like your setup a lot. I have been working to build a modular code base that would be easy to use for setting up info and control screens.

This is what I have so far.

It’s not nearly as clean as your code but it has a few more features. I also have support for two screens that you don’t have.

Very cool, thanks for sharing. Definitely some things I can learn in there. I haven’t played with many widgets beyond buttons in my setup yet. I had a lot going on when I was on OpenHASP but since switching to ESPHome it’s been more about optimizing the yaml than actually making widgets.

How do you like the Guition ESP32-S3-4848S040 square screen? I have something similar (https://www.aliexpress.com/item/1005007582119640.html) in my AliExpress cart. I really think I would love the square format. Just not sure which one of the few I’ve found to take a chance on.

Edit: Just realized I’ve seen your thread on it (and probably your repo) before! hah

I really like that 480x480 screen. It has a back plate with 3 relays in it you can use to control lights. Also I like that fact that the case is already done. You can mount it’s backplate in the wall then pop on the screen. Very clean for lighting control. You can see more about it here.