Lanbon L9 LCD Smart Light Switch with Motion Sensor

Here’s the ESPHome YAML configuration file for the Lanbon L9 with a trivial LVGL UI to toggle the local relay:

external_components:
  - source: github://EmbedMe-io/embedme
    components: [i80, io_bus, ili9xxx, spi]
    refresh: 1d

psram:
  speed: 80MHz

output:
  - platform: ledc
    pin: GPIO42
    id: backlight_pwm
  - platform: gpio
    pin: GPIO36
    id: relay

light:
  - platform: monochromatic
    name: "Backlight"
    id: backlight
    output: backlight_pwm
    restore_mode: ALWAYS_ON
  - platform: binary
    id: local_light
    name: "Light"
    output: relay

i80:
  dc_pin: GPIO17
  data_pins: 
    - GPIO6
    - GPIO7
    - GPIO15
    - GPIO16
    - GPIO10
    - GPIO9
    - ignore_strapping_warning: true
      number: GPIO46
    - ignore_strapping_warning: true
      number: GPIO3
  wr_pin: GPIO13
  rd_pin: GPIO18

i2c:
  sda: GPIO35
  scl:
    ignore_strapping_warning: true
    number: GPIO0

display:
  - id: langbon_L9
    platform: ili9xxx
    model: ST7789V
    bus_type: i80
    invert_colors: true
    dimensions:
      height: 320
      width: 170
      offset_width: 35
    cs_pin: GPIO21
    reset_pin: GPIO4
    auto_clear_enabled: false
    update_interval: never
    rotation: 0

touchscreen:
  platform: ft63x6
  calibration:
    x_min: 0
    y_min: 3
    x_max: 169
    y_max: 319
  on_touch:
    - lambda: |-
          ESP_LOGI("cal", "x=%d, y=%d, x_raw=%d, y_raw=%0d",
              touch.x,
              touch.y,
              touch.x_raw,
              touch.y_raw
              );
    - if:
        condition: lvgl.is_paused
        then:
          - logger.log: "LVGL resuming"
          - lvgl.resume:
          - lvgl.page.show: main_page
          - lvgl.widget.redraw
          - light.turn_on: backlight

image:
  - file: https://esphome.io/_static/favicon-512x512.png
    id: boot_logo
    resize: 150x150
    type: RGB565
    use_transparency: true

lvgl:
  on_idle:
    timeout: !lambda "return 10000;"  # Turn off back light if idle for 10 secs
    then:
      - logger.log: "LVGL is idle"
      - light.turn_off: backlight
      - lvgl.pause:
          show_snow: true # Prevent burn-in
  bg_color: black

  top_layer:
    widgets:
      - obj:
          id: boot_screen
          x: 0
          y: 0
          width: 100%
          height: 100%
          bg_color: 0xffffff
          bg_opa: COVER
          radius: 0
          pad_all: 0
          border_width: 0
          widgets:
            - image:
                align: CENTER
                src: boot_logo
                y: -40
            - spinner:
                align: CENTER
                y: 95
                height: 50
                width: 50
                spin_time: 1s
                arc_length: 60deg
                arc_width: 8
                indicator:
                  arc_color: 0x18bcf2
                  arc_width: 8
          on_press:
            - lvgl.widget.hide: boot_screen

  pages:
    - id: main_page
      widgets:
        - switch:
            id: light_switch
            align: CENTER
            width: 90%
            height: 15%
            on_click:
              light.toggle: local_light

The pin-out on the display board connector (thanks to openHASP):

IMPORTANT: You must supply both 5V and 3.3V pins.

1 Like