Advertisement
kornelremete

Presence sensor LD2412

Mar 21st, 2025
456
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
YAML 5.99 KB | Software | 0 0
  1. external_components:
  2.   - source:
  3.       type: git
  4.       url: https://github.com/Rihan9/LD2412
  5.       ref: main
  6.     components: [LD2412]
  7.  
  8. esphome:
  9.   name: presence
  10.   friendly_name: presence
  11.  
  12. esp32:
  13.   board: esp32-s3-devkitc-1
  14.   framework:
  15.     type: arduino
  16.  
  17. # Enable logging
  18. logger:
  19.   level: VERBOSE
  20.   baud_rate: 0
  21.  
  22. # Enable Home Assistant API
  23. api:
  24.   encryption:
  25.     key: "KKW3/SDHmRtsABvOJZU0auD8in/6JWcw+K5SvucWQzA="
  26.  
  27. ota:
  28.   - platform: esphome
  29.     password: "84c2ea524669d38cb881c50ecd14b333"
  30.  
  31. wifi:
  32.   ssid: !secret wifi_ssid
  33.   password: !secret wifi_password
  34.  
  35.   # Enable fallback hotspot (captive portal) in case wifi connection fails
  36.   ap:
  37.     ssid: "Presencetest Fallback Hotspot"
  38.     password: "mnevv5Ey3fQo"
  39.  
  40.  
  41. web_server:
  42.   port: 80
  43.  
  44.  
  45. captive_portal:
  46. uart:
  47.   id: uart_bus
  48.   rx_pin: GPIO6
  49.   tx_pin: GPIO7
  50.   baud_rate: 115200
  51.   parity: NONE
  52.   stop_bits: 1
  53.  
  54. LD2412:
  55.   id: ld2412
  56.   throttle: 3s
  57.  
  58. binary_sensor:
  59.   - platform: LD2412
  60.     has_target:
  61.       name: Presence
  62.     has_moving_target:
  63.       name: Moving Target
  64.     has_still_target:
  65.       name: Still Target
  66.  
  67. sensor:
  68.   - platform: LD2412
  69.     moving_distance:
  70.       name : Moving Distance
  71.     still_distance:
  72.       name: Still Distance
  73.     moving_energy:
  74.       name: Move Energy
  75.     still_energy:
  76.       name: Still Energy
  77.     detection_distance:
  78.       name: Detection Distance
  79.     light:
  80.       name: light
  81.     g0:
  82.       move_energy:
  83.         name: g00 move energy
  84.       still_energy:
  85.         name: g00 still energy
  86.     g1:
  87.       move_energy:
  88.         name: g01 move energy
  89.       still_energy:
  90.         name: g01 still energy
  91.     g2:
  92.       move_energy:
  93.         name: g02 move energy
  94.       still_energy:
  95.         name: g02 still energy
  96.     g3:
  97.       move_energy:
  98.         name: g03 move energy
  99.       still_energy:
  100.         name: g03 still energy
  101.     g4:
  102.       move_energy:
  103.         name: g04 move energy
  104.       still_energy:
  105.         name: g04 still energy
  106.     g5:
  107.       move_energy:
  108.         name: g05 move energy
  109.       still_energy:
  110.         name: g05 still energy
  111.     g6:
  112.       move_energy:
  113.         name: g06 move energy
  114.       still_energy:
  115.         name: g06 still energy
  116.     g7:
  117.       move_energy:
  118.         name: g07 move energy
  119.       still_energy:
  120.         name: g07 still energy
  121.     g8:
  122.       move_energy:
  123.         name: g08 move energy
  124.       still_energy:
  125.         name: g08 still energy
  126.     g9:
  127.       move_energy:
  128.         name: g09 move energy
  129.       still_energy:
  130.         name: g09 still energy
  131.     g10:
  132.       move_energy:
  133.         name: g10 move energy
  134.       still_energy:
  135.         name: g10 still energy
  136.     g11:
  137.       move_energy:
  138.         name: g11 move energy
  139.       still_energy:
  140.         name: g11 still energy
  141.     g12:
  142.       move_energy:
  143.         name: g12 move energy
  144.       still_energy:
  145.         name: g12 still energy
  146.     g13:
  147.       move_energy:
  148.         name: g13 move energy
  149.       still_energy:
  150.         name: g13 still energy
  151.  
  152. number:
  153.   - platform: LD2412
  154.     timeout:
  155.       name: "presence holding"
  156.     min_distance_gate:
  157.       name: "min distance gate"
  158.     max_distance_gate:
  159.       name: "max distance gate"
  160.     g0:
  161.       move_threshold:
  162.         name: g00 move threshold
  163.       still_threshold:
  164.         name: g00 still threshold
  165.     g1:
  166.       move_threshold:
  167.         name: g01 move threshold
  168.       still_threshold:
  169.         name: g01 still threshold
  170.     g2:
  171.       move_threshold:
  172.         name: g02 move threshold
  173.       still_threshold:
  174.         name: g02 still threshold
  175.     g3:
  176.       move_threshold:
  177.         name: g03 move threshold
  178.       still_threshold:
  179.         name: g03 still threshold
  180.     g4:
  181.       move_threshold:
  182.         name: g04 move threshold
  183.       still_threshold:
  184.         name: g04 still threshold
  185.     g5:
  186.       move_threshold:
  187.         name: g05 move threshold
  188.       still_threshold:
  189.         name: g05 still threshold
  190.     g6:
  191.       move_threshold:
  192.         name: g06 move threshold
  193.       still_threshold:
  194.         name: g06 still threshold
  195.     g7:
  196.       move_threshold:
  197.         name: g07 move threshold
  198.       still_threshold:
  199.         name: g07 still threshold
  200.     g8:
  201.       move_threshold:
  202.         name: g08 move threshold
  203.       still_threshold:
  204.         name: g08 still threshold
  205.     g9:
  206.       move_threshold:
  207.         name: g09 move threshold
  208.       still_threshold:
  209.         name: g09 still threshold
  210.     g10:
  211.       move_threshold:
  212.         name: g10 move threshold
  213.       still_threshold:
  214.         name: g10 still threshold
  215.     g11:
  216.       move_threshold:
  217.         name: g11 move threshold
  218.       still_threshold:
  219.         name: g11 still threshold
  220.     g12:
  221.       move_threshold:
  222.         name: g12 move threshold
  223.       still_threshold:
  224.         name: g12 still threshold
  225.     g13:
  226.       move_threshold:
  227.         name: g13 move threshold
  228.       still_threshold:
  229.         name: g13 still threshold
  230.  
  231. select:
  232.   - platform: LD2412
  233.     out_pin_level:
  234.       name: 'Hardware output pin level'
  235.     distance_resolution:
  236.       name: 'Distance resolution'
  237.     baud_rate:
  238.       name: "baud rate"
  239.       on_value:
  240.         - delay: 3s
  241.         - lambda: |-
  242.             id(uart_bus).flush();
  243.             uint32_t new_baud_rate = stoi(x);
  244.             ESP_LOGD("change_baud_rate", "Changing baud rate from %i to %i",id(uart_bus).get_baud_rate(), new_baud_rate);
  245.             if (id(uart_bus).get_baud_rate() != new_baud_rate) {
  246.             id(uart_bus).set_baud_rate(new_baud_rate);
  247.             id(uart_bus).load_settings();
  248.             }
  249.     mode:
  250.       name: "Mode"
  251. button:
  252.   - platform: LD2412
  253.     factory_reset:
  254.       name: "factory reset"
  255.     restart:
  256.       name: "restart"
  257.     query_params:
  258.       name: query params
  259.  
  260. text_sensor:
  261.   - platform: LD2412
  262.     version:
  263.       name: "firmware version"
  264.     mac_address:
  265.       name: "mac address"
  266. switch:
  267.   - platform: LD2412
  268.     bluetooth:
  269.       name: "Bluetooth"    
  270.  
  271. light:
  272.   - platform: status_led
  273.     name: "Status Led"
  274.     pin:
  275.       number: GPIO8
  276.       inverted: true
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement