Build a smaller human body radar sensor using ESP32-S2 and LD2410C

What you described is really great, can you quote you to those who buy our diy radar? We will sign your name, and as a gift if you would like, we would like to give you 1 small radars (esp32-s2+ld2410c) of our design, you may need to send us privately an address that can be mailed internationally.

I’m not sure if this post is allowed here :innocent: :rofl: :joy: :stuck_out_tongue_winking_eye:

Yes, I’m happy for you to use my description for tweaking the sensitivity.

:smiley:Hello, Martin. This is Stella from HiLink. Thank you very much for using our products. I’ve consulted our engineers and the answer is as follows: When a person is at rest, the module detects the rise and fall of the chest cavity to determine if there is still a person present. Firstly, whether the installation position does not detect the chest rise and fall. Secondly, the stationary energy value can be adjusted downwards.

I hope the above answer is helpful to you. If you have any questions during the use, please feel free to contact me.
Whatsapp: +86 15986863266
Email: [email protected]

Hello, Martin. This is Stella from HiLink. Thank you very much for using our products. I have consulted our engineers and the answer is as follows: The Bluetooth module that comes with the 2410C is used to set up the module parameters and configurations, there is no data transmission function, if you want to connect via Bluetooth, you can add a Bluetooth module.

I hope the above answer is helpful to you. If you have any questions during the use, please feel free to contact me.
Whatsapp: +86 15986863266
Email: [email protected]

Built mine using LD2410C + Wemos S2 mini here also. With removable slip on mount.

3 Likes

Hi all,
I have tried to follow the instruction reported here and I believe to have succefully create my first presence detector.
Yesterday everything seems to work well but this morning I found the Esp32 S2 mini off line.

The funny thing is that the sensor seem still connected and working

How is possible?
Below my Yaml (based on screek one)

esphome:
  name: ld2410-ingresso
  comment: Screek Human Presence Sensor 1U
  friendly_name: LD2410 ingresso
  name_add_mac_suffix: True
  platformio_options:
    board_build.flash_mode: dio
    board_build.f_cpu: 80000000L
  on_boot:
    priority: 900
    then:
       lambda: |-
        id(cpu_speed) = ESP.getCpuFreqMHz() ;
  project: 
    name: Screek.Human_Presence_Sensor
    version: 1U
  min_version: 2023.6.1

globals:
   - id: cpu_speed
     type: int
     restore_value: no
     initial_value: '0'

external_components:
  # - source: github://screek-workshop/custom_components_support_for_screek_1u
  - source:
      type: git
      url: https://github.com/screek-workshop/custom_components_support_for_screek_1u
      ref: master
    # components: [ ld2410, uart ]

esp32:
  board: lolin_s2_mini
  framework:
    type: arduino
    version: 2.0.9
    platform_version: 6.3.2

improv_serial:

logger:
  hardware_uart: uart0

api:
  encryption:
    key: "xxx"

ota:
  password: "xxx"
  safe_mode: False
# By automatically importing to the console, 
# subsequent adjustments can be easily made without having to manually fix a specific name.
# dashboard_import:
#  package_import_url: github://screekworkshop/screek-human-sensor/1u/yaml/[email protected]
#  import_full_config: False

wifi:
  # power_save_mode: NONE
  output_power: 15dB
  power_save_mode: LIGHT
  reboot_timeout: 10min
  ssid: !secret wifi_ssid
  password: !secret wifi_password
  ap:
    ssid: "Ld2410-Ingresso Fallback Hotspot"
    password: "xxx"

captive_portal:

web_server:
  port: 80

binary_sensor:
  - platform: status
    name: Online
    id: ink_ha_connected
  - platform: ld2410
    has_target:
      name: Presence
    has_moving_target:
      name: Moving Target
    has_still_target:
      name: Still Target

sensor:
  - platform: template
    name: "ESP Cpu Speed"
    accuracy_decimals: 0
    unit_of_measurement: Mhz
    lambda: |-
      return (id(cpu_speed));
    entity_category: "diagnostic"

  # - platform: internal_temperature
  #   id: sys_esp_temperature
  #   name: ESP Temperature
  #   unit_of_measurement: °C
  #   device_class: TEMPERATURE
  #   update_interval: 1s
  #   entity_category: "diagnostic"

  - platform: template
    id: sys_esp_temperature
    name: ESP Temperature
    lambda: return temperatureRead();
    unit_of_measurement: °C
    device_class: TEMPERATURE
    update_interval: 5s
    entity_category: "diagnostic"

  - platform: uptime
    name: Uptime
    id: sys_uptime
    update_interval: 10s

  - platform: wifi_signal 
    name: RSSI
    id: wifi_signal_db
    update_interval: 5s
    entity_category: "diagnostic"

  - platform: template
    id: esp_memory
    icon: mdi:memory
    name: ESP Free Memory
    lambda: return heap_caps_get_free_size(MALLOC_CAP_INTERNAL) / 1024;
    unit_of_measurement: 'kB'
    state_class: measurement
    entity_category: "diagnostic"

  - platform: ld2410
    moving_distance:
      name : Moving Distance
      id: moving_distance
    still_distance:
      name: Still Distance
      id: still_distance
    moving_energy:
      name: Move Energy
    still_energy:
      name: Still Energy
    detection_distance:
      name: Detection Distanza
    light:
      name: Sun Light

light:
  - platform: status_led
    name: sys_status
    pin: GPIO15
    internal: True
    restore_mode: ALWAYS_OFF

time:
  - platform: sntp
    id: time_sntp

uart:
  id: uart_ld2410
  tx_pin: GPIO17
  rx_pin: GPIO16
  baud_rate: 256000
  parity: NONE
  stop_bits: 1

ld2410:
  timeout: 150s
  id: ld2410_radar
  # max_move_distance : 6m
  # max_still_distance: 0.75m
  # g0_move_threshold: 10
  # g0_still_threshold: 20
  # g1_move_threshold: 10
  # g1_still_threshold: 20
  # g2_move_threshold: 20
  # g2_still_threshold: 21
  # g3_move_threshold: 30
  # g3_still_threshold: 31
  # g4_move_threshold: 40
  # g4_still_threshold: 41
  # g5_move_threshold: 50
  # g5_still_threshold: 51
  # g6_move_threshold: 60
  # g6_still_threshold: 61
  # g7_move_threshold: 70
  # g7_still_threshold: 71
  # g8_move_threshold: 80
  # g8_still_threshold: 81

button:
  - platform: template
    name: "Enable LD2410 BLE"
    disabled_by_default: True #it was commented 
    entity_category: "config"
    icon: mdi:bluetooth
    on_press:
      lambda: |-
        id(ld2410_radar) -> ble_control(true);

  - platform: template
    name: "Disable LD2410 BLE"
    disabled_by_default: True
    entity_category: "config"
    icon: mdi:bluetooth-off
    on_press:
      lambda: |-
        id(ld2410_radar) -> ble_control(false);

  - platform: template
    name: "LD2410 Reboot"
    icon: mdi:radar
    entity_category: "config"
    on_press:
      lambda: |-
        // auto* radar = LD2410Component::get(ld2410); 
        // radar -> roboot();
        id(ld2410_radar) -> reboot();

  - platform: restart
    icon: mdi:power-cycle
    name: "ESP Reboot"

  - platform: factory_reset
    disabled_by_default: True
    name: Factory Reset
    id: factory_reset_all

The ESPhome dashboard uses mDNS to find the device unless you specify use_address in the WiFi config.

The ESPhome integration uses the IP address to communicate with the device.

So, likely just an mDNS issue causing it to show offline in the ESPHome dashboard.

What do you suggest to do? Repeat the Install procedure via USB?

I want to say that if you edit the config for it in the dashboard, add the “use_address” option, and save, the dashboard will immediately start using the IP instead of mDNS. So just changing the config may resolve it.

With that said. It looks like you might have the older config. So refreshing via USB may be the better route. You can try out my config that’s updated to use the ESPhome components for the LD2410C.

1 Like

I have used pins 16 and 17 for rx/tx so I should change the following section of the yaml, correct?

uart:
  tx_pin: GPIO18
  rx_pin: GPIO33
  baud_rate: 256000
  parity: NONE
  stop_bits: 1

I suppose I should also add the api key, correct?

Yes to changing the pins. The API key is only necessary if you feel so.

It works very well - thanks!.
There are still some entities not available but it should not be a problem.






Looking the log file I saw few warning messages

[14:23:22][W][component:214]: Component ld2410 took a long time for an operation (0.16 s).
[14:23:22][W][component:215]: Components should block for at most 20-30ms.
[14:23:23][D][binary_sensor:036]: 'Moving Target': Sending state OFF
[14:23:23][D][binary_sensor:036]: 'Still Target': Sending state ON

Regarding the Automation do you have a good proposal to use all the potentiality of LD2410C?
thanks again

do you have STL or thinkcad files for this case?

Hi! Can you share your yaml file ?

sure.

substitutions:
  # Set the device name
  name: ld2410-ingresso
  # Set the friendly name
  friendly_name: ld2410 ingresso
  # Provide the wifi SSID
  wifi: !secret wifi_ssid
  #Provide the wifi password
  wifi_pass: !secret wifi_password
  #Provide an OTA password:
  ota_pass: "d5f51f4af1af194556f70bf803220b08"

### No modifications needed below here ###
####################################################################################

esphome:
  name: $name
  friendly_name: $friendly_name
  platformio_options:
    board_build.flash_mode: dio
    board_build.f_cpu: 80000000L
  name_add_mac_suffix: false

wifi:
  ssid: $wifi
  password: $wifi_pass
  power_save_mode: NONE
  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
  output_power: 15db

captive_portal:

web_server:
  port: 80

esp32:
  board: lolin_s2_mini
  framework:
    type: esp-idf
  
api:
  encryption:
    key: "OuA4PpKklT38koJgASlo7EkfznEzvnrVa5I79Nw="

ota:
  password: $ota_pass

logger:
  level: DEBUG

uart:
  tx_pin: GPIO17
  rx_pin: GPIO16
  baud_rate: 256000
  parity: NONE
  stop_bits: 1

ld2410:

binary_sensor:
  - platform: ld2410
    has_target:
      name: Presence
    has_moving_target:
      name: Moving Target
    has_still_target:
      name: Still Target
    out_pin_presence_status:
      name: Out Pin Presence Status

sensor:
  - platform: ld2410
    light:
      name: Light
    moving_distance:
      name : Moving Distance
    still_distance:
      name: Still Distance
    moving_energy:
      name: Move Energy
    still_energy:
      name: Still Energy
    detection_distance:
      name: Detection Distance
    g0:
      move_energy:
        name: g0 move energy
      still_energy:
        name: g0 still energy
    g1:
      move_energy:
        name: g1 move energy
      still_energy:
        name: g1 still energy
    g2:
      move_energy:
        name: g2 move energy
      still_energy:
        name: g2 still energy
    g3:
      move_energy:
        name: g3 move energy
      still_energy:
        name: g3 still energy
    g4:
      move_energy:
        name: g4 move energy
      still_energy:
        name: g4 still energy
    g5:
      move_energy:
        name: g5 move energy
      still_energy:
        name: g5 still energy
    g6:
      move_energy:
        name: g6 move energy
      still_energy:
        name: g6 still energy
    g7:
      move_energy:
        name: g7 move energy
      still_energy:
        name: g7 still energy
    g8:
      move_energy:
        name: g8 move energy
      still_energy:
        name: g8 still energy
  - platform: internal_temperature
    name: ESP Temperature
    unit_of_measurement: °C
    device_class: TEMPERATURE
    update_interval: 30s
    entity_category: "diagnostic"
  - platform: uptime
    name: Uptime
    id: sys_uptime
    update_interval: 10s
  - platform: wifi_signal 
    name: WiFi RSSI
    id: wifi_signal_db
    update_interval: 30s
    entity_category: "diagnostic"

switch:
  - platform: ld2410
    engineering_mode:
      name: "LD2410 Engineering Mode"
    bluetooth:
      name: "LD2410 Bluetooth"

number:
  - platform: ld2410
    timeout:
      name: Timeout
    light_threshold:
      name: Light Threshold
    max_move_distance_gate:
      name: Max Move Distance Gate
    max_still_distance_gate:
      name: Max Still Distance Gate
    g0:
      move_threshold:
        name: g0 move threshold
      still_threshold:
        name: g0 still threshold
    g1:
      move_threshold:
        name: g1 move threshold
      still_threshold:
        name: g1 still threshold
    g2:
      move_threshold:
        name: g2 move threshold
      still_threshold:
        name: g2 still threshold
    g3:
      move_threshold:
        name: g3 move threshold
      still_threshold:
        name: g3 still threshold
    g4:
      move_threshold:
        name: g4 move threshold
      still_threshold:
        name: g4 still threshold
    g5:
      move_threshold:
        name: g5 move threshold
      still_threshold:
        name: g5 still threshold
    g6:
      move_threshold:
        name: g6 move threshold
      still_threshold:
        name: g6 still threshold
    g7:
      move_threshold:
        name: g7 move threshold
      still_threshold:
        name: g7 still threshold
    g8:
      move_threshold:
        name: g8 move threshold
      still_threshold:
        name: g8 still threshold

button:
  - platform: ld2410
    factory_reset:
      name: "LD2410 Factory Reset"
    restart:
      name: "LD2410 Reboot"
    query_params:
      name: "LD2410 Query Params"
  - platform: restart
    icon: mdi:power-cycle
    name: "ESP Reboot"

text_sensor:
  - platform: ld2410
    version:
      name: "LD2410 Firmware Version"
    mac_address:
      name: "LD2410 MAC Address"

select:
  - platform: ld2410
    distance_resolution:
      name: "Distance Resolution"
    baud_rate:
      name: "Baud Rate"
    light_function:
      name: Light Function
    out_pin_level:
      name: Out Pin Level

light:
  - platform: status_led
    name: sys_status
    pin: 
      number: GPIO15
      inverted: True
    internal: True
    restore_mode: ALWAYS_OFF
1 Like

I’m a total noob. When I install I get stuck here everytime.

INFO ESPHome 2024.2.2
INFO Reading configuration /config/esphome/guest-room-ps.yaml…
WARNING The selected Arduino framework version is not the recommended one. If there are connectivity or build issues please remove the manual version.
WARNING The selected Arduino framework version is not the recommended one. If there are connectivity or build issues please remove the manual version.
INFO Detected timezone ‘America/Chicago’
INFO Generating C++ source…
INFO Compiling app…
Processing screek-humen-sensor-1u (board: lolin_s2_mini; framework: arduino; platform: platformio/[email protected])

HARDWARE: ESP32S2 80MHz, 320KB RAM, 4MB Flash

  • toolchain-riscv32-esp @ 8.4.0+2021r2-patch5
  • toolchain-xtensa-esp32s2 @ 8.4.0+2021r2-patch5
    Dependency Graph
    |-- AsyncTCP-esphome @ 2.0.1
    |-- WiFi @ 2.0.0
    |-- FS @ 2.0.0
    |-- Update @ 2.0.0
    |-- ESPAsyncWebServer-esphome @ 3.1.0
    |-- DNSServer @ 2.0.0
    |-- ESPmDNS @ 2.0.0
    |-- noise-c @ 0.1.4
    |-- ArduinoJson @ 6.18.5
    |-- Improv @ 1.2.3
    RAM: [== ] 16.6% (used 54352 bytes from 327680 bytes)
    Flash: [===== ] 54.0% (used 990638 bytes from 1835008 bytes)
    ========================= [SUCCESS] Took 4.67 seconds =========================
    INFO Successfully compiled program.
    esptool.py v4.7.0
    Serial port /dev/ttyACM0
    Connecting…
    Chip is ESP32-S2FNR2 (revision v0.0)
    Features: WiFi, Embedded Flash 4MB, Embedded PSRAM 2MB, ADC and temperature sensor calibration in BLK2 of efuse V2
    Crystal is 40MHz
    MAC: 48:27:e2:58:4a:24
    Uploading stub…
    Running stub…
    Stub running…
    Changing baud rate to 460800
    Changed.
    Configuring flash size…
    Auto-detected Flash size: 4MB
    Flash will be erased from 0x00010000 to 0x00101fff…
    Flash will be erased from 0x00001000 to 0x00004fff…
    Flash will be erased from 0x00008000 to 0x00008fff…
    Flash will be erased from 0x0000e000 to 0x0000ffff…
    Compressed 991008 bytes to 667081…
    Wrote 991008 bytes (667081 compressed) at 0x00010000 in 7.4 seconds (effective 1078.6 kbit/s)…
    Hash of data verified.
    Compressed 13600 bytes to 9549…
    Wrote 13600 bytes (9549 compressed) at 0x00001000 in 0.2 seconds (effective 624.0 kbit/s)…
    Hash of data verified.
    Compressed 3072 bytes to 144…
    Wrote 3072 bytes (144 compressed) at 0x00008000 in 0.0 seconds (effective 672.6 kbit/s)…
    Hash of data verified.
    Compressed 8192 bytes to 47…
    Wrote 8192 bytes (47 compressed) at 0x0000e000 in 0.1 seconds (effective 909.9 kbit/s)…
    Hash of data verified.

Leaving…
Hard resetting via RTS pin…
INFO Successfully uploaded program.
INFO Starting log output from /dev/ttyACM0 with baud rate 115200

That looks fine to me. ESPhome tries to programmatically restart the esp board but that doesn’t work with the S2. You have to unplug/plug in or hit the reset button on the board.

Can someone provide code to turn off the blue flashing led???

For the current screek firmware uses an indicator light to indicate the networking status, which is automatically turned off once networking is complete.

1 Like