From 56abf44a56bbc1f8e87e9295f0b4d8ddea6b50bf Mon Sep 17 00:00:00 2001 From: Sebastian Muszynski Date: Thu, 5 Sep 2024 12:55:53 +0200 Subject: [PATCH] Add UART transmitter/receiver example (#70) --- .github/workflows/ci.yaml | 10 ++++++++++ tests/esp32-uart-trx1.yaml | 41 ++++++++++++++++++++++++++++++++++++++ tests/esp32-uart-trx2.yaml | 41 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 92 insertions(+) create mode 100644 tests/esp32-uart-trx1.yaml create mode 100644 tests/esp32-uart-trx2.yaml diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index ee92d4a..a55c1b8 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -36,6 +36,16 @@ jobs: pip install esphome pip list esphome version + + - name: Write tests/secrets.yaml + shell: bash + run: 'echo -e "wifi_ssid: ssid\nwifi_password: password\nmqtt_host: host\nmqtt_username: username\nmqtt_password: password" > tests/secrets.yaml' + - name: Validate test configurations + run: | + for YAML in tests/esp*.yaml; do + esphome -s external_components_source ../components config $YAML >/dev/null + done + - name: Write secrets.yaml shell: bash run: 'echo -e "wifi_ssid: ssid\nwifi_password: password\nmqtt_host: host\nmqtt_username: username\nmqtt_password: password" > secrets.yaml' diff --git a/tests/esp32-uart-trx1.yaml b/tests/esp32-uart-trx1.yaml new file mode 100644 index 0000000..8d3c4d3 --- /dev/null +++ b/tests/esp32-uart-trx1.yaml @@ -0,0 +1,41 @@ +substitutions: + name: uart-trx1 + tx_pin: GPIO16 + rx_pin: GPIO17 + +esphome: + name: ${name} + min_version: 2024.6.0 + +esp32: + board: wemos_d1_mini32 + framework: + type: esp-idf + +wifi: + ssid: !secret wifi_ssid + password: !secret wifi_password + +ota: + platform: esphome + +logger: + level: DEBUG + +api: + +uart: + - id: uart_0 + baud_rate: 9600 + tx_pin: ${tx_pin} + rx_pin: ${rx_pin} + debug: + direction: BOTH + dummy_receiver: true + +interval: + - interval: 1s + then: + - uart.write: + id: uart_0 + data: "Hello from ${name}" diff --git a/tests/esp32-uart-trx2.yaml b/tests/esp32-uart-trx2.yaml new file mode 100644 index 0000000..7713efb --- /dev/null +++ b/tests/esp32-uart-trx2.yaml @@ -0,0 +1,41 @@ +substitutions: + name: uart-trx2 + tx_pin: GPIO16 + rx_pin: GPIO17 + +esphome: + name: ${name} + min_version: 2024.6.0 + +esp32: + board: wemos_d1_mini32 + framework: + type: esp-idf + +wifi: + ssid: !secret wifi_ssid + password: !secret wifi_password + +ota: + platform: esphome + +logger: + level: DEBUG + +api: + +uart: + - id: uart_0 + baud_rate: 9600 + tx_pin: ${tx_pin} + rx_pin: ${rx_pin} + debug: + direction: BOTH + dummy_receiver: true + +interval: + - interval: 1s + then: + - uart.write: + id: uart_0 + data: "Hello from ${name}"