ST7789V to ili9xxx display component support question

HI,

According to this the direct support for the ST7789V (that comes with the TTGO/ESP combo) may be dropped in the future but is now supported by the ili9xxx component.

I have tried several times to update the component from the ST7789V to ili9xxx in my ESP code but can never seem to get it right. ;-(

This is what I have at the moment and the display is now just black, whereas previously (with the ST7789V driver) it was all working nicely?

display:
  - platform: ili9xxx
    model: ST7789V
    dimensions:
      height: 240
      width: 135
      offset_height: 40
      offset_width: 52
      invert_colors: true
    id: my_display           
    cs_pin: GPIO5
    dc_pin: GPIO16
    reset_pin: GPIO23

What have I got wrong please? ;-(

I got the same problem, because I forgot about the backlight.

# Define a PWM output on the ESP32
output:
  - platform: ledc
    pin: GPIO04
    id: gpio_04_backlight_pwm

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

Hi and thanks for coming back to me. :wink:

So can I confirm I just need to use the code I offered AND the code you offered and that should do it?

Just to be sure, I also have

spi:
  clk_pin: GPIO18
  mosi_pin: GPIO19

And for my usecase I used “rotation: 90” at the display segment but that could be different for you.

Hi again,

Could you do me a massive favour and post all the code from one of your TTGO displays (with any sensitive bits redacted etc) please?

I’d like to start with something that works, at least as the display is concerned and try to take it from there.

Mine monitors Co2, so if you’re doing anything else you will have to delete a lot of stuff i’m afraid :stuck_out_tongue:
(this is the kit Control CO2 Bouwpakket (CO2, temperatuur en relatieve vochtigheid sensor) – Control CO2)

For reference this is the guide I had initially used (before the new version of the software)

Do mind the font, I remember I had to download them

And the code i’m running now

esphome:
  name: "air-quality-indoor"
  friendly_name: Co2 reader blue cloud
  platform: ESP32
  board: "featheresp32"

wifi:
  networks:
   -[put your super secret stuff here]
      
  
  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "[put your super secret stuff here]"
    password: [put your super secret stuff here]

logger:
  logs:
    component: ERROR

# Enable Home Assistant API
api:
    encryption:
        key: "[put your super secret stuff here]" 

ota:
  password: "[put your super secret stuff here]"
  
captive_portal:

# CO2 sensor
uart:
  rx_pin: 27
  tx_pin: 26
  baud_rate: 9600

# Dipslay driver: ST7789
spi:
  clk_pin: GPIO18
  mosi_pin: GPIO19

font:
  - file: "/config/esphome//fonts/Oswald-Light.ttf"
    id: font_70
    size: 70
    glyphs: 0123456789 # Only used for CO2 level

  - file: "/config/esphome//fonts/Oswald-Light.ttf"
    id: font_30
    size: 30

color:
  - id: color_black
    red: 0%
    green: 0%
    blue: 0%
    white: 0%
  - id: color_green
    red: 0%
    green: 100%
    blue: 0%
  - id: color_yellow
    red: 100%
    green: 100%
    blue: 0%
  - id: color_orange
    red: 100%
    green: 55%
    blue: 0%
  - id: color_red
    red: 100%
    green: 0%
  - id: color_white
    red: 100%
    green: 100%
    blue: 100%
  - id: color_blue
    red: 0%
    green: 0%
    blue: 100%

# Define a PWM output on the ESP32
output:
  - platform: ledc
    pin: GPIO04
    id: gpio_04_backlight_pwm

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

display:
  - platform: ili9xxx
    model: st7789v
    #TTGO TDisplay 135x240
    dimensions:
      height: 240
      width: 135
      offset_height: 40
      offset_width: 52
    # Required or the colors are all inverted, and Black screen is White
    invert_colors: true
    id: my_display
    cs_pin: GPIO5
    dc_pin: GPIO16
    reset_pin: GPIO23
    #brightness: 100%
    rotation: 90

    pages:
        # Page 1: Current CO2 levels
        #    0    - 1000 -> Green
        #    1000 - 1600 -> Yellow
        #    1600 - 2000 -> Orange
        #    >2000       -> Red
        - id: page1
          lambda: |-
            if(!id(co2_sensor).has_state() ){
              it.print(
                it.get_width()/2,
                it.get_height()/2,
                id(font_70),
                color_white,
                TextAlign::CENTER,
                "Starting..."
              );
              return;
            }
          
            auto bg_color = id(color_black);
            auto text_color = id(color_green);
            auto co2 = id(co2_sensor).state;
            if(co2 > 1000) text_color = id(color_yellow);
            if(co2 > 1600) text_color = id(color_orange);
            if(co2 > 2000){
              text_color = id(color_white);
              bg_color = id(color_red);
            }
            it.filled_rectangle(0, 0, it.get_width(), it.get_height(), bg_color);
            it.printf(
              it.get_width()/2, 
              it.get_height()/2, 
              id(font_70), 
              text_color, 
              TextAlign::CENTER, 
              "%.0f",
              co2
            );
        # Page 2: WiFi information
        - id: page2
          lambda: |-
            it.print(
              0, 0,
              id(font_30),
              id(color_white),
              "WiFi details"
            );
            it.printf(
              0, 30,
              id(font_30),
              id(color_white),
              "%s",
              id(wifi_ssid).state.c_str()
            );
            it.printf(
              0, 60,
              id(font_30),
              id(color_white),
              "%s",
              id(wifi_ip_addr).state.c_str()
            );

# does not work anymore with newer version
#switch:
#  - platform: gpio
#    name: "Backlight co2"
#    pin: GPIO4
#    id: backlight
#    internal: true

sensor:
  - platform: mhz19
    co2:
      name: "CO2 Indoor"
      id: "co2_sensor"
    temperature:
      name: "Temperature"
      internal: true
    update_interval: 60s
    automatic_baseline_calibration: false
  - platform: dht
    model: AM2302
    pin: 15
    temperature:
      name: "co2 temp"
    humidity:
      name: "co2 Humidity"
    update_interval: 60s

text_sensor:
  - platform: wifi_info
    ip_address:
      internal: true
      id: wifi_ip_addr
    ssid:
      internal: true
      id: wifi_ssid

binary_sensor:
  # Button to cycle through pages on the display
  - platform: gpio
    pin:
      number: GPIO35
      inverted: true
    id: button_1
    on_click:
      then:
        - display.page.show_next: my_display
        - component.update: my_display
  # Button to toggle the backlight (for use at night)
  - platform: gpio
    pin:
      number: GPIO0
      inverted: true
    id: button_2
    on_click:
      then:
        - light.toggle: 
            id: back_light 

I thought I had replied to you to thank you for your post but I can’t see it here. ;-(

I have copied, pasted into a new ESPHome node and tweaked the settings etc. I will order a new TTGO module to try it on as I need a spare one to play with. :wink:

Just OOI, have you not played with ‘Secrets’ for your secret settings as it does make posting in public places easier / safer?

Just slick on ‘Secrets’ t/r of the ESPHome main screen then add entries like:

wifi_ssid: BT1223
wifi_password: G4rY87R9W9b
fallback_password: £1ab54Cdxyz

And it even adds them for you when you create a new node. :wink:

esphome:
name: “air-quality-indoor”
#friendly_name: Co2 reader blue cloud
platform: ESP32
board: “featheresp32”

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

manual_ip:
static_ip: 192.168.0.198
gateway: 192.168.0.100
subnet: 255.255.255.0

ap:
ssid: “Air quality Fallback Hotspot”
password: !secret fallback_password

etc