Skip to content

Instantly share code, notes, and snippets.

@clydebarrow
Created November 20, 2024 23:46
Show Gist options
  • Save clydebarrow/2bb1472f5185dd0a39f84988a54f93e6 to your computer and use it in GitHub Desktop.
Save clydebarrow/2bb1472f5185dd0a39f84988a54f93e6 to your computer and use it in GitHub Desktop.
Sample ESPHome config for Waveshare 7 ESP32 Display
# For Waveshare 7" ESP32 board.
substitutions:
friendly_name: Waveshare 7
esphome:
name: wave-7
friendly_name: ${friendly_name}
platformio_options:
build_unflags: -Werror=all
board_build.flash_mode: dio
esp32:
board: esp32-s3-devkitc-1
framework:
type: esp-idf
platform_version: 6.8.1
version: 5.3.0
sdkconfig_options:
CONFIG_ESP32S3_DEFAULT_CPU_FREQ_240: "y"
CONFIG_ESP32S3_DATA_CACHE_64KB: "y"
CONFIG_SPIRAM_FETCH_INSTRUCTIONS: y
CONFIG_SPIRAM_RODATA: y
api:
encryption:
key: !secret encryption_key
logger:
hardware_uart: UART0
wifi: !include wifi.yaml
ota:
platform: esphome
password: !secret ota_password
ch422g:
psram:
mode: octal
speed: 80MHz
output:
- platform: ledc
id: backlight_output
pin: 13
frequency: 1220Hz
inverted: true
# Note: this requires a hardware modification to work - GPIO 13 must be connected to the backlight PWM pad.
light:
- platform: monochromatic
output: backlight_output
name: LCD Backlight
id: lcd_backlight
restore_mode: ALWAYS_ON
default_transition_length: 0s
gamma_correct: 1.8
effects:
- pulse:
i2c:
sda: 8
scl: 9
frequency: 400kHz
scan: false
id: bus_a
button:
- platform: safe_mode
name: Safe Mode Boot
entity_category: diagnostic
touchscreen:
- platform: gt911
address: 0x5D
id: my_touchscreen
interrupt_pin: 4
reset_pin:
ch422g:
number: 1
display:
- platform: rpi_dpi_rgb
id: rpi_disp
#update_interval: never
#rotation: 90
auto_clear_enabled: false
color_order: RGB
pclk_frequency: 16MHz
dimensions:
width: 800
height: 480
reset_pin:
ch422g:
number: 3
enable_pin:
ch422g:
number: 2
de_pin:
number: 5
hsync_pin:
number: 46
ignore_strapping_warning: true
vsync_pin:
number: 3
ignore_strapping_warning: true
pclk_pin: 7
pclk_inverted: true
# 7" 800x480 params
hsync_back_porch: 8
hsync_front_porch: 8
hsync_pulse_width: 4
vsync_back_porch: 16
vsync_front_porch: 16
vsync_pulse_width: 4
# 5" 1024x600 params
# hsync_back_porch: 188
# hsync_front_porch: 44
# hsync_pulse_width: 88
# vsync_back_porch: 16
# vsync_front_porch: 3
# vsync_pulse_width: 6
# 4.3" 800x480 params
# hsync_back_porch: 8
# hsync_front_porch: 8
# hsync_pulse_width: 4
# vsync_back_porch: 16
# vsync_front_porch: 16
# vsync_pulse_width: 4
data_pins:
red:
- 1 #r3
- 2 #r4
- 42 #r5
- 41 #r6
- 40 #r7
blue:
- 14 #b3
- 38 #b4
- 18 #b5
- 17 #b6
- 10 #b7
green:
- 39 #g2
- 0 #g3
- 45 #g4
- 48 #g5
- 47 #g6
- 21 #g7
lvgl:
@TangoOversway
Copy link

You left a link to this on the ESPHome forum. I figured asking questions about this file itself is best done here.

A few questions - sure to have more later!

1 - It looks like this is a basic setup to just turn the screen on. I still have almost everything to learn about actually displaying anything on the screen. (I'm going to start with text, but hope to include graphics at some point.) Am I right that this config does not include actually putting anything up on the screen?

2 - The Light section - is that only for backlighting? I'd rather not start making pin and hardware mods until I have it working and am more familiar with the hardware involved. If I just want to test it out and make sure it's working, while I'm learning how to put text and/or graphics on the screen, do I need to make that extra connection?

(Just for reference, at this point, I'm not using the screen for any touch input - just for display. I may want to add touch later, though.)

@clydebarrow
Copy link
Author

The config as is will display a "hello world" example on the screen. The light section is for backlighting so you can skip that to begin with (won't do any harm though if included and you haven't done the very simple hardware mod.)

@TangoOversway
Copy link

Just where is it set to display, "Hello World?" I don't see that in the code. Is it a default startup screen?

@clydebarrow
Copy link
Author

Yes. Just run it and see.

@TangoOversway
Copy link

Ah - got it. I ran into a few issues I want to make note of - for anyone reading this in the future who may have as limited a background in this as I do!

1 - I had problems with things downloading and was warned about the version from the start, so I had to comment out the platform_version and the version info in the esp32: section.
2 - I have been using the arduino framework and that won't work because this uses things not available in that framework. (Or at least not available without something I am not doing or don't know about.) So use the esp-idf framework.
3 - Since I haven't used the esp-idf before, it took about 21 minutes, total, to compile. That included downloading a lot of libraries and compiling a lot of object code.

@TangoOversway
Copy link

I see the need to connect GPIO 13 from the ESP32 to the backlight pin. I think we also discussed that on the ESPHome forum, but I can't find the thread where it came up. Where is the backlight PWM pad?

@clydebarrow
Copy link
Author

So it's the same board, and it does have a pad for dimming as per the pics in the wiki.

I'll delete the previous comments to avoid confusion.

Screenshot 2025-01-15 at 4 59 59 AM

@TangoOversway
Copy link

I found the issue that was causing me confusion in the configs - I was merging this one and the one in the thread on the ESPHome discussion and ended up with 2 ON/OFF controls (the dimmer had an ON/OFF included).

I did something a bit different for the soldering. It's been a good while since I did a lot of soldering, so I wanted to do things the easiest way I could. The thread you linked to with the brightness adjustment included a post about using one of the included connectors, plugging it into the RS485 connection, then soldering the black (data) wire to the pad you referenced. I'm including an image, using bright green (for visibility) of what I did.
IMG_3233 2

@bwze
Copy link

bwze commented Apr 9, 2025

@clydebarrow, I'm using your code above on a 4.3" variant of this board. I commented out the 7" and uncommented the 4.3" stuff and compiled with no issues. After flashing with ESPHome Flasher 1.4, I don't see anything on the screen. On the back, if plugged into the USB port, there is one Power LED on (two LEDs if plugged into the UART port) and I can see the backlight is on too or at least I think it's the backlight at the bottom edge of the display.

I'm not quite sure of the proper flashing process but holding down the BOOT button while powering on and then releasing allows me to flash but I'm not sure what to do afterwards.

Any idea what I may be doing wrong here?

@bwze
Copy link

bwze commented Apr 9, 2025

Nevermind.....it was the ESPHome Flasher v1.4. I just tied ESPHome Web and it flashed correctly.

@bwze
Copy link

bwze commented Apr 9, 2025

Any idea if the 4.3" version can be dimmed like the 7"?

@clydebarrow
Copy link
Author

Any idea if the 4.3" version can be dimmed like the 7"?

Yes. There is an unmarked pad that should be wired to a GPIO, e.g. GPIO11 which is used for the SD card. It looks like R7 needs to be populated with a 30K resistor (the value won't be critical, 33K should work fine.)

Quick Camera Image 2025-04-10 at 7 57 18 AM

Screenshot 2025-04-10 at 7 57 09 AM

@bwze
Copy link

bwze commented Apr 10, 2025

I've altered my config file to use GPIO11 on the ESP32 and soldered a wire from GPIO11 to the solder pad. I also added a 30K resisitor at, what I assume to be, R7 (lower right in your image).

After flashing, the screen will turn off but the device will reboot if I try to turn it on again.

Here is my code: https://pastebin.com/ifPc6U2X

@clydebarrow
Copy link
Author

It works for me, but you commented out important bits, like the inverted setting on the output. Also, you will need to replace R6 (currently 0R, next to R7) with another value - I used 3K3 but 2K7 might be better. And change the light gamma to 1.0.

@bwze
Copy link

bwze commented Apr 10, 2025

That did it @clydebarrow .....thanks. Backlight LED is now responding correctly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment