From f1d0e2f953486651064a9d5672020a9ccb4f7e57 Mon Sep 17 00:00:00 2001 From: Benny Date: Sat, 5 Apr 2025 12:08:58 +0200 Subject: [PATCH] esphome config added Signed-off-by: Benny --- .gitignore | 1 + README.md | 71 ++++++++++++++++++- esphome.yaml | 158 ++++++++++++++++++++++++++++++++++++++++++ secrets_template.yaml | 23 ++++++ 4 files changed, 252 insertions(+), 1 deletion(-) create mode 100644 .gitignore create mode 100644 esphome.yaml create mode 100644 secrets_template.yaml diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..33a9299 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +secrets.yaml \ No newline at end of file diff --git a/README.md b/README.md index 2a212b2..a037e77 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,71 @@ -# ESP32-mmWave-Sensor +# Presence Sensor Project with ESP32-S3 Board and mmWave +ESPHome configuration for the HMMD mmWave Sensor S3KM1110 on an ESP32-S3 board. + +> **Tested with:** ESPHome version 2025.2.2 + +## Features + +- MQTT integration for Home Assistant +- Optional native Home Assistant API (disabled by default) +- Status LED via WS2812 +- WiFi fallback Access Point +- Easy customization via `secrets_template.yaml` + +## Getting Started + +### 1. Prepare secrets.yaml + +Copy the template and add your details: + +```bash +cp secrets_template.yaml secrets.yaml +``` + +### 2. Adjust device name (optional) + +Change the device name and friendly name at the top of the YAML: + +```yaml +substitutions: + device_name: presence_sensor + friendly_name: "Presence Sensor" +``` + +### 3. Flash your ESP32-S3 + +Use ESPHome CLI or Home Assistant ESPHome Add-On. + +### 4. Optional: Enable Home Assistant API + +Uncomment the `api:` section and provide the API encryption key in `secrets.yaml` if you prefer native API over MQTT. + +```yaml +# api: +# encryption: +# key: !secret api_encryption_key +``` + +### 5. Add to Home Assistant + +If using MQTT with discovery enabled, your device will appear automatically. + +## Hardware + +This configuration was tested with the following hardware: + +- ✅ HMMD mmWave Sensor (S3KM1110) + - [Amazon Link](https://www.amazon.de/gp/aw/d/B0CT8JTMJM) + - [Waveshare Wiki](https://www.waveshare.com/wiki/HMMD_mmWave_Sensor) + +- ✅ ESP32-S3 board (Waveshare ESP32-S3 Zero) + - [Amazon Link](https://www.amazon.de/Waveshare-Development-ESP32-S3FH4R2-Castellated-Applications/dp/B0CHYHGYRH?th=1&psc=1) + - [Waveshare Wiki](https://www.waveshare.com/wiki/ESP32-S3-Zero) + +**Wiring:** + +- ESP32-S3 TX (GPIO7) → Sensor RX +- ESP32-S3 RX (GPIO6) → Sensor TX +- Sensor VCC → 3.3V on ESP32-S3 +- Sensor GND → GND on ESP32-S3 +- WS2812 LED Data → GPIO21 on ESP32-S3 diff --git a/esphome.yaml b/esphome.yaml new file mode 100644 index 0000000..f66d126 --- /dev/null +++ b/esphome.yaml @@ -0,0 +1,158 @@ +substitutions: + device_name: presence_sensor # Change the device name here + friendly_name: "Presense Sensor" + +esphome: + name: ${device_name} + comment: "HMMD mmWave Sensor S3KM1110 - ${friendly_name}" + on_boot: + priority: 550.0 + then: + - light.turn_on: + id: led + brightness: 100% + red: 100% + green: 0% + blue: 0% + +esp32: + board: esp32-s3-devkitc-1 + framework: + type: arduino + +# Enable logging +logger: + hardware_uart: USB_CDC + +# Optional: Enable Home Assistant API (uncomment to use) +# api: +# encryption: +# key: !secret api_encryption_key + +mqtt: + broker: !secret mqtt_broker + port: !secret mqtt_port + username: !secret mqtt_username + password: !secret mqtt_password + reboot_timeout: 0s + discovery: true + birth_message: + topic: "${device_name}/status" + payload: "online" + will_message: + topic: "${device_name}/status" + payload: "offline" + on_connect: + then: + - light.turn_on: + id: led + brightness: 100% + red: 0% + green: 100% + blue: 0% + - delay: 3s + - light.turn_off: + id: led + +ota: + - platform: esphome + password: !secret ota_password + +wifi: + ssid: !secret wifi_ssid + password: !secret wifi_password + power_save_mode: none + + manual_ip: + static_ip: !secret device_ip + gateway: !secret gateway_ip + subnet: !secret subnet + + on_connect: + - light.turn_on: + id: led + brightness: 100% + red: 100% + green: 65% + blue: 0% + + ap: + ssid: "${friendly_name}" + password: !secret ap_password + +captive_portal: + +light: + - platform: esp32_rmt_led_strip + rgb_order: RGB + pin: GPIO21 + num_leds: 1 + chipset: ws2812 + id: led + rmt_channel: 0 + +# UART configuration +uart: + id: ld2420_uart + tx_pin: GPIO7 + rx_pin: GPIO6 + baud_rate: 115200 + parity: NONE + stop_bits: 1 + +# LD2420 sensor configuration +ld2420: + +text_sensor: + - platform: ld2420 + fw_version: + name: "LD2420 Firmware" + - platform: wifi_info + ip_address: + name: "${friendly_name} IP Address" + +sensor: + - platform: ld2420 + moving_distance: + name: "${friendly_name} Motion Distance" + +binary_sensor: + - platform: ld2420 + has_target: + name: "${friendly_name} Presence" + id: has_target + +select: + - platform: ld2420 + operating_mode: + name: "${friendly_name} Operating Mode" + +number: + - platform: ld2420 + presence_timeout: + name: "${friendly_name} Presence Timeout (s)" + min_gate_distance: + name: "${friendly_name} Minimum Distance (Gate)" + max_gate_distance: + name: "${friendly_name} Maximum Distance (Gate)" + gate_select: + name: "${friendly_name} Gate Selection (Gate Number)" + still_threshold: + name: "${friendly_name} Still Threshold (Sensitivity)" + move_threshold: + name: "${friendly_name} Motion Threshold (Sensitivity)" + gate_move_sensitivity: + name: "${friendly_name} Motion Sensitivity (Factor)" + gate_still_sensitivity: + name: "${friendly_name} Still Sensitivity (Factor)" + +button: + - platform: ld2420 + apply_config: + name: "${friendly_name} Apply Config" + factory_reset: + name: "${friendly_name} Factory Reset" + restart_module: + name: "${friendly_name} Sensor Restart" + revert_config: + name: "${friendly_name} Revert Changes" diff --git a/secrets_template.yaml b/secrets_template.yaml new file mode 100644 index 0000000..deba346 --- /dev/null +++ b/secrets_template.yaml @@ -0,0 +1,23 @@ +# WiFi Configuration +wifi_ssid: "YourWiFiSSID" +wifi_password: "YourWiFiPassword" + +# Manual IP configuration (adjust to your network) +device_ip: "192.168.50.100" +gateway_ip: "192.168.50.1" +subnet: "255.255.255.0" + +# Access Point fallback password +ap_password: "ChangeThisToASecurePassword" + +# OTA (Over-the-Air) Update password +ota_password: "YourOTAPassword" + +# MQTT configuration +mqtt_broker: "192.168.50.10" +mqtt_port: 1883 +mqtt_username: "mqtt_user" +mqtt_password: "mqtt_password" + +# Home Assistant API encryption key (only if you enable api:) +api_encryption_key: "your_api_encryption_key"