Waveshare ESP32 S3 7" LCD Touch Screen - Using GPIO pins that may be pre-assigned

I’ve set up a Waveshare ESP32 S3 7" LCD touch screen so I can display information on it and control the dimming and turn it on and off. Now I want to gain access to 4 GPIO pins to use with PWM to control fans. (Access to more than 4 pins would be nice - but at least 4.) I know a lot of other people here are using this screen, so I’m hoping someone can help me with this.

I’m looking at 4 pinn:

  • GPIO06 - Connects to sensors, not used for anything else, available on the sensor interface plug
  • GPIO15 - Part of the RS485 connection, on the RS485 connector. I’m using GPIO16, which is the other pin on the RS485, for dimming the display. (The wire is soldered to a pad on the board.)
  • GPIO19 and GPIO20 - both are on the USB connector. I’m testing them by plugging in a USB-C cable (male to male) and using a breakout board on the other end.

I power my unit by a USB cable plugged into the UART1 socket (also a USB-C connector). I’m using a simple, cheap oscilloscope to check for PWM output on these pins. I’ve included the YAML file at the end of this post.

I get a PWM signal on GPIO06, but I do not see one on pins 15, 19, and 20. I’m wondering if I have to deactivate something or include something about the USB or RS485 info in the config.

Is there something I have to do to gain access to pins 15, 19, and 20 for use as “normal” GPIO pins? Is it something I can do in my YAML file? I’m hoping it doesn’t requires a hardware mod, since I’m testing on a screen I’m using for something else and I don’t want to buy another for the fan controller unless I’m sure I can use it for that.


Oops! Posted without the YAML file. Adding it now:

# For Waveshare 7" ESP32 board.

substitutions:
  name: narvi
  friendly_name: Narvi

esphome:
  name: ${name}
  friendly_name: ${friendly_name}
  min_version: 2024.6.0
  name_add_mac_suffix: false
  platformio_options:
    board_build.flash_mode: dio
    # This option added for the display config file
    build_unflags: -Werror=all
  project:
    name: esphome.web
    version: dev

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

#Wifi not included - has my own data.

# Enable logging
logger:
  hardware_uart: UART0

# Enable Home Assistant API
api:
  reboot_timeout: 0s

# Allow Over-The-Air updates
ota:
- platform: esphome

ch422g:

psram:
  mode: octal
  speed: 80MHz

output:
  - platform: ledc
    id: backlight_output
    pin: 13    #Ignore this for this confiruation and for fan testing
    frequency: 1220Hz
    inverted: true

#------------------------------------------------------------
#Fan testing stuff
#------------------------------------------------------------

  - id: fan_out_01
    platform: ledc
    pin: GPIO6
    # inverted: true
    frequency: 1000

  - id: fan_out_02
    platform: ledc
    pin: GPIO15
    inverted: true
    frequency: 1000

  - id: fan_out_03
    platform: ledc
    pin: GPIO19
    inverted: true
    frequency: 1000

  - id: fan_out_04
    platform: ledc
    pin: GPIO20
    inverted: true
    frequency: 1000

# Note: this requires a hardware modification to work - GPIO 13 must be connected to the backlight PWM pad.
# Additional note: The GPIO13 works with the original setup in this config. I'm using GPIO16 for that.
#                  In this config, though, I'm leaving out dimming.

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

    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:
  widgets:
    - label:
        id: InfoDisplay
        align: CENTER
        text: "Fan test setup"
        text_align: CENTER
        text_font: montserrat_48
        text_color: purple


web_server:
  version: 3
  sorting_groups:
    - id: group_fans
      name: "Fans"
      sorting_weight: 10

fan:
  - id: vent_fan_cnc
    name: "Pin 6 - Sensor Connection"
    platform: speed
    output: fan_out_01
    speed_count: 10
    web_server:
      sorting_group_id: group_fans
      sorting_weight: 10

  - id: vent_fan_print
    name: "Pin 15 - RS485 Connectino"
    platform: speed
    output: fan_out_02
    speed_count: 10
      sorting_group_id: group_fans
      sorting_weight: 20

  - id: vent_fan_3
    name: "Pin 19 - USB Connection"
    platform: speed
    output: fan_out_03
    speed_count: 10
      sorting_group_id: group_fans
      sorting_weight: 30

  - id: vent_fan_4
    name: "Pin 20 - USB Connection"
    platform: speed
    output: fan_out_04
    speed_count: 10
      sorting_group_id: group_fans
      sorting_weight: 40

Have a look at the SD card pins.

So those are easy to use? I had figured they’d be part of a whole SD thing that might be hard to bypass. That was just an assumption, though.

Do you know if there’s an easy way to connect to those pins, other than soldering wires dot the SD connector?

Solder to the pads on the ESP32 module - they’re bigger than the SD connector pins.
There are 3 usable IOs there, and they’re not connected to anything else.

Do you have any idea what’s going on with the RS485 and USB pins and why those aren’t providing PWM output?