Skip to content

Instantly share code, notes, and snippets.

@wildekek
Created February 2, 2025 00:10
Show Gist options
  • Select an option

  • Save wildekek/d827cf2d9ab788b04ae072708a710a60 to your computer and use it in GitHub Desktop.

Select an option

Save wildekek/d827cf2d9ab788b04ae072708a710a60 to your computer and use it in GitHub Desktop.
Guition ESP32-S3 ESPHome example
substitutions:
device_name: "wall-tablet"
device_friendly_name: "Wall Tablet"
device_description: "Guition ESP32-S3-4848S040 "
time_timezone: "Europe/Amsterdam"
# Icons
lightbulb: "\U000F0335"
ceiling_light: "\U000F0769"
lamp: "\U000F06B5"
floor_lamp: "\U000F08DD"
string_lights: "\U000F12BA"
mdi_home: "\U000F02DC"
mdi_menu_left: "\U000F035E"
mdi_menu_right: "\U000F035F"
esphome:
name: $device_name
friendly_name: $device_friendly_name
comment: $device_description
name_add_mac_suffix: false
platformio_options:
board_build.flash_mode: dio
esp32:
board: esp32-s3-devkitc-1
variant: esp32s3
flash_size: 16MB
framework:
type: esp-idf
sdkconfig_options:
COMPILER_OPTIMIZATION_SIZE: y
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: "<insert your API key>"
ota:
- platform: esphome
password: "<insert your ESPHome key>"
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "Wall-Tablet Fallback Hotspot"
password: "<insert a password>"
captive_portal:
sensor:
- platform: wifi_signal
name: "WiFi Signal"
id: wifi_signal_db
update_interval: 60s
entity_category: diagnostic
internal: true
# Reports the WiFi signal strength in %
- platform: copy
source_id: wifi_signal_db
name: "WiFi Strength"
filters:
- lambda: return min(max(2 * (x + 100.0), 0.0), 100.0);
unit_of_measurement: "%"
entity_category: diagnostic
text_sensor:
- platform: wifi_info
ip_address:
name: "IP Address"
entity_category: diagnostic
ssid:
name: "Connected SSID"
entity_category: diagnostic
mac_address:
name: "Mac Address"
entity_category: diagnostic
lvgl:
on_idle:
- timeout: !lambda "return (id(display_timeout).state * 1000);"
then:
- logger.log: "Screen idle"
- light.turn_off:
id: backlight
transition_length: 5s
- lvgl.pause:
on_resume:
then:
- light.turn_on:
id: backlight
#- lvgl.resume:
style_definitions:
- id: style_line
line_color: 0x0000FF
line_width: 8
line_rounded: true
- id: date_style
text_font: roboto24
align: center
text_color: 0x333333
bg_opa: cover
radius: 4
pad_all: 2
- id: header_footer
bg_color: 0x2F8CD8
bg_grad_color: 0x005782
bg_grad_dir: VER
bg_opa: COVER
border_opa: TRANSP
radius: 0
pad_all: 0
pad_row: 0
pad_column: 0
border_color: 0x0077b3
text_color: 0xFFFFFF
width: 100%
height: 30
theme:
button:
text_font: roboto24
scroll_on_focus: true
#group: general
radius: 25
width: 150
height: 109
pad_left: 10px
pad_top: 10px
pad_bottom: 10px
pad_right: 10px
shadow_width: 0
bg_color: 0x313131
text_color: 0xB6B6B6
checked:
bg_color: 0xCC5E14
text_color: 0xB6B6B6
buttonmatrix:
bg_opa: TRANSP
border_color: 0x0077b3
border_width: 0
text_color: 0xFFFFFF
pad_all: 0
items: # set all your buttonmatrix buttons to use your custom defined styles and font
bg_color: 0x2F8CD8
bg_grad_color: 0x005782
bg_grad_dir: VER
bg_opa: COVER
border_color: 0x0077b3
border_width: 1
text_color: 0xFFFFFF
text_font: roboto24
pressed:
bg_color: 0x006699
bg_grad_color: 0x00334d
checked:
bg_color: 0x1d5f96
bg_grad_color: 0x03324A
text_color: 0x005580
top_layer:
widgets:
- buttonmatrix:
align: bottom_mid
styles: header_footer
pad_all: 0
outline_width: 0
id: top_layer
items:
styles: header_footer
rows:
- buttons:
- id: page_prev
text: $mdi_menu_left
on_press:
then:
lvgl.page.previous:
- id: page_home
text: $mdi_home
on_press:
then:
lvgl.page.show: main_page
- id: page_next
text: $mdi_menu_right
on_press:
then:
lvgl.page.next:
page_wrap: true
pages:
- id: main_page
#skip: true
layout:
type: flex
flex_flow: column_wrap
width: 100%
bg_color: 0x000000
bg_opa: cover
pad_all: 5
widgets:
- switch:
height: 223
checkable: true
id: lv_button_1
widgets:
- label:
align: bottom_left
text: "L1"
long_mode: dot
on_click:
switch.toggle: relay_l1
- id: external_lights
#skip: true
layout:
type: flex
flex_flow: column_wrap
width: 100%
bg_color: 0x000000
bg_opa: cover
pad_all: 5
widgets:
- button:
height: 223
checkable: true
id: button_remote_table_light
widgets:
- label:
text_font: light40
align: top_left
text: $lightbulb
id: lv_button_2_icon
- label:
align: bottom_left
text: "Table Light"
long_mode: dot
on_click:
- homeassistant.action:
action: light.toggle
data:
entity_id: light.table_light
#-------------------------------------------
# Internal outputs
#-------------------------------------------
output:
# Backlight LED
- platform: ledc
pin: GPIO38
id: GPIO38
frequency: 100Hz
# Built in 240v relay(s)
- id: internal_relay_l1
platform: gpio
pin: GPIO40
#- id: internal_relay_l2
# platform: gpio
# pin: GPIO2
#- id: internal_relay_l3
# platform: gpio
# pin: GPIO1
switch:
- platform: output
name: "Relay L1"
id: relay_l1
output: 'internal_relay_l1'
number:
- platform: template
name: Screen timeout
optimistic: true
id: display_timeout
unit_of_measurement: "s"
initial_value: 45
restore_value: true
min_value: 5
max_value: 300
step: 5
mode: box
#-------------------------------------------
# External lights
#-------------------------------------------
binary_sensor:
- platform: homeassistant
id: remote_table_light
entity_id: light.table_light
publish_initial_state: true
on_state:
then:
lvgl.widget.update:
id: button_remote_table_light
state:
checked: !lambda return x;
#-------------------------------------------
# Internal lights
#-------------------------------------------
light:
- platform: monochromatic
output: GPIO38
name: Backlight
id: backlight
restore_mode: ALWAYS_ON
default_transition_length: 0s
#-------------------------------------------
# Graphics and Fonts
#-------------------------------------------
font:
- file: "gfonts://Roboto"
id: roboto24
size: 24
bpp: 4
extras:
- file: "https://cdnjs.cloudflare.com/ajax/libs/MaterialDesign-Webfont/7.4.47/fonts/materialdesignicons-webfont.ttf" # http://materialdesignicons.com/cdn/7.4.47/
glyphs:
[
"\U000F02DC", # mdi-home
"\U000F035E", # mdi-menu-left
"\U000F035F" # mdi-menu-right
]
- file: "https://cdnjs.cloudflare.com/ajax/libs/MaterialDesign-Webfont/7.4.47/fonts/materialdesignicons-webfont.ttf" # http://materialdesignicons.com/cdn/7.4.47/
id: light40
size: 40
bpp: 4
glyphs: [
"\U000F0335", # mdi-lightbulb
"\U000F0769", # mdi-ceiling-light
"\U000F06B5", # mdi-lamp
"\U000F08DD", # mdi-floor-lamp
"\U000F12BA" # mdi-string-lights
]
#-------------------------------------------
# Touchscreen gt911 i2c
#-------------------------------------------
i2c:
- id: bus_a
sda: GPIO19
scl:
number: GPIO45
ignore_strapping_warning: true
#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
);
#-------------------------------------------
# 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
spi_mode: MODE3
data_rate: 2MHz
color_order: RGB
invert_colors: False
dimensions:
width: 480
height: 480
cs_pin: 39
de_pin: 18
hsync_pin: 16
vsync_pin: 17
pclk_pin: 21
pclk_frequency: 12MHz
pclk_inverted: False
hsync_pulse_width: 8
hsync_front_porch: 10
hsync_back_porch: 20
vsync_pulse_width: 8
vsync_front_porch: 10
vsync_back_porch: 10
init_sequence:
- 1
# Custom sequences are an array, first byte is command, the rest are data.
- [0xFF, 0x77, 0x01, 0x00, 0x00, 0x10] # CMD2_BKSEL_BK0
- [0xCD, 0x00] # disable MDT flag
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment