GUITION 4" 480x480 ESP32-S3-4848S040 Smart Display with LVGL

Nice does it seem to work well for you?

Can you still tap to turn the light on and off?

I created a new button with a slider on it. It you press the button any other other place other than the slider it will toggle the light. The slider will set the brightness. Also if the brightness is set by something else the screen will update to show the correct state.

This is the button’

              - button:
                    height: $button_height_double
                    checkable: true
                    id: lv_button_1
                    widgets:
                      - label:
                          text_font: $icon_font
                          align: top_left
                          text: $button_1_icon
                          id: lv_button_1_icon
                      - label:
                          align: bottom_left
                          id: lv_button_1_label
                          text: $button_1_name
                      - slider:
                          id: lv_button_1_slider
                          align: top_right
                          x: -5  
                          width: 40
                          height: 170
                          pad_all: 0
                          min_value: 0
                          max_value: 255
                          radius: 5px
                          knob:
                            bg_color: White
                            radius: 2px
                            pad_left: -3px
                            pad_right: -3px
                            pad_top: -18px
                            pad_bottom: -18px
                          indicator:
                            radius: 0px
                            bg_color: Gray
                          on_release:
                            - homeassistant.action:
                                action: light.turn_on
                                data:
                                  entity_id: $button_1_device
                                  brightness: !lambda return int(x);
                    on_click:
                        - homeassistant.service:
                            service: light.toggle
                            data:
                              entity_id: $button_1_device

And this is the code that controls the state.

    platform: homeassistant
    id: button_${id}_device_brightness
    entity_id: $button_${id}_device
    attribute: brightness
    on_value:
      - lvgl.slider.update:
          id: lv_button_${id}_slider
          value: !lambda return x;

I added it to my guition-esp32-s3-4848s040-display_modular.yaml file if you want to see it working.

7 Likes

Tell me how to draw filled triangle in LVGL?

Yours looks much better ! will try it out tonight.

Any idea how we can get LVGL to display a sensor reading - eg “sensor.solarproduction”

i dont get it -
do you have to do something in ‘sensor:’ bit ,
sensor: -platform: ha - entity ID:
then how do i get it to update on lvgl?

Try this:

- platform: homeassistant
    id: my_solar_sensor
    entity_id: your_entity_name_in_ha # Change the entity from your Home Assistant
    #attribute: last_period # If you have a specific attribute in the sensor, make sure to uncomment and set it corresponding to yours
    on_value:
      then:
        - lvgl.label.update:
            id: solar_label # The label where u want to show
            text: 
              format: "%s kWh"
              args: ["id(my_solar_sensor).state.c_str()"] # Make sure to match with properly id like my_solar_sensor

Hi thanks for this

do iput this in ‘sensor:’ or ‘text_sensor’ as i keep getting an error when i put it in sensor?

text_sensor

thanks!#
so in your example - is solar_label the thing i need to put into the bit that says : label:
so its like this:
label: solar_label ?
or label: my_solar_sensor
or do i need to put a $ in front of it or something?

i really appreciate the help

this is looking really good.
ive looked at what you have done with proper eyes today and it seems so much more elegant a solution - i couldnt understand how to set individual settings per button but i get it now - i will try this next week (once the trouble+strife is at work)

Hi everyone - I hope you might be able to help me. I can’t get my display to show anything. I’ve tried something simple like just getting it to write “Hello world” but nothing appears on the display. I can compile the code in esphome and upload it to the display, but no luck. I greatly appreciate any help

esphome:
  name: stordisp2
  friendly_name: stordisp2

esp32:
  board: esp32-s3-devkitc-1
  variant: esp32s3
  flash_size: 16MB
  framework:
    type: esp-idf
    sdkconfig_options:
      CONFIG_ESP32S3_DEFAULT_CPU_FREQ_240: "y"
      CONFIG_ESP32S3_DATA_CACHE_64KB: "y"
      CONFIG_ESP32S3_DATA_CACHE_LINE_64B: "y"
      CONFIG_SPIRAM_FETCH_INSTRUCTIONS: y
      CONFIG_SPIRAM_RODATA: y

psram:
  mode: octal
  speed: 80MHz

# Enable logging
logger:

# Enable Home Assistant API
api:
  encryption:
    key: XXXXXXXXX

ota:
  - platform: esphome
    password: XXXXXXXXXXX

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

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Stordisp2 Fallback Hotspot"
    password: XXXXXXXXXX

captive_portal:
    
#-------------------------------------------
# Internal outputs
#-------------------------------------------
output:
    # Backlight LED
  - platform: ledc
    pin: GPIO38
    id: GPIO38
    frequency: 100Hz
    
    # Built in 120v relay
  - id: internal_relay_1
    platform: gpio
    pin: 40

#-------------------------------------------
# LIGHTS
#-------------------------------------------
light:
  - platform: monochromatic
    output: GPIO38
    name: Backlight
    id: backlight
    restore_mode: ALWAYS_ON





lvgl:
  displays: 
    - my_display
  touchscreens:
    - my_touchscreen
  log_level: INFO
  color_depth: 16
  bg_color: 0
  text_font: unscii_8
  align: center

  pages:
    - id: page_boot
      widgets:
        - obj:
            widgets:
              - label:
                  id: your_widget_id
                  align: CENTER
                  text_align: CENTER
                  y: 190
                  width: 100%
                  text_color: 0x63b2f2
                  text: "HELLO WORLD"



#-------------------------------------------
# Touchscreen gt911 i2c
#-------------------------------------------
i2c:
  - id: bus_a
    sda: GPIO19
    scl: GPIO45
    #frequency: 100kHz
    
touchscreen:
  platform: gt911
  transform:
    mirror_x: false
    mirror_y: false
  id: my_touchscreen
  display: my_display

  on_touch:
    - logger.log:
          format: Touch at (%d, %d)
          args: [touch.x, touch.y]
    - lambda: |-
          ESP_LOGI("cal", "x=%d, y=%d, x_raw=%d, y_raw=%0d",
              touch.x,
              touch.y,
              touch.x_raw,
              touch.y_raw
              );

  on_release:
    then:
      - if:
          condition: lvgl.is_paused
          then:
            - logger.log: "LVGL resuming"
            - lvgl.resume:
            - lvgl.widget.redraw:
            - light.turn_on: backlight

#-------------------------------------------
# Display st7701s spi
#-------------------------------------------
spi:
  - id: lcd_spi
    clk_pin: GPIO48
    mosi_pin: GPIO47
    
display:
  - platform: st7701s
    id: my_display
    update_interval: never
    auto_clear_enabled: false
    data_rate: 2MHz
    spi_mode: MODE3
    color_order: RGB
    invert_colors: false
    dimensions:
      width: 480
      height: 480
    transform:
      mirror_x: false
      mirror_y: false
    cs_pin: 39
      # reset not defined 
    de_pin: 18
    hsync_pin: 16
    vsync_pin: 17
    pclk_pin: 21
    init_sequence: 
      - 1
      - [0xFF, 0x77, 0x01, 0x00, 0x00, 0x10] # CMD2_BKSEL_BK0
      - [0xCD, 0x00] # disable MDT flag
    pclk_frequency: 12MHz
    pclk_inverted: false
    data_pins:
      red:
        - 11         # R1
        - 12         # R2
        - 13         # R3
        - 14         # R4
        - 0          # R5
      green:
        - 8          # G0
        - 20         # G1
        - 3          # G2
        - 46         # G3
        - 9          # G4
        - 10         # G5 
      blue:
        - 4          # B1
        - 5          # B2
        - 6          # B3
        - 7          # B4
        - 15         # B5

When I see the log i esphome this is showing over and over again.
Udklipboot

esphome:
on_boot:
- light.turn_on: backlight

Start with my basic file for the GUITION 4” 480x480 ESP32-S3-4848S040 Smart Display. That will get your display working and you can move on from there.

guition-esp32-s3-4848s040-display_basic.yaml

1 Like

Wow, That’s some nice code!!

Thanks…
I found the problem, my device was stuck in a boot loop so I added this to my code and now it is working.

esphome:
  platformio_options:
    board_build.flash_mode: dio

I also just tried your code and that is working fine :+1:
You did a greate job on github :+1:

Hello everyone!
I also use this screen and EspHome without Home assistant and I want to talk about some troubles that arose in the process…
After all, this screen is an independent device that can work without WiFi… And it seems very convenient to do the following things:

  1. Have the ability to enter the SSID and WiFi password directly on the screen…
  2. Have the ability to specify your static IP address also from the screen…
  3. Have the ability to transmit the minimum and maximum scale values ​​for bars, arcs, sliders etc. via MQTT…
  4. Have the ability to transmit MDI icons as text via MQTT, for example, when the button is pressed - one icon, when the button is released - another icon. I understand how to do this inside the code, but I need the ability to send exactly the icons that are needed via MQTT, without reprogramming…
    But EspHome can’t do this… These values ​​can’t be templates… Very sad…
    Also, I noticed that the screen itself displays the fill very ugly if a gradient is used…
    Maybe someone can help me solve my problems?

Hi

I tried Andrew code but I obtain an error
image
Why the common/color.yaml file cannot be find?

Hi,

I got an issue. I can swtich my lightbulb on my display. The problem is that it won’t update the state on the display when setting it on in homeassistant. I got in the logging that it gets the state. Any an idea what I do wrong

        - button:
            x: 250
            y: 260
            width: 60
            height: 58
            checkable: true
            widgets:
               - label:
                  text_font: light32
                  id: zolderlamp_button
                  text: "\U000F0335"
                  align: center
            on_click:
              - homeassistant.service:
                  service: switch.toggle
                  data_template:
                    entity_id: switch.zolderverlichting



binary_sensor:
  - platform: homeassistant
    id: zolderlamp
    entity_id: switch.zolderverlichting
    publish_initial_state: true
    on_state:
      then:
        - lvgl.widget.update:
            id: zolderlamp_button
            state:
              checked: !lambda return x;
              
              
[19:56:24][D][homeassistant.binary_sensor:026]: 'switch.zolderverlichting': Got state ON
[19:56:24][D][binary_sensor:036]: 'zolderlamp': Sending state ON

I don’t know. I don’t have any links in my code to the file anymore… Make sure to get the latest from my GIT repo and if you are still have issue tell me exactly what YAML file you are trying to use.

Look like you are missing some code. Try my guition-esp32-s3-4848s040-display_modular.yaml example. That will get it working.