From bb25684072e22098e253517cb99c881da53e530c Mon Sep 17 00:00:00 2001 From: Matthias Guillitte Date: Thu, 13 Aug 2026 11:27:42 +0200 Subject: [PATCH] Screen working Need mqtt connection still --- ecran_externe/.gitignore | 5 + ecran_externe/README.md | 3 + ecran_externe/device_id.txt | 1 + ecran_externe/epaper_thread_node.yaml | 130 +++++++++++++++++++------- ecran_externe/test_minimal.yaml | 29 ++++++ 5 files changed, 133 insertions(+), 35 deletions(-) create mode 100644 ecran_externe/.gitignore create mode 100644 ecran_externe/README.md create mode 100644 ecran_externe/device_id.txt create mode 100644 ecran_externe/test_minimal.yaml diff --git a/ecran_externe/.gitignore b/ecran_externe/.gitignore new file mode 100644 index 0000000..d8b4157 --- /dev/null +++ b/ecran_externe/.gitignore @@ -0,0 +1,5 @@ +# Gitignore settings for ESPHome +# This is an example and may include too much for your use-case. +# You can modify this file to suit your needs. +/.esphome/ +/secrets.yaml diff --git a/ecran_externe/README.md b/ecran_externe/README.md new file mode 100644 index 0000000..468f2c3 --- /dev/null +++ b/ecran_externe/README.md @@ -0,0 +1,3 @@ +`esphome run epaper_thread_node.yaml` + +`esphome logs epaper_thread_node.yaml` \ No newline at end of file diff --git a/ecran_externe/device_id.txt b/ecran_externe/device_id.txt new file mode 100644 index 0000000..e440e5c --- /dev/null +++ b/ecran_externe/device_id.txt @@ -0,0 +1 @@ +3 \ No newline at end of file diff --git a/ecran_externe/epaper_thread_node.yaml b/ecran_externe/epaper_thread_node.yaml index bbce29c..4a4313b 100644 --- a/ecran_externe/epaper_thread_node.yaml +++ b/ecran_externe/epaper_thread_node.yaml @@ -1,55 +1,115 @@ +substitutions: + device_id: !include device_id.txt + esphome: - name: epaper-display-node + name: epaper-node + friendly_name: "Microwave Thread Display Node" + on_boot: + priority: -100.0 + then: + - component.update: my_display esp32: board: esp32-h2-devkitm-1 variant: esp32h2 framework: type: esp-idf + advanced: + loop_task_stack_size: 32768 + sdkconfig_options: + CONFIG_ESP_MAIN_TASK_STACK_SIZE: "16384" + CONFIG_OPENTHREAD_TASK_STACK_SIZE: "8192" + CONFIG_ESP_WIFI_ENABLED: "n" + CONFIG_OPENTHREAD_ENABLED: "y" + CONFIG_MBEDTLS_DYNAMIC_BUFFER: "y" + CONFIG_MBEDTLS_DYNAMIC_FREE_CONFIG_DATA: "y" -# OpenThread configuration joining the Pi's Thread network +logger: + level: INFO + hardware_uart: UART0 + +network: + enable_ipv6: true + +# ------------------------------------------------------------------- +# OpenThread Network Settings +# ------------------------------------------------------------------- openthread: - network: - enable_ipv6: true - network_name: "OpenThread-Pi" # Must match OTBR - pan_id: 0x1234 # Must match OTBR - channel: 15 # Must match OTBR - network_key: "00112233445566778899aabbccddeeff" # Must match OTBR + network_name: "OpenThread-7f41" + pan_id: 0x7f41 + channel: 24 + network_key: "0x3f543281275a135e38982974aa71e987" + force_dataset: true -# MQTT Client connecting over Thread (IPv6) +# ------------------------------------------------------------------- +# MQTT Connection over Thread IPv6 +# ------------------------------------------------------------------- mqtt: - broker: "fdde:ad00:beef:0::1" # RPi OTBR wpan0 IPv6 address - port: 1883 + broker: "fd1a:dbbe:7435:e954:4455:28c5:b6cf:e990" + port: 8884 + skip_cert_cn_check: true topic_prefix: microwave/display + keepalive: 60s + on_connect: + - mqtt.publish: + topic: smartwave/hello + payload: !lambda |- + return std::string("{\"id_microwave\":\"") + "${device_id}" + "\",\"type\":\"externalDisplay\"}"; + on_message: + - topic: microwave/display/status + then: + - text_sensor.template.publish: + id: status_message + state: !lambda 'return x;' + - component.update: my_display +# ------------------------------------------------------------------- +# Template Text Sensor +# ------------------------------------------------------------------- +text_sensor: + - platform: template + name: "Display Status Message" + id: status_message + +# ------------------------------------------------------------------- +# Hardware SPI Pin Mapping (ESP32-H2) +# ------------------------------------------------------------------- spi: clk_pin: GPIO10 mosi_pin: GPIO11 -display: - - platform: waveshare_epaper - cs_pin: GPIO8 - dc_pin: GPIO12 - reset_pin: GPIO13 - busy_pin: GPIO14 - model: 2.13in-d - update_interval: never # Updated explicitly via text sensor - id: my_epaper - pages: - - id: status_page - lambda: |- - it.printf(0, 0, id(font_small), "Status: %s", id(display_text).state.c_str()); - +# ------------------------------------------------------------------- +# Fonts +# ------------------------------------------------------------------- font: - file: "gfonts://Roboto" - id: font_small - size: 16 + id: font_header + size: 18 + - file: "gfonts://Roboto" + id: font_body + size: 12 -text_sensor: - - platform: mqtt - name: "Display Text Input" - id: display_text - state_topic: "microwave/display/text" - on_value: - then: - - component.update: my_epaper \ No newline at end of file +# ------------------------------------------------------------------- +# Waveshare 2.13-inch e-Paper Display (V4 panel = 2.13inv3 in ESPHome) +# ------------------------------------------------------------------- +display: + - platform: waveshare_epaper + cs_pin: GPIO4 + dc_pin: GPIO1 + reset_pin: GPIO2 + busy_pin: GPIO3 + model: 2.13inv3 + rotation: 90° + update_interval: 30s + id: my_display + lambda: |- + if (id(status_message).has_state()) { + it.print(5, 3, id(font_header), "MICROWAVE STATUS"); + it.line(0, 20, it.get_width(), 20); + it.print(5, 25, id(font_body), id(status_message).state.c_str()); + } else { + int center_x = it.get_width() / 2; + int center_y = it.get_height() / 2; + + it.printf(center_x, center_y, id(font_header), TextAlign::CENTER, "SmartWave"); + } \ No newline at end of file diff --git a/ecran_externe/test_minimal.yaml b/ecran_externe/test_minimal.yaml new file mode 100644 index 0000000..c2de3ba --- /dev/null +++ b/ecran_externe/test_minimal.yaml @@ -0,0 +1,29 @@ +esphome: + name: h2-test-node + +esp32: + board: esp32-h2-devkitm-1 + variant: esp32h2 + framework: + type: esp-idf + advanced: + loop_task_stack_size: 16384 + sdkconfig_options: + CONFIG_ESP_MAIN_TASK_STACK_SIZE: "16384" + CONFIG_OPENTHREAD_TASK_STACK_SIZE: "8192" + CONFIG_ESP_WIFI_ENABLED: "n" + CONFIG_OPENTHREAD_ENABLED: "y" + CONFIG_ESP_CONSOLE_UART_DEFAULT: "y" + +logger: + level: INFO + hardware_uart: UART0 + +network: + enable_ipv6: true + +openthread: + network_name: "OpenThread-7f41" + pan_id: 0x7f41 + channel: 24 + network_key: "0x3f543281275a135e38982974aa71e987" \ No newline at end of file