diff --git a/example/mr24hpc1_mmwave_kit_arduino.yaml b/example/mr24hpc1_mmwave_kit_arduino.yaml new file mode 100644 index 0000000..e9e15f1 --- /dev/null +++ b/example/mr24hpc1_mmwave_kit_arduino.yaml @@ -0,0 +1,542 @@ +substitutions: + name: "seeedstudio-mmwave-kit" + friendly_name: "SeeedStudio mmWave Kit" + +esphome: + name: "${name}" + friendly_name: "${friendly_name}" + name_add_mac_suffix: true + project: + name: "seeedstudio.mmwave_kit" + version: "1.1" + platformio_options: + board_build.flash_mode: dio + board_build.mcu: esp32c3 + board_build.extra_flags: + - "-DARDUINO_USB_CDC_ON_BOOT=0" # Override, defaults to '-DARDUINO_USB_CDC_ON_BOOT=1' + includes: + - ../headers/mr24hpc1_mmwave_kit.h + +esp32: + board: seeed_xiao_esp32c3 + variant: esp32c3 + framework: + type: arduino + platform_version: 5.4.0 + +# Enable logging +logger: + hardware_uart: UART0 + level: DEBUG + +# Enable Home Assistant API +api: + +ota: + +dashboard_import: + package_import_url: github://limengdu/MR24HPC1_HomeAssistant/example/mr24hpc1_mmwave_kit_arduino.yaml@mmwave-kit + +wifi: + # Enable fallback hotspot (captive portal) in case wifi connection fails + ap: + ssid: "mmwave-kit" + +captive_portal: + +# Sets up Bluetooth LE (Only on ESP32) to allow the user +# to provision wifi credentials to the device. +esp32_improv: + authorizer: none + +# Sets up the improv via serial client for Wi-Fi provisioning. +# Handy if your device has a usb port for the user to add credentials when they first get it. +# improv_serial: # Commented until improv works with usb-jtag on idf + +uart: + id: uart_bus + baud_rate: 115200 + rx_pin: 4 + tx_pin: 5 + +select: + - platform: template + name: "Scene Settings" + id: scene_mode + icon: mdi:hoop-house + optimistic: true + options: + - "None" + - "Living Room" + - "Area Detection" + - "Washroom" + - "Bedroom" + initial_option: "Living Room" + set_action: + - logger.log: + format: "set action option: %s" + args: ["x.c_str()"] + - uart.write: !lambda auto index = id(scene_mode).index_of(x); + uint8_t value = (uint8_t)index.value() + 1; + uint8_t crc = value + 0xB9; + return {0x53,0x59,0x05,0x07,0x00,0x01,value,crc,0x54,0x43}; + + - platform: template + name: "Time For Entering No Person State Setting (Standard Function)" + id: unmanned_time + icon: mdi:timeline-clock + optimistic: true + options: + - "none" + - "10s" + - "30s" + - "1min" + - "2min" + - "5min" + - "10min" + - "30min" + - "60min" + initial_option: "none" + set_action: + - logger.log: + format: "Chosen option: %s" + args: ["x.c_str()"] + - uart.write: !lambda auto index = id(unmanned_time).index_of(x); + uint8_t value = (uint8_t)index.value(); + uint8_t crc = value + 0x37; + return {0x53,0x59,0x80,0x0a,0x00,0x01,value,crc,0x54,0x43}; + + - platform: template + name: "Existence Perception Boundary Settings" + id: custom_presence_of_perception_boundary + optimistic: true + options: + - "0.5m" + - "1.0m" + - "1.5m" + - "2.0m" + - "2.5m" + - "3.0m" + - "3.5m" + - "4.0m" + - "4.5m" + - "5.0m" + set_action: + - logger.log: + format: "Chosen option: %s" + args: ["x.c_str()"] + - uart.write: + !lambda auto index = id(custom_presence_of_perception_boundary).index_of(x); + uint8_t value = (uint8_t)index.value() + 1; + uint8_t crc = value + 0xBF; + return {0x53,0x59,0x08,0x0a,0x00,0x01,value,crc,0x54,0x43}; + + - platform: template + name: "Motion Trigger Boundary Setting" + id: custom_motion_trigger_boundary + optimistic: true + options: + - "0.5m" + - "1.0m" + - "1.5m" + - "2.0m" + - "2.5m" + - "3.0m" + - "3.5m" + - "4.0m" + - "4.5m" + - "5.0m" + set_action: + - logger.log: + format: "Chosen option: %s" + args: ["x.c_str()"] + - uart.write: + !lambda auto index = id(custom_motion_trigger_boundary).index_of(x); + uint8_t value = (uint8_t)index.value() + 1; + uint8_t crc = value + 0xC0; + return {0x53,0x59,0x08,0x0b,0x00,0x01,value,crc,0x54,0x43}; + +number: + - platform: template + id: sensitivity + name: "Sensitivity Settings" + icon: mdi:archive-check-outline + min_value: 0 + max_value: 3 + optimistic: false + step: 1 + update_interval: 2s + set_action: + - uart.write: !lambda uint8_t crc = x + 0xBA; + return {0x53,0x59,0x05,0x08,0x00,0x01,(uint8_t)x,crc,0x54,0x43}; + + - platform: template + name: "Existence Judgment Threshold Settings" + id: custom_judgment_threshold_exists + min_value: 0 + max_value: 250 + step: 1 + set_action: + - uart.write: !lambda int crc = 0xBD + (int)x; + return {0x53,0x59,0x08,0x08,0x00,0x01,(uint8_t)x,(uint8_t)crc,0x54,0x43}; + + - platform: template + name: "Motion Trigger Threshold Settings" + id: custom_motion_amplitude_trigger_threshold + min_value: 0 + max_value: 250 + step: 1 + set_action: + - uart.write: !lambda int crc = 0xBE + (int)x; + return {0x53,0x59,0x08,0x09,0x00,0x01,(uint8_t)x,(uint8_t)crc,0x54,0x43}; + + - platform: template + name: "Custom Mode Settings" + id: custom_mode_settings + icon: mdi:cog + min_value: 0 + max_value: 4 + step: 1 + set_action: + - uart.write: !lambda int crc = 0xBB + (int)x; + return {0x53,0x59,0x05,0x09,0x00,0x01,(uint8_t)x,(uint8_t)crc,0x54,0x43}; + + - platform: template + name: "Motion Trigger Time Setting" + id: custom_motion_trigger_time + icon: mdi:camera-timer + unit_of_measurement: "ms" + min_value: 0 + max_value: 4294967295 + step: 100 + set_action: + - uart.write: !lambda int h24_num = ((int)x >> 24) & 0xff; + int h16_num = ((int)x >> 16) & 0xff; + int h8_num = ((int)x >> 8) & 0xff; + int l8_num = (int)x & 0xff; + int crc = 0xC4 + h24_num + h16_num + h8_num + l8_num; + return {0x53,0x59,0x08,0x0c,0x00,0x04,(uint8_t)h24_num,(uint8_t)h16_num,(uint8_t)h8_num,(uint8_t)l8_num,(uint8_t)crc,0x54,0x43}; + + - platform: template + name: "Motion To Rest Time Setting" + id: custom_movement_to_rest_time + icon: mdi:camera-timer + unit_of_measurement: "ms" + min_value: 0 + max_value: 4294967295 + step: 1000 + set_action: + - uart.write: !lambda int h24_num = ((int)x >> 24) & 0xff; + int h16_num = ((int)x >> 16) & 0xff; + int h8_num = ((int)x >> 8) & 0xff; + int l8_num = (int)x & 0xff; + int crc = 0xC5 + h24_num + h16_num + h8_num + l8_num; + return {0x53,0x59,0x08,0x0d,0x00,0x04,(uint8_t)h24_num,(uint8_t)h16_num,(uint8_t)h8_num,(uint8_t)l8_num,(uint8_t)crc,0x54,0x43}; + + - platform: template + name: "Time For Entering No Person State Setting (Underlying Open Function)" + id: custom_time_of_enter_unmanned + icon: mdi:camera-timer + unit_of_measurement: "ms" + min_value: 0 + max_value: 4294967295 + step: 5000 + set_action: + - uart.write: !lambda int h24_num = ((int)x >> 24) & 0xff; + int h16_num = ((int)x >> 16) & 0xff; + int h8_num = ((int)x >> 8) & 0xff; + int l8_num = (int)x & 0xff; + int crc = 0xC6 + h24_num + h16_num + h8_num + l8_num; + return {0x53,0x59,0x08,0x0e,0x00,0x04,(uint8_t)h24_num,(uint8_t)h16_num,(uint8_t)h8_num,(uint8_t)l8_num,(uint8_t)crc,0x54,0x43}; + +text_sensor: + - platform: custom + lambda: |- + auto my_custom_sensor = new MyCustomTextSensor(); + App.register_component(my_custom_sensor); + return {my_custom_sensor->Heartbeat}; + + text_sensors: + - name: "Standard Heartbeat" + icon: mdi:connection + + - platform: template + name: "Product Model" + id: product_mode + icon: mdi:information-outline + on_raw_value: + then: + - logger.log: text_sensor on_raw_value + + - platform: template + name: "Product ID" + id: product_id + icon: mdi:information-outline + + - platform: template + name: "Hardware Model" + id: hardware_model + icon: mdi:information-outline + + - platform: template + name: "Firmware Version" + id: firmware_version + icon: mdi:information-outline + + - platform: template + name: "Active Reporting Of Proximity" + id: keep_away + icon: mdi:walk + + - platform: template + name: "Motion Information" + id: motion_status + icon: mdi:human-greeting + + - platform: template + name: "Presence Information" + id: someoneExists + icon: "mdi:motion-sensor" + + - platform: template + name: "Static Distance" + id: custom_presence_of_detection + icon: mdi:signal-distance-variant + +button: + - platform: template + name: "Module Reset" + id: "reset" + icon: mdi:reload + on_press: + then: + - logger.log: Button Pressed + - uart.write: + [0x53, 0x59, 0x01, 0x02, 0x00, 0x01, 0x0F, 0xBF, 0x54, 0x43] + + - platform: template + name: "End Of Custom Mode Settings" + id: custom_mode_setting_completed + icon: mdi:cog + on_press: + then: + - logger.log: Button Pressed + - uart.write: + [0x53, 0x59, 0x05, 0x0a, 0x00, 0x01, 0x0F, 0xCB, 0x54, 0x43] + + - platform: template + name: "Custom Mode Query" + icon: mdi:cog + id: custom_mode_query + on_press: + then: + - logger.log: Button Pressed + - uart.write: + [0x53, 0x59, 0x05, 0x89, 0x00, 0x01, 0x0F, 0x4A, 0x54, 0x43] + + - platform: template + name: "Existence Energy Value Inquiry" + icon: mdi:cog + id: custom_spatial_static_value_query + on_press: + then: + - logger.log: Button Pressed + - uart.write: + [0x53, 0x59, 0x08, 0x81, 0x00, 0x01, 0x0F, 0x45, 0x54, 0x43] + + - platform: template + name: "Motion Energy Value Inquiry" + icon: mdi:cog + id: custom_spatial_motion_value_query + on_press: + then: + - logger.log: Button Pressed + - uart.write: + [0x53, 0x59, 0x08, 0x82, 0x00, 0x01, 0x0F, 0x46, 0x54, 0x43] + + - platform: template + name: "Static Distance Inquiry" + icon: mdi:cog + id: custom_presence_of_detection_query + on_press: + then: + - logger.log: Button Pressed + - uart.write: + [0x53, 0x59, 0x08, 0x83, 0x00, 0x01, 0x0F, 0x47, 0x54, 0x43] + + - platform: template + name: "Motion Distance Inquiry" + icon: mdi:cog + id: custom_motion_distance_query + on_press: + then: + - logger.log: Button Pressed + - uart.write: + [0x53, 0x59, 0x08, 0x84, 0x00, 0x01, 0x0F, 0x48, 0x54, 0x43] + + - platform: template + name: "Existence Judgment Threshold Inquiry" + icon: mdi:cog + id: custom_judgment_threshold_exists_query + on_press: + then: + - logger.log: Button Pressed + - uart.write: + [0x53, 0x59, 0x08, 0x88, 0x00, 0x01, 0x0F, 0x4C, 0x54, 0x43] + + - platform: template + name: "Motion Trigger Threshold Inquiry" + icon: mdi:cog + id: custom_motion_trigger_time_query + on_press: + then: + - logger.log: Button Pressed + - uart.write: + [0x53, 0x59, 0x08, 0x89, 0x00, 0x01, 0x0F, 0x4D, 0x54, 0x43] + + - platform: template + name: "Motion To Rest Time Setting Query" + icon: mdi:cog + id: custom_movement_to_rest_time_query + on_press: + then: + - logger.log: Button Pressed + - uart.write: + [0x53, 0x59, 0x08, 0x8d, 0x00, 0x01, 0x0F, 0x51, 0x54, 0x43] + + - platform: template + name: "Time For Entering No Person State Inquiry" + icon: mdi:cog + id: custom_time_of_enter_unmanned_query + on_press: + then: + - logger.log: Button Pressed + - uart.write: + [0x53, 0x59, 0x08, 0x8e, 0x00, 0x01, 0x0F, 0x52, 0x54, 0x43] + + - platform: template + name: "Proximity Inquiry" + icon: mdi:cog + id: proximity_query + on_press: + then: + - logger.log: Button Pressed + - uart.write: + [0x53, 0x59, 0x80, 0x8b, 0x00, 0x01, 0x0F, 0xc7, 0x54, 0x43] + +switch: + - platform: template + id: output_info_switch + name: "Underlying Open Function Info Output Switch" + icon: mdi:electric-switch + assumed_state: true + turn_on_action: + - uart.write: [0x53, 0x59, 0x08, 0x00, 0x00, 0x01, 0x01, 0xB6, 0x54, 0x43] + - lambda: !lambda |- + id(keep_away).publish_state(""); + id(motion_status).publish_state(""); + id(someoneExists).publish_state(""); + turn_off_action: + - uart.write: [0x53, 0x59, 0x08, 0x00, 0x00, 0x01, 0x00, 0xB5, 0x54, 0x43] + - lambda: !lambda |- + id(custom_spatial_static_value).publish_state(0.0f); + id(custom_spatial_motion_value).publish_state(0.0f); + id(custom_motion_distance).publish_state(0.0f); + id(custom_static_distance).publish_state(0.0f); + id(custom_motion_speed).publish_state(0.0f); + +sensor: + - platform: custom + lambda: |- + auto my_custom_sensor = new UartReadLineSensor(id(uart_bus)); + App.register_component(my_custom_sensor); + return { + my_custom_sensor->movementSigns, + my_custom_sensor->inited, + }; + sensors: + - name: "Body Movement Parameter" + id: movementSigns + icon: "mdi:human-greeting-variant" + device_class: "temperature" + state_class: "measurement" + + - name: "Initialization Status" + id: inited + icon: mdi:all-inclusive + + - platform: template + name: "Motion Distance" + id: custom_moving_of_detection + icon: mdi:signal-distance-variant + on_value: + then: + # - logger.log: Custom Motion distance on_value + - logger.log: + format: "Custom Motion distance on_value : %d" + args: ["x"] + on_raw_value: + then: + - logger.log: + format: "Custom Motion distance on_raw_value : %d" + args: ["x"] + + - platform: template + name: "Existence Energy Value" + id: existence_value_display + icon: mdi:counter + + - platform: template + name: "Motion Energy Value" + id: motion_value_display + icon: mdi:counter + + - platform: template + name: "Custom Mode" + id: custom_mode_display + icon: mdi:cog + + - platform: template + name: "Existence Judgment Threshold" + id: existence_judgment_display + icon: mdi:counter + + - platform: template + name: "Motion To Rest Time" + id: motion_to_rest_time_display + icon: mdi:timeline-clock + + - platform: template + name: "Motion Trigger Threshold" + id: motion_trigger_threshold_display + icon: mdi:counter + + - platform: template + name: "Time For Entering No Person State" + id: time_for_enter_no_person_state_display + icon: mdi:timeline-clock + + - platform: template + name: "Motion Distance (Proactive Reporting)" + id: custom_motion_distance + icon: mdi:signal-distance-variant + + - platform: template + name: "Static Distance (Proactive Reporting)" + id: custom_static_distance + icon: mdi:signal-distance-variant + + - platform: template + name: "Existence Energy Value (Proactive Reporting)" + id: custom_spatial_static_value + icon: mdi:counter + + - platform: template + name: "Motion Energy Value (Proactive Reporting)" + id: custom_spatial_motion_value + icon: mdi:counter + + - platform: template + name: "Motion Speed" + id: custom_motion_speed + icon: mdi:run-fast \ No newline at end of file