I remixed this enclosure for LD2410 sensor with an aht10+BMP280 sensor (but you could use most i2c sensors)
Heres the esphome code:
esphome:
name: ""--------------let esphome fill this in for you
friendly_name: ""--------------let esphome fill this in for you
includes:
- ld2410_uart.h
on_boot:
priority: 600...
then:
- lambda: |-
auto uart_component = static_cast<LD2410 *>(ld2410);
uart_component->setNumbers(maxMovingDistanceRange, maxStillDistanceRange, noneDuration);
esp8266:
board: esp12e
Enable logging
logger:
Enable Home Assistant API
api:
encryption:
key: ""--------------let esphome fill this in for you
ota:
- platform: esphome
password: ""--------------let esphome fill this in for you
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "Fallback Hotspot"
password: ""--------------let esphome fill this in for you
captive_portal:
i2c:
sda: GPIO4
scl: GPIO5
scan: true
id: bus_a
uart:
id: my_uart
tx_pin: TX
rx_pin: RX
baud_rate: 256000 # Change this according to your setting
parity: NONE
stop_bits: 1
debug:
direction: BOTH
dummy_receiver: false
after:
delimiter: [0xF8,0xF7,0xF6,0xF5]
light:
- platform: neopixelbus
type: GRB
variant: WS2812
pin: GPIO14
num_leds: 1
name: "Indicator Light"
custom_component:
- lambda: |-
return {new LD2410(id(my_uart))};
components:
binary_sensor:
- platform: custom
lambda: |-
auto uart_component = static_cast<LD2410 *>(ld2410);
return {uart_component->hasTarget,uart_component->hasMovingTarget,uart_component->hasStillTarget,uart_component->lastCommandSuccess};
binary_sensors:- name: "Target Detected"
- name: "Moving Target Detected"
- name: "Still Target Detected"
- name: "Command Success"
sensor:
- platform: aht10
humidity:
name: "Room Humidity"
update_interval: 20s
temperature:
name: "Room Temperature" - platform: bmp280
pressure:
name: "Air Pressure"
address: 0x77
update_interval: 60s
temperature:
name: "Air Temperature"
oversampling: 16x - platform: custom
lambda: |-
auto uart_component = static_cast<LD2410 *>(ld2410);
return {uart_component->movingTargetDistance,uart_component->movingTargetEnergy,uart_component->stillTargetDistance,uart_component->stillTargetEnergy,uart_component->detectDistance};
sensors:- name: "Distance to Moving Object"
unit_of_measurement: "cm"
accuracy_decimals: 0 - name: "Energy of Moving Object"
unit_of_measurement: "%"
accuracy_decimals: 0 - name: "Distance to Static Object"
unit_of_measurement: "cm"
accuracy_decimals: 0 - name: "Energy of Static Object"
unit_of_measurement: "%"
accuracy_decimals: 0 - name: "Overall Detection Distance"
unit_of_measurement: "cm"
accuracy_decimals: 0
number:
- platform: template
name: "Max Moving Range"
id: maxMovingDistanceRange
min_value: 1
max_value: 8
step: 1
update_interval: never
optimistic: true
set_action:- lambda: |-
auto uart_component = static_cast<LD2410 *>(ld2410);
uart_component->setMaxDistancesAndNoneDuration(x,id(maxStillDistanceRange).state,id(noneDuration).state);
- platform: template
name: "Max Static Range"
id: maxStillDistanceRange
min_value: 1
max_value: 8
step: 1
update_interval: never
optimistic: true
set_action:- lambda: |-
auto uart_component = static_cast<LD2410 *>(ld2410);
uart_component->setMaxDistancesAndNoneDuration(id(maxMovingDistanceRange).state,x,id(noneDuration).state);
- platform: template
name: "No Detection Timeout"
id: noneDuration
min_value: 0
max_value: 32767
step: 1
mode: box
update_interval: never
optimistic: true
set_action:- lambda: |-
auto uart_component = static_cast<LD2410 *>(ld2410);
uart_component->setMaxDistancesAndNoneDuration(id(maxMovingDistanceRange).state,id(maxStillDistanceRange).state,x);
button:
- platform: template
name: "Restart mmWave Sensor"
on_press:
lambda: 'static_cast<LD2410 *>(ld2410)->reboot();' - platform: template
name: "Enable Config Mode"
on_press:- lambda: 'static_cast<LD2410 *>(ld2410)->setConfigMode(true);'
- platform: template
name: "Disable Config Mode"
on_press:- lambda: 'static_cast<LD2410 *>(ld2410)->setConfigMode(false);'
- platform: template
name: "Get Current Settings"
on_press:- lambda: 'static_cast<LD2410 *>(ld2410)->queryParameters();'
- platform: template
name: "Set High Baud Rate 256000bps"
on_press:- lambda: 'static_cast<LD2410 *>(ld2410)->setBaudrate(7);'
- platform: template
name: "Set Medium Baud Rate 115200bps"
on_press:- lambda: 'static_cast<LD2410 *>(ld2410)->setBaudrate(5);'
- platform: template
name: "Set Low Baud Rate 9600bps"
on_press:- lambda: 'static_cast<LD2410 *>(ld2410)->setBaudrate(1);'