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

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