-
-
Save itmaybeokay/bd5c7aa574e8ed517148cf9c4c267bdb to your computer and use it in GitHub Desktop.
| esphome: | |
| name: panel | |
| friendly_name: panel | |
| platformio_options: | |
| build_flags: "-DBOARD_HAS_PSRAM" | |
| board_build.arduino.memory_type: qio_opi | |
| board_build.flash_mode: dio | |
| board_upload.maximum_ram_size: 524288 | |
| esp32: | |
| board: esp32-s3-devkitc-1 | |
| variant: esp32s3 | |
| framework: | |
| type: esp-idf | |
| sdkconfig_options: | |
| CONFIG_ESP32S3_DEFAULT_CPU_FREQ_240: y | |
| CONFIG_ESP32S3_DATA_CACHE_64KB: y | |
| CONFIG_SPIRAM_FETCH_INSTRUCTIONS: y | |
| CONFIG_SPIRAM_RODATA: y | |
| # Enable logging | |
| logger: | |
| i2c: | |
| sda: GPIO08 | |
| scl: GPIO09 | |
| # scan: True | |
| id: bus_a | |
| ch422g: | |
| - id: ch422g_hub | |
| address: 0x24 | |
| # Of the CH422's twenty-four i2c addresses, 0x24 is the correct one to use in the setup here. | |
| # Still, wow, that's a lot of i2c addresses. | |
| # Enable Home Assistant API | |
| api: | |
| encryption: | |
| key: | |
| ota: | |
| - platform: esphome | |
| password: | |
| wifi: | |
| ssid: !secret wifi_ssid | |
| password: !secret wifi_password | |
| # Enable fallback hotspot (captive portal) in case wifi connection fails | |
| ap: | |
| ssid: "Panel Fallback Hotspot" | |
| password: | |
| captive_portal: | |
| psram: | |
| mode: octal | |
| speed: 80MHz | |
| # Define display | |
| display: | |
| - platform: rpi_dpi_rgb | |
| id: my_display | |
| auto_clear_enabled: false | |
| color_order: RGB | |
| pclk_frequency: 16MHZ | |
| dimensions: | |
| width: 800 | |
| height: 480 | |
| de_pin: | |
| number: 5 | |
| hsync_pin: | |
| number: 46 | |
| ignore_strapping_warning: true | |
| vsync_pin: | |
| number: 3 | |
| ignore_strapping_warning: true | |
| pclk_pin: 7 | |
| reset_pin: | |
| ch422g: ch422g_hub | |
| number: 3 | |
| enable_pin: | |
| ch422g: ch422g_hub | |
| number: 2 | |
| hsync_back_porch: 16 | |
| hsync_front_porch: 16 | |
| hsync_pulse_width: 8 | |
| vsync_back_porch: 16 | |
| vsync_front_porch: 16 | |
| vsync_pulse_width: 8 | |
| data_pins: | |
| red: | |
| - 1 #r3 | |
| - 2 #r4 | |
| - 42 #r5 | |
| - 41 #r6 | |
| - 40 #r7 | |
| blue: | |
| - 14 #b3 | |
| - 38 #b4 | |
| - 18 #b5 | |
| - 17 #b6 | |
| - 10 #b7 | |
| green: | |
| - 39 #g2 | |
| - 0 #g3 | |
| - 45 #g4 | |
| - 48 #g5 | |
| - 47 #g6 | |
| - 21 #g7 | |
| touchscreen: | |
| platform: gt911 | |
| id: my_touch | |
| # Uncomment below if you got the janky OTHER i2c address this time | |
| #address: 0x14 | |
| # Probably fixed by adding reset_pin via CH422 though | |
| interrupt_pin: GPIO4 | |
| # DEFINE RESET PIN for consistent i2c address selection | |
| # CTP_RST is wired to IO1 of CH422G | |
| reset_pin: | |
| ch422g: ch422g_hub | |
| number: 1 | |
| mode: OUTPUT | |
| on_touch: | |
| - lambda: |- | |
| ESP_LOGI("Touch", "Touch detected at x=%d, y=%d", touch.x, touch.y); | |
| # Define fonts | |
| font: | |
| - file: "gfonts://Roboto" | |
| id: roboto24 | |
| size: 24 | |
| bpp: 4 | |
| - file: "gfonts://Roboto" | |
| id: roboto18 | |
| size: 18 | |
| bpp: 4 | |
| binary_sensor: | |
| - platform: homeassistant | |
| id: demo_light_status | |
| entity_id: light.demo | |
| internal: true | |
| on_state: | |
| then: | |
| - lambda: |- | |
| if (id(demo_light_status).state) { | |
| lv_obj_add_state(id(lv_button_demo_light), LV_STATE_CHECKED); | |
| lv_label_set_text(id(demo_light_status_label), "On"); | |
| } else { | |
| lv_obj_clear_state(id(lv_button_demo_light), LV_STATE_CHECKED); | |
| lv_label_set_text(id(demo_light_status_label), "Off"); | |
| } | |
| lvgl: | |
| displays: | |
| - my_display | |
| touchscreens: | |
| - my_touch | |
| theme: | |
| button: | |
| bg_color: 0x333333 | |
| bg_grad_dir: VER | |
| text_color: 0xFFFFFF | |
| checked: | |
| bg_color: 0xcc9900 | |
| text_color: 0x000000 | |
| bg_grad_color: 0x664d00 | |
| pressed: | |
| border_color: 0xff6600 | |
| pages: | |
| - id: main_page | |
| layout: | |
| type: flex | |
| flex_flow: column_wrap | |
| width: 100% | |
| bg_color: 0x000000 | |
| bg_opa: cover | |
| pad_all: 5 | |
| widgets: | |
| - button: | |
| checkable: true | |
| id: lv_button_demo_light | |
| width: 140 | |
| height: 150 | |
| widgets: | |
| - label: | |
| text_font: roboto24 | |
| text: "Demo\nLamp" | |
| - label: | |
| id: demo_light_status_label | |
| text: "Off" | |
| align: bottom_left | |
| on_click: | |
| then: | |
| - homeassistant.service: | |
| service: light.toggle | |
| data: | |
| entity_id: light.demo | |
| interval: | |
| - interval: 20s | |
| #startup_delay: 15s | |
| then: | |
| - lambda: |- | |
| if (id(demo_light_status).state) { | |
| lv_obj_add_state(id(lv_button_demo_light), LV_STATE_CHECKED); | |
| lv_label_set_text(id(demo_light_status_label), "On"); | |
| } else { | |
| lv_obj_clear_state(id(lv_button_demo_light), LV_STATE_CHECKED); | |
| lv_label_set_text(id(demo_light_status_label), "Off"); | |
| } | |
Just for info, I have been trying to use an ESP32-S3-Touch-LCD-4.3B in my system (not with home assistant) and I have found an issue at least with my system. I have an ESP32-S3-Touch-LCD-4.3B powered from a 12V DC supply and with a SHT31 I2C module attached to read temperature and humidity. I have found that the touch controller locks up after a while and have, so far, diagnosed this to the ch422g IO expander reacting to the touch controllers I2C reads during its polling. This ends up with the display going blank and lots of touch errors reported on its USB serial interface. It looks like the ch422g is prone to I2C glitches which are made worse with the 12V power and external I2C device attached. Maybe some 47pF caps on the SLC/SDA linesto GND (ESP32 side of M1 - NDC7002N) might help (yet to try) ?
I gave up using touch because of this problem. It would be good if you can find a solution.
I believe I have managed to fix this issue by soldering some 47 pF capacitors on the ESP32 I2C bus from SDA and SCL to ground (CPU/CH422G side of M1). I did this by soldering two 0603 47pf caps vertically to the SDA an SCL ends of R100 and R101 (RHS when ESP32-S3-Touch-LCD-4.3B viewed from rear with text the correct way up) and with the caps top soldered via some thin wirewrap wire to the right hand pad of C42 (or where C42 would be fitted) as this is GND.
With my test program which failed every 10 seconds or so, it has now lasted > 30 minutes without any issues.
I have also changed my real program to use touch interrupts (in combination with polling) so that the touch controller isn't being read every 10ms reducing I2C traffic hugely. As a belt and braces I may occasionally read the CH422G input register and if it is not as it should be re-configure the CH422G.
Is there a good Waveshare forum to put this fix on ?
Thank you so much for this! Do you know if this setup works with https://www.waveshare.com/wiki/ESP32-S3-Touch-LCD-4B ?
Any help would be much appreciated!