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

4 Likes

Thank you for sharing your work, Ryan. I was looking for such a solution to kick-start my project. Did you try to hook up external sensors to the screen using I2C? I was thinking about Temp/Gas sensor like BME680/688 to have an environmental sensor with display for my 3D-Printer booth. I thought it would be possible to realize this using openHASP, but according to some older GitHub discussion it does not seem to be that easy.

Glad this is of some use to you! Unfortunately I haven’t tried adding any sensors to any of the devices I own. I am planning to add some basic buttons / momentary switches, but haven’t had time to even play with those.

Hey man. Well, an interesting side note on a similar 4.3 CYD. The Guition 4.3 4827S043
…gave me a bit of a headache. Couldn’t get the screen layout to work. This has the funky 480x272 layout. Man …I tried so many things. Spent a day and a half…getting to the point of messing with pin assignments, looking at the tech guides AliExpress was good enough to actually provide. Well …finally…I think I have it solved.
Set it to 480x320 :roll_eyes:. Yep…thats really all it is. Now, I may have changed something else along the way …I still need to do an AOA report lol. I save a manual Bin file, factory version, after each change just in case. At times, I would lose IP and have to flash the next time via the ESPHome web tool. Then… I’d get IP back. But …just thought that was kinda funny. Maybe the driver library just really doesn’t like that 272? All I have right now is a title bar and text but … I made sure to have the title bar as just a boarder. Wanted to see the lines on each end and…they are there.
But…for the most part …seems like your pin assignments are working just fine. :grinning:
Cheers