Help needed to get this tiny screen working - ESP32-c6 1.47in display


Hey all, I’ve been using HA for a few years now and I’ve decided to try ESPhome.

I thought this tiny esp32-c6 with screen was really cool and would be a nice place to start. Have I mad it more difficult for myself?

It’s connected and visible in HA but I can’t get the screen to display anything.

Log level debug:
Full log here - INFO ESPHome 2024.11.0INFO Reading configuration /config/esphome/sdsd.yaml... - Pastebin.com

but this is where it seems to fail

[09:11:10][W][component:237]: Component display took a long time for an operation (101 ms).
[09:11:10][W][component:238]: Components should block for at most 30 ms.

My config

I’ve been using these two pages to help with the config but I’ve hit a wall.

Any help would be massively appreciated.

Thanks

1 Like

Definitely yes. Basic Wroom32 board would be easier to start with.
Anyway, nice board I have to say.
Read the waveshare wiki.
Start with the correct display pins:

1 Like

Looking at the debug log it looks like the display is detected ok.

[09:15:54][C][ili9xxx:094]: ili9xxx
[09:15:54][C][ili9xxx:094]:   Rotations: 0 °
[09:15:54][C][ili9xxx:094]:   Dimensions: 172px x 320px
[09:15:54][C][ili9xxx:095]:   Width Offset: 0
[09:15:54][C][ili9xxx:096]:   Height Offset: 0
[09:15:54][C][ili9xxx:102]:   Color mode: 16bit
[09:15:54][C][ili9xxx:111]:   Data rate: 40MHz
...

Put the logger into VERBOSE mode and boot up again. Then do the same with VERY_VERBOSE mode. Very verbose should post the commands to the display and will be very long; we only need ~15 seconds of that one. Upload both.

logger:
  level: VERBOSE
1 Like

@darleschixon and pull down that password for your WiFi
It should be hidden in the secrets like this:

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password

Secrets are managed here:
image

1 Like

Thanks @RonnieLast @Karosm for your hep. Much appreciated.

I’ve hidden my Wifi details now.

I got a little further using the correct GPIO numbers as @Karosm pointed out above.
I was able to see the shape on the screen but it was very intermittent and the same error appeared in the logs as before.

Config
Verbose log
Very_verbose log

Weirdly, if I install via usb.

When I get to this screen

It works and the screen shows the shape (just a random example I found)

But as soon as the install is “successful” the screen goes off.

Posting a new Very_verbose log here because it looks a lot different to the first one I posted.

I wonder if the SPI and display are negotiating the correct speed? I had an issue not unlike this last week and it was resolved by configuring the speed on I2C…

As soon as I put i2c in my config I get this error about Pin 21

Screenshot 2024-11-26 at 12.32.55

Because you use the pin on the LCD.
This display is not i2c? So if you need i2c then you need to select other pins than the default

It’s SPI and not I2C.

I meant my update as an example of what can happen if the protocol cannot communicate to the display at the expected speed. Sorry for the confusion.

The ST7789V component has these parameters you could try and change:

data_rate (Optional, frequency): The SPI data rate (default 20MHz.) Can be reduced if required, e.g. to compensate for long data cables.

spi_mode (Optional, 0-3): The SPI clock mode to use (default: mode0.) The ST7789V datasheet specifies mode 0, but some displays appear to require mode 3. This should be one of mode0, mode1, mode2 or mode3 (or just a digit from 0-3.)

EDIT;
Just noticed from the manual Ronnie posted:

Could that be the spi_mode?

1 Like

Trying this now:

display:
  - platform: st7789v
    model: Waveshare 1.47in 172X320
    dc_pin: GPIO15
    cs_pin: GPIO14
    reset_pin: GPIO21
    spi_mode: 3
    id: tft_ha
    lambda: |-
      // Draw a circle in the middle of the display
      it.filled_circle(it.get_width() / 2, it.get_height() / 2, 20);

I also noticed that the manual mentioned 4 Line SPI on the same table you took a screenshot.
Found this info from here

"For quad type instead specify data_pins:

  • data_pins (Required, Pin Schema): Must be a list of exactly 4 pins to be used for the quad SPI output data lines."

Looking at the logs around SPI. Does it look like 1 pin is missing here?

[13:55:51][C][spi:064]: SPI bus:
[13:55:51][C][spi:065]:   CLK Pin: GPIO7
[13:55:51][C][spi:066]:   SDI Pin: 
[13:55:51][C][spi:067]:   SDO Pin: GPIO6
[13:55:51][C][spi:072]:   Using HW SPI: SPI2_HOST

Is the screen backlight on by default? Your picture looks like it is, if not you should be able to control with

# Define a PWM output on the ESP32
output:
  - platform: ledc
    pin: GPIO22
    id: backlight_pwm

# Define a monochromatic, dimmable light for the backlight
light:
  - platform: monochromatic
    output: backlight_pwm
    name: "Display Backlight"
    id: back_light
    restore_mode: ALWAYS_ON
1 Like

Weirdly enough I’ve just added
backlight_pin: GPIO22
to my config and the screen is showing correctly.

Thanks to everyone who helped out,

This is the working config for spi and display

spi:
  clk_pin: GPIO7
  mosi_pin: GPIO6

display:
  - platform: st7789v
    model: CUSTOM
    dc_pin: GPIO15
    height: 320
    width: 172
    offset_height: 34
    offset_width: 0
    cs_pin: GPIO14
    reset_pin: GPIO21
    backlight_pin: GPIO22
    spi_mode: 3
    data_rate: 4000000.0
    id: tft_ha
    lambda: |-
      // Draw a circle in the middle of the display
      it.filled_circle(it.get_width() / 2, it.get_height() / 2, 20);

I am still getting the orignal error in the logs but the screen is working, so I’m going to ignore that for now (I’m sure I’ll regret this later)

1 Like