Lanbon L9 LCD Smart Light Switch with Motion Sensor

Lanbon has a new smart switch that runs on an ESP32-S3-Wroom-1U. This is a really great solution for ESPHome users in the US as it fits behind a standard Decora switch plate.

The best feature is it has a mmwave radar chip behind the screen for motion sensing!

  • Display Size:1.9‘
  • Display resolution:170*320
  • Display Controller: ST7789V2
  • Touch Controller: FT6336U
  • Flash: 16MB

It anybody interested in writing a yaml file that will get this screen working with ESPHome?.

It looks like the openHASP community has most of it working now. So it should be possible to reuse their code.

1 Like

I’m looking at the work the openHASP guys have put into reverse-engineering the L9 and it seems it is using an 8-bit parallel interface for the display.

Am I reading this right? If so, what’s the easiest way to support it? It’s easy to create a parallel interface external component, but how to integrate that into the display component which expects a SPI bus?

Me think an external component defining a new display platform might be the way to go…

Looking at the ESPHome source code, I’m starting to think that defining a new “Octal” SPI type would be the easiest, similar to the Quad SPI. It would allow using the ILI9xxx-ST7789V display driver as-is.

The “problem” is that the 8-bit parallel interface on the ST7789V uses rising edges on WRX and RDX to perform write and read operations via shared data bits whereas SPI uses a rising edge on SCK with parallel write and read operations on MOSI and MISO – so it is not “SPI”. Would the ESP powers that be (@clydebarrow) allow such an overloading of the SPI component in an eventual contribution?

Looking at the ILI9XXX driver, it always transmits bytes. So the proper solution would be for it to be implemented on top of a “byte Tx/Rx” component, SPI being one possible implementation. But that would be a LOT more work and maybe not backward compatible.

Thoughts?

Please do not tag people who are not part of the thread.

If you want to get eyes on this, you already have the link to the github repository where anyone with knowledge on the matter will be able to weigh in.

This would be a good place to start.
WT32-SC01-PLus ESPHome config · GitHub

It uses the same parallel interface.

Thank you! That is awesome. I’m already very familiar with the WT32-SC01 Plus so that should be a breeze now.

Thank you for that great improvement on the light platform @clydebarrow!! That was beautiful work. I’m glad we agree on the proper approach. I hope to see the io_bus component appear in the official ESPHome soon.

1 Like

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

Nice work! Has anybody figure out how to use the mmWare radar that is behind the screen?

Here’s the relevant portion of the discussion on openHASP about the radar sensor. Should be possible to use with all the info that is there but I am not personally motivated to do it (yet) as I do not need it for my current application.