HLK-LD2450 Initial experiments to connect to HomeAssistant

I have LD2410 in a small PLA case. I made front plate pretty thin (1mm) and i didn’t notice and degradation in range. I guess it’s a good idea to leave as little as possible between sensor and front plate, to eliminate any reflections, though.

Did you manage to fix this? I’m having the same issue.

Switch TX with RX.
Had same problem.
I see lots of posts/people saying to connect RX to RX and TX to TX. Not in my case.

I’ve seen the same thing. However, I don’t think that is correct. Usually transmit (TX) on one end connects to receive (RX) of the other Since I’m using a D1 mini (esp8266) and powering through the USB I’ve read that this may disable the RX pin which is why I moved the pins. However, I’m using Uncle Yura package and if his solution is hardwired to pins 1 & 3, that would explain why it doesn’t work for me. My next step is to use an ESP board vs the ESP8266.

I am using D1 Mini+LD2450+Yura package, and yes, I had to to connect TX-RX and RX to TX to see data coming in(the logic thinking).
But in another project I use a RS485-TTL converter (3.3V), and in that one I had to connect TX-TX and RX to RX. Also in that converter I cannot use UART pins due to pull ups, so I choose D2-D1 as UART

I tried it with and without front plate as below before, the result was same !

1 Like

Yep, I tried, it is 50/50, on one it is working great, on other 2410 went crazy, however if I switch 2410 to low distance settings it is always working correctly.

I tried it multiple times, even with ld2450, I asked them to enable cloud point instead of processed data (as it is in LD6002), they promised and nothing happen for months

1 Like

just wondering if there is an alternative way to integrate this kind of sensor in HA without using esphome…
i commonly code my ESP devices and then use mqtt integration to take data to my HA, but i think there is not a “mqtt presence sensor” in ha, am i wrong?
half of the fun is gone if i use esphome :slight_smile:

binary sensor with device_class presence

Most often I am using TCP/UDP UART proxy

1 Like

well i assume this is just a… binary sensor so no “radar”, no x-y-z values and so on…
what about this?

it is just a device with multiple sensors, presence is binary sensor, x,y,z are numeric sensors etc.

ad UART:
I am just getting stream and parsing it locally, in python or js (node red)
Then when I am happy with solution I am writing C code for esp or for esphome.

2 Likes

I finally got mine as well. Tested 4 diffrent ld2450 and 4 ld2410. Distance between sensors 4cm and never got bad readings. Maybe it’s firmware issue or orientation (my ld2450 is vertical, ld2410 horizontal) which causes problems.

1 Like

Have you tried LD2450 with multi-target mode? In my case, the reading is not stable. 2 actual target become 1 target by reading data sometimes and 1 actual target become 2 target by reading data sometimes. total 10pcs LD2450 I have and all of them have same problem in multi-target mode. single target mode is no problem. (my LD2450 is vertical too).
so far, only LD2410B/C is OK for me due to its sensitivity can be adjusted. it should be better if LD2450 and LD2461 can be adjusted too. after all, the environment is a variable. of course, this is just my personal opinion!

1 Like

Ihave being trying to display the correct measurments using everything lite code, but I always have x10 report.
Cannot find where the issue is.
Radartool is in meters, but no matter what I type in code, I am always x10 off.


In picture I should have been at 69cm not 699cm.
If I change to mm in code, I will be at 6,999mm.

esphome:
  name: sensor-ld2450
  friendly_name: Sensor LD2450
  on_boot: 
    #priority: -100
    then:
      - binary_sensor.template.publish:
          id: zone1_occupancy
          state: false 
      - binary_sensor.template.publish:
          id: zone2_occupancy
          state: false 
      - binary_sensor.template.publish:
          id: zone3_occupancy
          state: false 
      - binary_sensor.template.publish:
          id: zone4_occupancy
          state: false

esp8266:
  board: d1_mini




# Enable logging
logger:
  baud_rate: 0
# Enable Home Assistant API
api:
  encryption:
    key: "fcdzAmBrk05F3Wvuy4A1/CAVXOifzTlhoaOq65qelhc="

ota:
  password: "ca30386623e727f82c9f65a84073c979"

web_server:
  port: 80

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Sensor-Ld2450 Fallback Hotspot"
    password: "XhHRVlT3jwep"


captive_portal:

globals:
  - id: mmwave_update_time
    type: unsigned long
    restore_value: no
    initial_value: '0'

binary_sensor:
  - platform: template
    name: "Occupancy"
    device_class: occupancy
    filters:
      - delayed_off: !lambda return (id(off_delay).state * 1000);
    lambda: |-
      return (id(target1_distance).state != 0
        || id(target2_distance).state != 0
        || id(target3_distance).state != 0);
  - platform: template
    name: "Zone 1 Occupancy"
    id: zone1_occupancy
    filters:
      - delayed_off: !lambda return (id(zone_1_off_delay).state * 1000);
  - platform: template
    name: "Zone 2 Occupancy"
    id: zone2_occupancy
    filters:
      - delayed_off: !lambda return (id(zone_2_off_delay).state * 1000);
    disabled_by_default: true
  - platform: template
    name: "Zone 3 Occupancy"
    id: zone3_occupancy
    filters:
      - delayed_off: !lambda return (id(zone_3_off_delay).state * 1000);
    disabled_by_default: true
  - platform: template
    name: "Zone 4 Occupancy"
    id: zone4_occupancy
    filters:
      - delayed_off: !lambda return (id(zone_4_off_delay).state * 1000);
    disabled_by_default: true
  - platform: template
    name: "Target 1 Active"
    id: target1_active
    lambda: |-
      return id(target1_distance).state != 0;
  - platform: template
    name: "Target 2 Active"
    id: target2_active
    lambda: |-
      return id(target2_distance).state != 0;
  - platform: template
    name: "Target 3 Active"
    id: target3_active
    lambda: |-
      return id(target3_distance).state != 0;

number:
  - platform: template
    name: "Occupancy Off Delay"
    id: off_delay
    max_value: 600
    min_value: 0
    step: 1
    optimistic: True
    restore_value: True
    unit_of_measurement: "s"
    initial_value: 2
  - platform: template
    name: "Max Distance"
    id: distance
    max_value: 600
    min_value: 0
    unit_of_measurement: "cm"
    step: 1
    optimistic: True
    restore_value: True
    initial_value: 600

  - platform: template
    name: "Zone 1 Begin X"
    id: zone1_begin_x
    max_value: 4000
    min_value: -4000
    unit_of_measurement: "mm"
    step: 10
    optimistic: True
    restore_value: True
    initial_value: -4000
  - platform: template
    name: "Zone 1 End X"
    id: zone1_end_x
    max_value: 4000
    min_value: -4000
    unit_of_measurement: "mm"
    step: 10
    optimistic: True
    restore_value: True
    initial_value: 4000
  - platform: template
    name: "Zone 1 Begin Y"
    id: zone1_begin_y
    max_value: 6000
    min_value: 0
    unit_of_measurement: "mm"
    step: 10
    optimistic: True
    restore_value: True
    initial_value: 0
  - platform: template
    name: "Zone 1 End Y"
    id: zone1_end_y
    max_value: 6000
    min_value: 0
    unit_of_measurement: "mm"
    step: 10
    optimistic: True
    restore_value: True
    initial_value: 6000
  - platform: template
    name: "Zone 1 Occupancy Off Delay"
    id: zone_1_off_delay
    max_value: 600
    min_value: 0
    step: 1
    optimistic: True
    restore_value: True
    unit_of_measurement: "s"
    initial_value: 15

  - platform: template
    name: "Zone 2 Begin X"
    id: zone2_begin_x
    max_value: 4000
    min_value: -4000
    unit_of_measurement: "mm"
    step: 10
    optimistic: True
    restore_value: True
    disabled_by_default: true
  - platform: template
    name: "Zone 2 End X"
    id: zone2_end_x
    max_value: 4000
    min_value: -4000
    unit_of_measurement: "mm"
    step: 10
    optimistic: True
    restore_value: True
    disabled_by_default: true
  - platform: template
    name: "Zone 2 Begin Y"
    id: zone2_begin_y
    max_value: 6000
    min_value: 0
    unit_of_measurement: "mm"
    step: 10
    optimistic: True
    restore_value: True
    disabled_by_default: true
  - platform: template
    name: "Zone 2 End Y"
    id: zone2_end_y
    max_value: 6000
    min_value: 0
    unit_of_measurement: "mm"
    step: 10
    optimistic: True
    restore_value: True
    disabled_by_default: true
  - platform: template
    name: "Zone 2 Occupancy Off Delay"
    id: zone_2_off_delay
    max_value: 600
    min_value: 0
    step: 1
    optimistic: True
    restore_value: True
    unit_of_measurement: "s"
    initial_value: 15
    disabled_by_default: true

  - platform: template
    name: "Zone 3 Begin X"
    id: zone3_begin_x
    max_value: 4000
    min_value: -4000
    unit_of_measurement: "mm"
    step: 10
    optimistic: True
    restore_value: True
    disabled_by_default: true
  - platform: template
    name: "Zone 3 End X"
    id: zone3_end_x
    max_value: 4000
    min_value: -4000
    unit_of_measurement: "mm"
    step: 10
    optimistic: True
    restore_value: True
    disabled_by_default: true
  - platform: template
    name: "Zone 3 Begin Y"
    id: zone3_begin_y
    max_value: 6000
    min_value: 0
    unit_of_measurement: "mm"
    step: 10
    optimistic: True
    restore_value: True
    disabled_by_default: true
  - platform: template
    name: "Zone 3 End Y"
    id: zone3_end_y
    max_value: 6000
    min_value: 0
    unit_of_measurement: "mm"
    step: 10
    optimistic: True
    restore_value: True
    disabled_by_default: true
  - platform: template
    name: "Zone 3 Occupancy Off Delay"
    id: zone_3_off_delay
    max_value: 600
    min_value: 0
    step: 1
    optimistic: True
    restore_value: True
    unit_of_measurement: "s"
    initial_value: 15
    disabled_by_default: true

  - platform: template
    name: "Zone 4 Begin X"
    id: zone4_begin_x
    max_value: 4000
    min_value: -4000
    unit_of_measurement: "mm"
    step: 10
    optimistic: True
    restore_value: True
    disabled_by_default: true
  - platform: template
    name: "Zone 4 End X"
    id: zone4_end_x
    max_value: 4000
    min_value: -4000
    unit_of_measurement: "mm"
    step: 10
    optimistic: True
    restore_value: True
    disabled_by_default: true
  - platform: template
    name: "Zone 4 Begin Y"
    id: zone4_begin_y
    max_value: 6000
    min_value: 0
    unit_of_measurement: "mm"
    step: 10
    optimistic: True
    restore_value: True
    disabled_by_default: true
  - platform: template
    name: "Zone 4 End Y"
    id: zone4_end_y
    max_value: 6000
    min_value: 0
    unit_of_measurement: "mm"
    step: 10
    optimistic: True
    restore_value: True
    disabled_by_default: true
  - platform: template
    name: "Zone 4 Occupancy Off Delay"
    id: zone_4_off_delay
    max_value: 600
    min_value: 0
    step: 1
    optimistic: True
    restore_value: True
    unit_of_measurement: "s"
    initial_value: 15
    disabled_by_default: true

sensor:
  - platform: template
    name: "Target 1 X"
    id: target1_x
    accuracy_decimals: 0
    unit_of_measurement: 'cm'
    state_class: measurement
    device_class: distance
  - platform: template
    name: "Target 1 Y"
    id: target1_y
    accuracy_decimals: 0
    unit_of_measurement: 'cm'
    state_class: measurement
    device_class: distance
  - platform: template
    name: "Target 1 Speed"
    id: target1_speed
    accuracy_decimals: 2
    unit_of_measurement: 'm/s'
    state_class: measurement
    device_class: speed
  - platform: template
    name: "Target 1 Resolution"
    id: target1_resolution
    accuracy_decimals: 0
    unit_of_measurement: 'nm'
    state_class: measurement
    device_class: distance
  - platform: template
    name: "Target 2 X"
    id: target2_x
    accuracy_decimals: 0
    unit_of_measurement: 'mm'
    state_class: measurement
    device_class: distance
  - platform: template
    name: "Target 2 Y"
    id: target2_y
    accuracy_decimals: 0
    unit_of_measurement: 'mm'
    state_class: measurement
    device_class: distance
  - platform: template
    name: "Target 2 Speed"
    id: target2_speed
    accuracy_decimals: 2
    unit_of_measurement: 'm/s'
    state_class: measurement
    device_class: speed
  - platform: template
    name: "Target 2 Resolution"
    id: target2_resolution
    accuracy_decimals: 0
    unit_of_measurement: 'nm'
    state_class: measurement
    device_class: distance
  - platform: template
    name: "Target 3 X"
    id: target3_x
    accuracy_decimals: 0
    unit_of_measurement: 'mm'
    state_class: measurement
    device_class: distance
  - platform: template
    name: "Target 3 Y"
    id: target3_y
    accuracy_decimals: 0
    unit_of_measurement: 'mm'
    state_class: measurement
    device_class: distance
  - platform: template
    name: "Target 3 Speed"
    id: target3_speed
    accuracy_decimals: 2
    unit_of_measurement: 'm/s'
    state_class: measurement
    device_class: speed
  - platform: template
    name: "Target 3 Resolution"
    id: target3_resolution
    accuracy_decimals: 0
    unit_of_measurement: 'nm'
    state_class: measurement
    device_class: distance
  - platform: template
    name: "Target 1 Angle"
    id: target1_angle
    accuracy_decimals: 0
    unit_of_measurement: '°'
    state_class: measurement
  - platform: template
    name: "Target 2 Angle"
    id: target2_angle
    accuracy_decimals: 0
    unit_of_measurement: '°'
    state_class: measurement
  - platform: template
    name: "Target 3 Angle"
    id: target3_angle
    accuracy_decimals: 0
    unit_of_measurement: '°'
    state_class: measurement
  - platform: template
    name: "Target 1 Distance"
    id: target1_distance
    accuracy_decimals: 0
    unit_of_measurement: 'cm'
    state_class: measurement
    device_class: distance
  - platform: template
    name: "Target 2 Distance"
    id: target2_distance
    accuracy_decimals: 0
    unit_of_measurement: 'mm'
    state_class: measurement
    device_class: distance
  - platform: template
    name: "Target 3 Distance"
    id: target3_distance
    accuracy_decimals: 0
    unit_of_measurement: 'mm'
    state_class: measurement
    device_class: distance
  - platform: template
    name: "Zone 1 Target Count"
    id: zone1_target_count
    accuracy_decimals: 0
  - platform: template
    name: "Zone 2 Target Count"
    id: zone2_target_count
    accuracy_decimals: 0
    disabled_by_default: true
  - platform: template
    name: "Zone 3 Target Count"
    id: zone3_target_count
    accuracy_decimals: 0
    disabled_by_default: true
  - platform: template
    name: "Zone 4 Target Count"
    id: zone4_target_count
    accuracy_decimals: 0
    disabled_by_default: true

uart:
  id: uart_bus
  tx_pin: TX
  rx_pin: RX
  baud_rate: 256000
  parity: NONE
  stop_bits: 1
  data_bits: 8
  debug:
    direction: BOTH
    dummy_receiver: True
    after:
      delimiter: [0X55, 0XCC]
    sequence:
      # - lambda: UARTDebug::log_hex(direction, bytes, ' ');
      - lambda: |-
          if ((millis() - id(mmwave_update_time)) <= 250) { 
            return;
          };
          id(mmwave_update_time) = millis();

          int16_t p1_x = (uint16_t((bytes[5] << 8) | bytes[4] ));
          if ((bytes[5] & 0x80) >> 7){
            p1_x -= pow(2, 15); 
          }else{
            p1_x = 0 - p1_x; // was 0 - p1_x;
          }

          int16_t p1_y = (uint16_t((bytes[7] << 8) | bytes[6] ));
          if ((bytes[7] & 0x80) >> 7){
            p1_y -= pow(2, 15);
          }else{
            p1_y = 0 - p1_y;
          }

          float p1_speed = (bytes[9] << 8 | bytes[8] );
          if ((bytes[9] & 0x80) >> 7){
            p1_speed -= pow(2, 15);
          }else{
            p1_speed = 0 - p1_speed;
          }
          int16_t p1_distance_resolution = (uint16_t((bytes[11] << 8) | bytes[10] )); 

          int16_t p2_x = (uint16_t((bytes[13] << 8) | bytes[12] ));
          if ((bytes[13] & 0x80) >> 7){
            p2_x -=  pow(2, 15); 
          }else{
            p2_x = 0 - p2_x;
          }

          int16_t p2_y = (uint16_t((bytes[15] << 8) | bytes[14] ));
          if ((bytes[15] & 0x80) >> 7){
            p2_y -= pow(2, 15);
          }else{
            p2_y = 0 - p2_y;
          }

          float p2_speed = (bytes[17] << 8 | bytes[16] );
          if ((bytes[17] & 0x80) >> 7){
            p2_speed -= pow(2, 15);
          }else{
            p2_speed = 0 - p2_speed;
          }
          int16_t p2_distance_resolution = (uint16_t((bytes[19] << 8) | bytes[18] )); 

          int16_t p3_x = (uint16_t((bytes[21] << 8) | bytes[20] ));
          if ((bytes[21] & 0x80) >> 7){
            p3_x -=  pow(2, 15); 
          }else{
            p3_x = 0 - p3_x;
          }

          int16_t p3_y = (uint16_t((bytes[23] << 8) | bytes[22] ));
          if ((bytes[23] & 0x80) >> 7){
            p3_y -= pow(2, 15);
          }else{
            p3_y = 0 - p3_y;
          }

          float p3_speed = (bytes[25] << 8 | bytes[24] );
          if ((bytes[25] & 0x80) >> 7){
            p3_speed -= pow(2, 15);
          }else{
            p3_speed = 0 - p3_speed;
          }
          int16_t p3_distance_resolution = (uint16_t((bytes[27] << 8) | bytes[26] ));

          const float RADIANS_TO_DEGREES = 180.0 / 3.14159265358979323846;
          float p1_angle = atan2(p1_y, p1_x) * RADIANS_TO_DEGREES;
          float p2_angle = atan2(p2_y, p2_x) * RADIANS_TO_DEGREES;
          float p3_angle = atan2(p3_y, p3_x) * RADIANS_TO_DEGREES;
          
          float p1_distance = sqrt(p1_x * p1_x + p1_y * p1_y);
          float p2_distance = sqrt(p2_x * p2_x + p2_y * p2_y);
          float p3_distance = sqrt(p3_x * p3_x + p3_y * p3_y);
          

          float max_distance = float(id(distance).state) * 10;
          if (p1_distance < max_distance) {
            if (id(target1_x).state != p1_x)
              id(target1_x).publish_state(p1_x);
            if (id(target1_y).state != p1_y)
              id(target1_y).publish_state(p1_y);
            p1_speed /= 100.0;
            if (id(target1_speed).state != p1_speed)
              id(target1_speed).publish_state(p1_speed);
            if (id(target1_resolution).state != p1_distance_resolution)
              id(target1_resolution).publish_state(p1_distance_resolution);
            if (id(target1_distance).state != p1_distance)
              id(target1_distance).publish_state(p1_distance);
            p1_angle -= 90;
            if (id(target1_angle).state != p1_angle)
              id(target1_angle).publish_state(p1_angle);
          } else {
            if (id(target1_x).state != 0)
              id(target1_x).publish_state(0);
            if (id(target1_y).state != 0)
              id(target1_y).publish_state(0);
            if (id(target1_speed).state != 0)
              id(target1_speed).publish_state(0);
            if (id(target1_resolution).state != 0)
              id(target1_resolution).publish_state(0);
            if (id(target1_distance).state != 0)
              id(target1_distance).publish_state(0);
            if (id(target1_angle).state != 0)
              id(target1_angle).publish_state(0);
          }

          if (p2_distance < max_distance) {
            if (id(target2_x).state != p2_x)
              id(target2_x).publish_state(p2_x);
            if (id(target2_y).state != p2_y)
              id(target2_y).publish_state(p2_y);
            p2_speed /= 100.0;
            if (id(target2_speed).state != p2_speed)
              id(target2_speed).publish_state(p2_speed);
            if (id(target2_resolution).state != p2_distance_resolution)
              id(target2_resolution).publish_state(p2_distance_resolution);
            if (id(target2_distance).state != p2_distance)
              id(target2_distance).publish_state(p2_distance);
            p2_angle -= 90;
            if (id(target2_angle).state != p2_angle)
              id(target2_angle).publish_state(p2_angle);
          } else {
            if (id(target2_x).state != 0)
              id(target2_x).publish_state(0);
            if (id(target2_y).state != 0)
              id(target2_y).publish_state(0);
            if (id(target2_speed).state != 0)
              id(target2_speed).publish_state(0);
            if (id(target2_resolution).state != 0)
              id(target2_resolution).publish_state(0);
            if (id(target2_distance).state != 0)
              id(target2_distance).publish_state(0);
            if (id(target2_angle).state != 0)
              id(target2_angle).publish_state(0);
          }

          if (p3_distance < max_distance) {
            if (id(target3_x).state != p3_x)
              id(target3_x).publish_state(p3_x);
            if (id(target3_y).state != p3_y)
              id(target3_y).publish_state(p3_y);
            p3_speed /= 100.0;
            if (id(target3_speed).state != p3_speed)
              id(target3_speed).publish_state(p3_speed);
            if (id(target3_resolution).state != p3_distance_resolution)
              id(target3_resolution).publish_state(p3_distance_resolution);
            if (id(target3_distance).state != p3_distance)
              id(target3_distance).publish_state(p3_distance);
            p3_angle -= 90;
            if (id(target3_angle).state != p3_angle)
              id(target3_angle).publish_state(p3_angle);
          } else {
            if (id(target3_x).state != 0)
              id(target3_x).publish_state(0);
            if (id(target3_y).state != 0)
              id(target3_y).publish_state(0);
            if (id(target3_speed).state != 0)
              id(target3_speed).publish_state(0);
            if (id(target3_resolution).state != 0)
              id(target3_resolution).publish_state(0);
            if (id(target3_distance).state != 0)
              id(target3_distance).publish_state(0);
            if (id(target3_angle).state != 0)
              id(target3_angle).publish_state(0);
          }

          int zone1_count = 0;      
          if (id(target1_active).state == true ) {
              if ((id(target1_x).state >= id(zone1_begin_x).state && id(target1_x).state <= id(zone1_end_x).state) &&
                  (id(target1_y).state >= id(zone1_begin_y).state && id(target1_y).state <= id(zone1_end_y).state)) {
                  zone1_count++;
              }
          }

          if (id(target2_active).state == true ) {
              if ((id(target2_x).state >= id(zone1_begin_x).state && id(target2_x).state <= id(zone1_end_x).state) &&
                  (id(target2_y).state >= id(zone1_begin_y).state && id(target2_y).state <= id(zone1_end_y).state)) {
                  zone1_count++;
              }
          }

          if (id(target3_active).state == true ) {
              if ((id(target3_x).state >= id(zone1_begin_x).state && id(target3_x).state <= id(zone1_end_x).state) &&
                  (id(target3_y).state >= id(zone1_begin_y).state && id(target3_y).state <= id(zone1_end_y).state)) {
                  zone1_count++;
              }
          }

          if (zone1_count > 0) {
            if (id(zone1_occupancy).state != true)
              id(zone1_occupancy).publish_state(true);
            if (id(zone1_target_count).state != zone1_count)
              id(zone1_target_count).publish_state(zone1_count);
          } else {
            if (id(zone1_occupancy).state != false)
              id(zone1_occupancy).publish_state(false);
            if (id(zone1_target_count).state != 0)
              id(zone1_target_count).publish_state(0);
          }

          int zone2_count = 0;
          if (id(target1_active).state == true ) {
              if ((id(target1_x).state >= id(zone2_begin_x).state && id(target1_x).state <= id(zone2_end_x).state) &&
                  (id(target1_y).state >= id(zone2_begin_y).state && id(target1_y).state <= id(zone2_end_y).state)) {
                  zone2_count++;
              }
          }
          if (id(target2_active).state == true ) {
              if ((id(target2_x).state >= id(zone2_begin_x).state && id(target2_x).state <= id(zone2_end_x).state) &&
                  (id(target2_y).state >= id(zone2_begin_y).state && id(target2_y).state <= id(zone2_end_y).state)) {
                  zone2_count++;
              }
          }
          if (id(target3_active).state == true ) {
              if ((id(target3_x).state >= id(zone2_begin_x).state && id(target3_x).state <= id(zone2_end_x).state) &&
                  (id(target3_y).state >= id(zone2_begin_y).state && id(target3_y).state <= id(zone2_end_y).state)) {
                  zone2_count++;
              }
          }
          if (zone2_count > 0) {
            if (id(zone2_occupancy).state != true)
              id(zone2_occupancy).publish_state(true);
            if (id(zone2_target_count).state != zone2_count)
              id(zone2_target_count).publish_state(zone2_count);
          } else {
            if (id(zone2_occupancy).state != false)
              id(zone2_occupancy).publish_state(false);
            if (id(zone2_target_count).state != 0)
              id(zone2_target_count).publish_state(0);
          }

          int zone3_count = 0;
          if (id(target1_active).state == true ) {
              if ((id(target1_x).state >= id(zone3_begin_x).state && id(target1_x).state <= id(zone3_end_x).state) &&
                  (id(target1_y).state >= id(zone3_begin_y).state && id(target1_y).state <= id(zone3_end_y).state)) {
                  zone3_count++;
              }
          }
          if (id(target2_active).state == true ) {
              if ((id(target2_x).state >= id(zone3_begin_x).state && id(target2_x).state <= id(zone3_end_x).state) &&
                  (id(target2_y).state >= id(zone3_begin_y).state && id(target2_y).state <= id(zone3_end_y).state)) {
                  zone3_count++;
              }
          }
          if (id(target3_active).state == true ) {
              if ((id(target3_x).state >= id(zone3_begin_x).state && id(target3_x).state <= id(zone3_end_x).state) &&
                  (id(target3_y).state >= id(zone3_begin_y).state && id(target3_y).state <= id(zone3_end_y).state)) {
                  zone3_count++;
              }
          }
          if (zone3_count > 0) {
            if (id(zone3_occupancy).state != true)
              id(zone3_occupancy).publish_state(true);
            if (id(zone3_target_count).state != zone3_count)
              id(zone3_target_count).publish_state(zone3_count);
          } else {
            if (id(zone3_occupancy).state != false)
              id(zone3_occupancy).publish_state(false);
            if (id(zone3_target_count).state != 0)
              id(zone3_target_count).publish_state(0);
          }

          int zone4_count = 0;
          if (id(target1_active).state == true ) {
              if ((id(target1_x).state >= id(zone4_begin_x).state && id(target1_x).state <= id(zone4_end_x).state) &&
                  (id(target1_y).state >= id(zone4_begin_y).state && id(target1_y).state <= id(zone4_end_y).state)) {
                  zone4_count++;
              }
          }
          if (id(target2_active).state == true ) {
              if ((id(target2_x).state >= id(zone4_begin_x).state && id(target2_x).state <= id(zone4_end_x).state) &&
                  (id(target2_y).state >= id(zone4_begin_y).state && id(target2_y).state <= id(zone4_end_y).state)) {
                  zone4_count++;
              }
          }
          if (id(target3_active).state == true ) {
              if ((id(target3_x).state >= id(zone4_begin_x).state && id(target3_x).state <= id(zone4_end_x).state) &&
                  (id(target3_y).state >= id(zone4_begin_y).state && id(target3_y).state <= id(zone4_end_y).state)) {
                  zone4_count++;
              }
          }
          if (zone4_count > 0) {
            if (id(zone4_occupancy).state != true)
              id(zone4_occupancy).publish_state(true);
            if (id(zone4_target_count).state != zone4_count)
              id(zone4_target_count).publish_state(zone4_count);
          } else {
            if (id(zone4_occupancy).state != false)
              id(zone4_occupancy).publish_state(false);
            if (id(zone4_target_count).state != 0)
              id(zone4_target_count).publish_state(0);
          }


Radatool is OK…
Example:
When at 4.6meters it reports the correct distance.

Need help.
What should I change, and where?

log when I am 4.5meters away, showing 4532cm:

Hi, i installed the sensor and it look like its working with firmware 2.04. I have read that i need to downgrade it, but my app ist crashing while downgrading. Is this normal? Tried two LD2450.

But i have one problem: i create a custom zone on uncle-yura firmware and it fires correct, but only for around 2 Seconds, then its back to no presence. This will start a endless cycle an my lights are “flashing”

It also looks like “ignoring” in Redion iss working correctly, but “detect” is not.

Inside the app location look fine.

hi, do you have a link for that?

No anwsers, so I had to ask chatgpt for help :slight_smile:
Use p1_x /= 10; and p1_y /= 10; etc etc to divide by 10 all x and y values.

Example for P1:

      int16_t p1_x = (uint16_t((bytes[5] << 8) | bytes[4] ));
      
      if ((bytes[5] & 0x80) >> 7){
        p1_x -= pow(2, 15); 
      }else{
        p1_x = 0 - p1_x; // was 0 - p1_x;
      }
      p1_x /= 10; // Divide by 10

Now I have the correct measurements for each x/y and distance

1 Like

Where can I find a working ESPHome configuration for LD2450?