HLK-LD2450 Initial experiments to connect to HomeAssistant

This ESPHome code should add the timeout config for Any Presence:

number:
  - platform: template
    name: "Any Presence Timeout"
    id: any_presence_timeout
    min_value: 0
    max_value: 600
    mode: box
    device_class: duration
    entity_category: config
    unit_of_measurement: s
    icon: mdi:timer-off
    step: 1
    optimistic: True
    initial_value: 0
    restore_value: True

binary_sensor:
  - platform: template
    name: "Any Presence"
    id: any_target_exsits
    device_class: occupancy
    filters:
      - delayed_off: !lambda |-
          return id(any_presence_timeout).state * 1000.0;
2 Likes

We synchronized athua’s code into it, and now a public firmware update can get this functionality.

A bit of a shame: the name of this property is too long, making it obscured in the HA properties.

1 Like

I’ve updated my 2A with V230905_1_BETA and tested it by setting a 60 second timeout for ‘Any Presence’ and it clears 60 seconds after I left the room.

Hello,
i have tried this yaml file screek human sensor stable with a luatos board - official page, but i only get a boot loop.
I have also specified the platformio options:

  platformio_options:
    board_build.f_flash: 40000000L
    board_build.flash_mode: dio
    board_build.flash_size: 4MB

esp32:
  board: esp32-c3-devkitm-1

I have tried with a “regular” yaml file and the board works as expected.

My logs are like this:

ESP-ROM:esp32c3-api1-20210207
Build:Feb  7 2021
rst:0x3 (RTC_SW_SYS_RST),boot:0xf (SPI_FAST_FLASH_BOOT)
Saved PC:0x4038252a
SPIWP:0xee
mode:DIO, clock div:2
load:0x3fcd6100,len:0x38c
load:0x403ce000,len:0x6ac
load:0x403d0000,len:0x24e4
entry 0x403ce000
E (5308) task_wdt: Task watchdog got triggered. The following tasks did not reset the watchdog in time:
E (5308) task_wdt:  - loopTask (CPU 0)
E (5308) task_wdt: Tasks currently running:
E (5308) task_wdt: CPU 0: IDLE
E (5308) task_wdt: Aborting.

I have also tried the beta binary file, didn’t helped.
Thanks!

Thanks! Getting presence logs in minutes now rather than every few seconds.
Still working on fixing to the best position in the room, might need to print one of those motion sensor mount for the corners and tilting it.

1 Like

Although Zone1 targets does not change, the Zone1 presence briefly changes to OFF and then to ON again in the same second. This occurs occasionally.

The “All presence” sensors stays still ON during Zone1 is shortly OFF.

Zone1 settings:

Zone1 Timeout	  60 s
Zone1 X-Begin	-600 mm	
Zone1 X-End      600 mm	
Zone1 Y-Begin    400 mm	
Zone1 Y-End	    1600 mm

ESP Log:

[18:01:34][D][sensor:094]: 'Target1 Y': Sending state 1171.00000 mm with 0 decimals of accuracy
[18:01:35][D][sensor:094]: 'Target1 X': Sending state -148.00000 mm with 0 decimals of accuracy
[18:01:35][D][sensor:094]: 'Target1 Y': Sending state 1155.00000 mm with 0 decimals of accuracy
[18:01:35][D][binary_sensor:036]: 'Zone1 Presence': Sending state OFF
[18:01:35][D][sensor:094]: 'Target1 X': Sending state -136.00000 mm with 0 decimals of accuracy
[18:01:35][D][sensor:094]: 'Target1 Y': Sending state 1135.00000 mm with 0 decimals of accuracy
[18:01:35][D][binary_sensor:036]: 'Zone1 Presence': Sending state ON
[18:01:36][D][sensor:094]: 'Target1 X': Sending state -142.00000 mm with 0 decimals of accuracy
[18:01:36][D][sensor:094]: 'Target1 Y': Sending state 1138.00000 mm with 0 decimals of accuracy
[18:01:36][D][sensor:094]: 'Target1 X': Sending state -143.00000 mm with 0 decimals of accuracy

What could be the reason for this beahivoir?

If you’re using the same c3 development board that we are, you may run into some more troublesome areas.
One of them is that we use a GPIO11, this cannot be used without unlocking it, and will cause the I2C to lock up and then restart repeatedly.

From your logs, it looks like the serial port logs are gone as well.

If you want to DIY a 2A radar, I’d suggest starting with a device you’re familiar with and modifying the GPIOs in the code. e.g. ESP32 development board.

Using a C3 without a USB serial port requires some special skills, some kernel tweaks to make the USB serial port stably supported, and some modifications to the esp32 built-in libraries in order to unlock the motherboard’s led lights.
All of this makes, things a bit more complicated.

From the logs, the behavior does seem strange. But the logs are a bit too short, so if possible, please post some nearby logs that might be better to investigate.
One of the things I might also be puzzled by is that Target 1 X, seems to have become Zone1 X here.

Since it’s 1am and I can’t access the code right now, this may be some name bug on my part that I’ll need to investigate further tomorrow.
But as it stands, we need a log with a little more detail.

[18:01:36][D][sensor:094]: ‘Zone1 X’: sending state -142.00000 mm with 0 decimals of accuracy
[18:01:36][D][sensor:094]: ‘Zone1 Y’: Sending state 1138.00000 mm with 0 decimals of accuracy

Thx for you fast answer.

I build a DIY LD2450 sensor with an M5 Stack Atom Lite based on V230905_1_BETA.

Only removed the illuminance and CPU part from your code.

The part that is not understandable:
20:52:24][D][sensor:094]: Zone1 Target Counts: Sending state 0.00000 targets with 0 decimals of accuracy

[20:52:35][D][sensor:094]: Zone1 Target Counts: Sending state 1.00000 targets with 0 decimals of accuracy

…and after 60 seconds (Zone1 timeout):
[20:53:24][D][binary_sensor:036]: Zone1 Presence: Sending state OFF
[20:53:25][D][binary_sensor:036]: Zone1 Presence: Sending state ON

If I understood the handling correct, 20:52:35 Zone1 Target Counts: Sending state 1 should cancel the switch off at 20:53:24 Zone1 Presence: Sending state OFF (due to delayed_off “zone1_x_timeout”).

More ESP Log:

[20:52:22][D][sensor:094]: 'Target1 Y': Sending state 630.00000 mm with 0 decimals of accuracy
[20:52:22][D][sensor:094]: 'Target1 Speed': Sending state -0.16000 m/s with 2 decimals of accuracy
[20:52:22][D][sensor:094]: 'Target1 X': Sending state 172.00000 mm with 0 decimals of accuracy
[20:52:22][D][sensor:094]: 'Target1 Y': Sending state 613.00000 mm with 0 decimals of accuracy
[20:52:22][D][sensor:094]: 'Target1 Speed': Sending state 0.00000 m/s with 2 decimals of accuracy
[20:52:23][D][sensor:094]: 'Target1 X': Sending state 202.00000 mm with 0 decimals of accuracy
[20:52:23][D][sensor:094]: 'Target1 Y': Sending state 596.00000 mm with 0 decimals of accuracy
[20:52:23][D][sensor:094]: 'Target1 X': Sending state 244.00000 mm with 0 decimals of accuracy
[20:52:23][D][sensor:094]: 'Target1 Y': Sending state 635.00000 mm with 0 decimals of accuracy
[20:52:24][D][sensor:094]: 'Target1 X': Sending state 278.00000 mm with 0 decimals of accuracy
[20:52:24][D][sensor:094]: 'Target1 Y': Sending state 618.00000 mm with 0 decimals of accuracy
[20:52:24][D][sensor:094]: 'Target1 X': Sending state 693.00000 mm with 0 decimals of accuracy
[20:52:24][D][sensor:094]: 'Target1 Y': Sending state 1455.00000 mm with 0 decimals of accuracy
[20:52:24][D][sensor:094]: 'Zone1 Target Counts': Sending state 0.00000 targets with 0 decimals of accuracy
[20:52:25][D][sensor:094]: 'Target1 X': Sending state 1091.00000 mm with 0 decimals of accuracy
[20:52:25][D][sensor:094]: 'Target1 Y': Sending state 2036.00000 mm with 0 decimals of accuracy
[20:52:25][D][sensor:094]: 'Target1 X': Sending state 1577.00000 mm with 0 decimals of accuracy
[20:52:25][D][sensor:094]: 'Target1 Y': Sending state 1559.00000 mm with 0 decimals of accuracy
[20:52:25][W][component:204]: Component uart took a long time for an operation (0.05 s).
[20:52:25][W][component:205]: Components should block for at most 20-30ms.
[20:52:26][D][sensor:094]: 'Target1 X': Sending state 0.00000 mm with 0 decimals of accuracy
[20:52:26][D][sensor:094]: 'Target1 Y': Sending state 0.00000 mm with 0 decimals of accuracy
[20:52:26][D][sensor:094]: 'Target1 Resolution': Sending state 0.00000 mm with 0 decimals of accuracy
[20:52:26][D][sensor:094]: 'All Target Counts': Sending state 0.00000 targets with 0 decimals of accuracy
[20:52:26][W][component:204]: Component uart took a long time for an operation (0.07 s).
[20:52:26][W][component:205]: Components should block for at most 20-30ms.
[20:52:26][D][binary_sensor:036]: 'Any Presence': Sending state OFF
[20:52:35][D][sensor:094]: 'Target1 X': Sending state 416.00000 mm with 0 decimals of accuracy
[20:52:35][D][sensor:094]: 'Target1 Y': Sending state 477.00000 mm with 0 decimals of accuracy
[20:52:35][D][sensor:094]: 'Target1 Resolution': Sending state 360.00000 mm with 0 decimals of accuracy
[20:52:35][D][sensor:094]: 'All Target Counts': Sending state 1.00000 targets with 0 decimals of accuracy
[20:52:35][D][binary_sensor:036]: 'Any Presence': Sending state ON
[20:52:35][D][sensor:094]: 'Zone1 Target Counts': Sending state 1.00000 targets with 0 decimals of accuracy
[20:52:35][W][component:204]: Component uart took a long time for an operation (0.12 s).
[20:52:35][W][component:205]: Components should block for at most 20-30ms.
[20:52:36][D][sensor:094]: 'Target1 X': Sending state 294.00000 mm with 0 decimals of accuracy
[20:52:36][D][sensor:094]: 'Target1 Y': Sending state 515.00000 mm with 0 decimals of accuracy
[20:52:36][D][sensor:094]: 'Target1 Speed': Sending state 0.16000 m/s with 2 decimals of accuracy
[20:52:36][D][sensor:094]: 'Target1 X': Sending state 225.00000 mm with 0 decimals of accuracy
[20:52:36][D][sensor:094]: 'Target1 Y': Sending state 548.00000 mm with 0 decimals of accuracy
[20:52:36][D][sensor:094]: 'Target1 Speed': Sending state 0.24000 m/s with 2 decimals of accuracy
[20:52:36][W][component:204]: Component uart took a long time for an operation (0.06 s).
[20:52:36][W][component:205]: Components should block for at most 20-30ms.
[20:52:37][D][sensor:094]: 'Target1 X': Sending state 219.00000 mm with 0 decimals of accuracy
[20:52:37][D][sensor:094]: 'Target1 Y': Sending state 577.00000 mm with 0 decimals of accuracy
[20:52:37][D][sensor:094]: 'Target1 X': Sending state 192.00000 mm with 0 decimals of accuracy
[20:52:37][D][sensor:094]: 'Target1 Y': Sending state 635.00000 mm with 0 decimals of accuracy
[20:52:37][D][sensor:094]: 'Target1 Speed': Sending state 0.00000 m/s with 2 decimals of accuracy
[20:52:38][D][sensor:094]: 'Target1 X': Sending state 201.00000 mm with 0 decimals of accuracy
[20:52:38][D][sensor:094]: 'Target1 Y': Sending state 655.00000 mm with 0 decimals of accuracy
[20:52:38][D][sensor:094]: 'Target1 Speed': Sending state -0.24000 m/s with 2 decimals of accuracy
[20:52:38][W][component:204]: Component uart took a long time for an operation (0.05 s).
[20:52:38][W][component:205]: Components should block for at most 20-30ms.
[20:52:38][D][sensor:094]: 'Target1 X': Sending state 164.00000 mm with 0 decimals of accuracy
[20:52:38][D][sensor:094]: 'Target1 Y': Sending state 659.00000 mm with 0 decimals of accuracy
[20:52:38][D][sensor:094]: 'Target1 Speed': Sending state -0.16000 m/s with 2 decimals of accuracy
[20:52:39][D][sensor:094]: 'Target1 X': Sending state 131.00000 mm with 0 decimals of accuracy
[20:52:39][D][sensor:094]: 'Target1 Y': Sending state 651.00000 mm with 0 decimals of accuracy
[20:52:39][D][sensor:094]: 'Target1 X': Sending state 73.00000 mm with 0 decimals of accuracy
[20:52:39][D][sensor:094]: 'Target1 Y': Sending state 637.00000 mm with 0 decimals of accuracy
[20:52:39][D][sensor:094]: 'Target1 Speed': Sending state 0.08000 m/s with 2 decimals of accuracy
[20:52:39][W][component:204]: Component uart took a long time for an operation (0.06 s).
[20:52:39][W][component:205]: Components should block for at most 20-30ms.
[20:52:40][D][sensor:094]: 'Target1 X': Sending state 87.00000 mm with 0 decimals of accuracy
[20:52:40][D][sensor:094]: 'Target1 Y': Sending state 638.00000 mm with 0 decimals of accuracy
[20:52:40][D][sensor:094]: 'Target1 X': Sending state 110.00000 mm with 0 decimals of accuracy
[20:52:40][D][sensor:094]: 'Target1 Y': Sending state 642.00000 mm with 0 decimals of accuracy
[20:52:41][D][sensor:094]: 'Target1 X': Sending state 114.00000 mm with 0 decimals of accuracy
[20:52:41][D][sensor:094]: 'Target1 Y': Sending state 653.00000 mm with 0 decimals of accuracy
[20:52:41][D][sensor:094]: 'Target1 Speed': Sending state -0.32000 m/s with 2 decimals of accuracy
[20:52:41][W][component:204]: Component uart took a long time for an operation (0.06 s).
[20:52:41][W][component:205]: Components should block for at most 20-30ms.
[20:52:41][D][sensor:094]: 'Target1 X': Sending state 117.00000 mm with 0 decimals of accuracy
[20:52:41][D][sensor:094]: 'Target1 Y': Sending state 635.00000 mm with 0 decimals of accuracy
[20:52:41][D][sensor:094]: 'Target1 Speed': Sending state 0.00000 m/s with 2 decimals of accuracy
[20:52:41][W][component:204]: Component uart took a long time for an operation (0.05 s).
[20:52:41][W][component:205]: Components should block for at most 20-30ms.
[20:52:42][D][sensor:094]: 'Target1 X': Sending state 100.00000 mm with 0 decimals of accuracy
[20:52:42][D][sensor:094]: 'Target1 Y': Sending state 604.00000 mm with 0 decimals of accuracy
[20:52:42][D][sensor:094]: 'Target1 X': Sending state 98.00000 mm with 0 decimals of accuracy
[20:52:42][D][sensor:094]: 'Target1 Y': Sending state 584.00000 mm with 0 decimals of accuracy
[20:52:43][D][sensor:094]: 'Target1 X': Sending state 120.00000 mm with 0 decimals of accuracy
[20:52:43][D][sensor:094]: 'Target1 Y': Sending state 551.00000 mm with 0 decimals of accuracy
[20:52:44][D][sensor:094]: 'Target1 X': Sending state 126.00000 mm with 0 decimals of accuracy
[20:52:44][D][sensor:094]: 'Target1 Y': Sending state 548.00000 mm with 0 decimals of accuracy
[20:52:44][D][sensor:094]: 'Target1 X': Sending state 123.00000 mm with 0 decimals of accuracy
[20:52:44][D][sensor:094]: 'Target1 Y': Sending state 545.00000 mm with 0 decimals of accuracy
[20:52:45][D][sensor:094]: 'Target1 X': Sending state 140.00000 mm with 0 decimals of accuracy
[20:52:45][D][sensor:094]: 'Target1 Y': Sending state 538.00000 mm with 0 decimals of accuracy
[20:52:45][D][sensor:094]: 'Target1 X': Sending state 148.00000 mm with 0 decimals of accuracy
[20:52:45][D][sensor:094]: 'Target1 Y': Sending state 533.00000 mm with 0 decimals of accuracy
[20:52:46][D][sensor:094]: 'ESP Free Memory': Sending state 191.00000 kB with 1 decimals of accuracy
[20:52:46][D][sensor:094]: 'Target1 X': Sending state 155.00000 mm with 0 decimals of accuracy
[20:52:46][D][sensor:094]: 'Target1 Y': Sending state 540.00000 mm with 0 decimals of accuracy
[20:52:46][D][sensor:094]: 'Target1 X': Sending state 163.00000 mm with 0 decimals of accuracy
[20:52:46][D][sensor:094]: 'Target1 Y': Sending state 537.00000 mm with 0 decimals of accuracy
[20:52:47][D][sensor:094]: 'Target1 X': Sending state 171.00000 mm with 0 decimals of accuracy
[20:52:47][D][sensor:094]: 'Target1 Y': Sending state 514.00000 mm with 0 decimals of accuracy
[20:52:47][D][sensor:094]: 'Target1 X': Sending state 155.00000 mm with 0 decimals of accuracy
[20:52:47][D][sensor:094]: 'Target1 Y': Sending state 494.00000 mm with 0 decimals of accuracy
[20:52:48][D][sensor:094]: 'ESP Temperature': Sending state 68.33334 °C with 1 decimals of accuracy
[20:52:48][D][sensor:094]: 'Target1 X': Sending state 139.00000 mm with 0 decimals of accuracy
[20:52:48][D][sensor:094]: 'Target1 Y': Sending state 487.00000 mm with 0 decimals of accuracy
[20:52:48][D][sensor:094]: 'Target1 X': Sending state 159.00000 mm with 0 decimals of accuracy
[20:52:48][D][sensor:094]: 'Target1 Y': Sending state 489.00000 mm with 0 decimals of accuracy
[20:52:49][D][sensor:094]: 'RSSI': Sending state -64.00000 dBm with 0 decimals of accuracy
[20:52:49][D][sensor:094]: 'ESP Uptime': Sending state 298.44699 s with 0 decimals of accuracy
[20:52:49][D][sensor:094]: 'Target1 X': Sending state 163.00000 mm with 0 decimals of accuracy
[20:52:49][D][sensor:094]: 'Target1 Y': Sending state 507.00000 mm with 0 decimals of accuracy
[20:52:49][D][sensor:094]: 'Target1 X': Sending state 165.00000 mm with 0 decimals of accuracy
[20:52:49][D][sensor:094]: 'Target1 Y': Sending state 518.00000 mm with 0 decimals of accuracy
[20:52:50][D][sensor:094]: 'Target1 X': Sending state 151.00000 mm with 0 decimals of accuracy
[20:52:50][D][sensor:094]: 'Target1 Y': Sending state 509.00000 mm with 0 decimals of accuracy
[20:52:50][I][ota:113]: Boot seems successful, resetting boot loop counter.
[20:52:50][D][esp32.preferences:114]: Saving 1 preferences to flash...
[20:52:50][D][esp32.preferences:143]: Saving 1 preferences to flash: 0 cached, 1 written, 0 failed
[20:52:50][D][sensor:094]: 'Target1 X': Sending state 172.00000 mm with 0 decimals of accuracy
[20:52:50][D][sensor:094]: 'Target1 Y': Sending state 518.00000 mm with 0 decimals of accuracy
[20:52:51][D][sensor:094]: 'Target1 X': Sending state 163.00000 mm with 0 decimals of accuracy
[20:52:51][D][sensor:094]: 'Target1 Y': Sending state 531.00000 mm with 0 decimals of accuracy
[20:52:52][D][sensor:094]: 'Target1 X': Sending state 155.00000 mm with 0 decimals of accuracy
[20:52:52][D][sensor:094]: 'Target1 Y': Sending state 521.00000 mm with 0 decimals of accuracy
[20:52:52][D][sensor:094]: 'Target1 Speed': Sending state 0.08000 m/s with 2 decimals of accuracy
[20:52:52][W][component:204]: Component uart took a long time for an operation (0.06 s).
[20:52:52][W][component:205]: Components should block for at most 20-30ms.
[20:52:52][D][sensor:094]: 'Target1 X': Sending state 149.00000 mm with 0 decimals of accuracy
[20:52:52][D][sensor:094]: 'Target1 Y': Sending state 505.00000 mm with 0 decimals of accuracy
[20:52:52][D][sensor:094]: 'Target1 Speed': Sending state 0.00000 m/s with 2 decimals of accuracy
[20:52:53][D][sensor:094]: 'Target1 X': Sending state 166.00000 mm with 0 decimals of accuracy
[20:52:53][D][sensor:094]: 'Target1 Y': Sending state 507.00000 mm with 0 decimals of accuracy
[20:52:53][D][sensor:094]: 'Target1 X': Sending state 182.00000 mm with 0 decimals of accuracy
[20:52:53][D][sensor:094]: 'Target1 Y': Sending state 533.00000 mm with 0 decimals of accuracy
[20:52:54][D][sensor:094]: 'Target1 X': Sending state 191.00000 mm with 0 decimals of accuracy
[20:52:54][D][sensor:094]: 'Target1 Y': Sending state 552.00000 mm with 0 decimals of accuracy
[20:52:54][D][sensor:094]: 'Target1 X': Sending state 205.00000 mm with 0 decimals of accuracy
[20:52:54][D][sensor:094]: 'Target1 Y': Sending state 561.00000 mm with 0 decimals of accuracy
[20:52:55][D][sensor:094]: 'Target1 X': Sending state 207.00000 mm with 0 decimals of accuracy
[20:52:55][D][sensor:094]: 'Target1 Y': Sending state 568.00000 mm with 0 decimals of accuracy
[20:52:55][D][sensor:094]: 'Target1 X': Sending state 213.00000 mm with 0 decimals of accuracy
[20:52:55][D][sensor:094]: 'Target1 Y': Sending state 566.00000 mm with 0 decimals of accuracy
[20:52:56][D][sensor:094]: 'Target1 X': Sending state 217.00000 mm with 0 decimals of accuracy
[20:52:56][D][sensor:094]: 'Target1 Y': Sending state 558.00000 mm with 0 decimals of accuracy
[20:52:56][D][sensor:094]: 'Target1 X': Sending state 210.00000 mm with 0 decimals of accuracy
[20:52:56][D][sensor:094]: 'Target1 Y': Sending state 556.00000 mm with 0 decimals of accuracy
[20:52:57][D][sensor:094]: 'Target1 X': Sending state 183.00000 mm with 0 decimals of accuracy
[20:52:57][D][sensor:094]: 'Target1 Y': Sending state 540.00000 mm with 0 decimals of accuracy
[20:52:57][D][sensor:094]: 'Target1 X': Sending state 182.00000 mm with 0 decimals of accuracy
[20:52:57][D][sensor:094]: 'Target1 Y': Sending state 542.00000 mm with 0 decimals of accuracy
[20:52:58][D][sensor:094]: 'Target1 X': Sending state 175.00000 mm with 0 decimals of accuracy
[20:52:58][D][sensor:094]: 'Target1 Y': Sending state 534.00000 mm with 0 decimals of accuracy
[20:52:58][D][sensor:094]: 'Target1 X': Sending state 179.00000 mm with 0 decimals of accuracy
[20:52:58][D][sensor:094]: 'Target1 Y': Sending state 531.00000 mm with 0 decimals of accuracy
[20:52:59][D][sensor:094]: 'Target1 X': Sending state 210.00000 mm with 0 decimals of accuracy
[20:52:59][D][sensor:094]: 'Target1 Y': Sending state 506.00000 mm with 0 decimals of accuracy
[20:53:00][D][sensor:094]: 'Target1 X': Sending state 199.00000 mm with 0 decimals of accuracy
[20:53:00][D][sensor:094]: 'Target1 Y': Sending state 514.00000 mm with 0 decimals of accuracy
[20:53:00][D][sensor:094]: 'Target1 X': Sending state 187.00000 mm with 0 decimals of accuracy
[20:53:00][D][sensor:094]: 'Target1 Y': Sending state 519.00000 mm with 0 decimals of accuracy
[20:53:01][D][sensor:094]: 'Target1 X': Sending state 178.00000 mm with 0 decimals of accuracy
[20:53:01][D][sensor:094]: 'Target1 Y': Sending state 542.00000 mm with 0 decimals of accuracy
[20:53:01][D][sensor:094]: 'Target1 X': Sending state 184.00000 mm with 0 decimals of accuracy
[20:53:01][D][sensor:094]: 'Target1 Y': Sending state 532.00000 mm with 0 decimals of accuracy
[20:53:02][D][sensor:094]: 'Target1 X': Sending state 176.00000 mm with 0 decimals of accuracy
[20:53:02][D][sensor:094]: 'Target1 Y': Sending state 529.00000 mm with 0 decimals of accuracy
[20:53:02][D][sensor:094]: 'Target1 X': Sending state 41.00000 mm with 0 decimals of accuracy
[20:53:02][D][sensor:094]: 'Target1 Y': Sending state 504.00000 mm with 0 decimals of accuracy
[20:53:03][D][sensor:094]: 'Target1 X': Sending state 49.00000 mm with 0 decimals of accuracy
[20:53:03][D][sensor:094]: 'Target1 Y': Sending state 516.00000 mm with 0 decimals of accuracy
[20:53:03][D][sensor:094]: 'Target1 X': Sending state 62.00000 mm with 0 decimals of accuracy
[20:53:03][D][sensor:094]: 'Target1 Y': Sending state 530.00000 mm with 0 decimals of accuracy
[20:53:04][D][sensor:094]: 'Target1 X': Sending state 45.00000 mm with 0 decimals of accuracy
[20:53:04][D][sensor:094]: 'Target1 X': Sending state 71.00000 mm with 0 decimals of accuracy
[20:53:04][D][sensor:094]: 'Target1 Y': Sending state 539.00000 mm with 0 decimals of accuracy
[20:53:05][D][sensor:094]: 'Target1 X': Sending state 86.00000 mm with 0 decimals of accuracy
[20:53:05][D][sensor:094]: 'Target1 Y': Sending state 547.00000 mm with 0 decimals of accuracy
[20:53:05][W][component:204]: Component uart took a long time for an operation (0.05 s).
[20:53:05][W][component:205]: Components should block for at most 20-30ms.
[20:53:05][D][sensor:094]: 'Target1 X': Sending state 87.00000 mm with 0 decimals of accuracy
[20:53:06][D][sensor:094]: 'Target1 X': Sending state 67.00000 mm with 0 decimals of accuracy
[20:53:06][D][sensor:094]: 'Target1 Y': Sending state 549.00000 mm with 0 decimals of accuracy
[20:53:06][D][sensor:094]: 'Target1 X': Sending state 34.00000 mm with 0 decimals of accuracy
[20:53:07][D][sensor:094]: 'Target1 Y': Sending state 543.00000 mm with 0 decimals of accuracy
[20:53:07][D][sensor:094]: 'Target1 X': Sending state 56.00000 mm with 0 decimals of accuracy
[20:53:07][D][sensor:094]: 'Target1 Y': Sending state 554.00000 mm with 0 decimals of accuracy
[20:53:08][D][sensor:094]: 'Target1 X': Sending state 70.00000 mm with 0 decimals of accuracy
[20:53:08][D][sensor:094]: 'Target1 Y': Sending state 548.00000 mm with 0 decimals of accuracy
[20:53:08][D][sensor:094]: 'Target1 X': Sending state 91.00000 mm with 0 decimals of accuracy
[20:53:08][D][sensor:094]: 'Target1 Y': Sending state 552.00000 mm with 0 decimals of accuracy
[20:53:09][D][sensor:094]: 'Target1 X': Sending state 109.00000 mm with 0 decimals of accuracy
[20:53:09][D][sensor:094]: 'Target1 Y': Sending state 553.00000 mm with 0 decimals of accuracy
[20:53:09][D][sensor:094]: 'Target1 X': Sending state 107.00000 mm with 0 decimals of accuracy
[20:53:09][D][sensor:094]: 'Target1 Y': Sending state 556.00000 mm with 0 decimals of accuracy
[20:53:10][D][sensor:094]: 'Target1 X': Sending state 123.00000 mm with 0 decimals of accuracy
[20:53:10][D][sensor:094]: 'Target1 Y': Sending state 563.00000 mm with 0 decimals of accuracy
[20:53:10][D][sensor:094]: 'Target1 X': Sending state 126.00000 mm with 0 decimals of accuracy
[20:53:10][D][sensor:094]: 'Target1 Y': Sending state 558.00000 mm with 0 decimals of accuracy
[20:53:11][D][sensor:094]: 'Target1 X': Sending state 130.00000 mm with 0 decimals of accuracy
[20:53:11][D][sensor:094]: 'Target1 Y': Sending state 556.00000 mm with 0 decimals of accuracy
[20:53:11][D][sensor:094]: 'Target1 X': Sending state 136.00000 mm with 0 decimals of accuracy
[20:53:11][D][sensor:094]: 'Target1 Y': Sending state 555.00000 mm with 0 decimals of accuracy
[20:53:12][D][sensor:094]: 'Target1 X': Sending state 139.00000 mm with 0 decimals of accuracy
[20:53:12][D][sensor:094]: 'Target1 Y': Sending state 545.00000 mm with 0 decimals of accuracy
[20:53:12][D][sensor:094]: 'Target1 X': Sending state 142.00000 mm with 0 decimals of accuracy
[20:53:12][D][sensor:094]: 'Target1 Y': Sending state 540.00000 mm with 0 decimals of accuracy
[20:53:13][D][sensor:094]: 'Target1 X': Sending state 166.00000 mm with 0 decimals of accuracy
[20:53:13][D][sensor:094]: 'Target1 Y': Sending state 556.00000 mm with 0 decimals of accuracy
[20:53:13][D][sensor:094]: 'Target1 X': Sending state 172.00000 mm with 0 decimals of accuracy
[20:53:13][D][sensor:094]: 'Target1 Y': Sending state 558.00000 mm with 0 decimals of accuracy
[20:53:14][D][sensor:094]: 'Target1 X': Sending state 178.00000 mm with 0 decimals of accuracy
[20:53:14][D][sensor:094]: 'Target1 Y': Sending state 557.00000 mm with 0 decimals of accuracy
[20:53:14][D][sensor:094]: 'Target1 X': Sending state 173.00000 mm with 0 decimals of accuracy
[20:53:15][D][sensor:094]: 'Target1 Y': Sending state 558.00000 mm with 0 decimals of accuracy
[20:53:15][D][sensor:094]: 'Target1 X': Sending state 205.00000 mm with 0 decimals of accuracy
[20:53:15][D][sensor:094]: 'Target1 Y': Sending state 533.00000 mm with 0 decimals of accuracy
[20:53:16][D][sensor:094]: 'Target1 X': Sending state 178.00000 mm with 0 decimals of accuracy
[20:53:16][D][sensor:094]: 'Target1 Y': Sending state 536.00000 mm with 0 decimals of accuracy
[20:53:16][D][sensor:094]: 'Target1 X': Sending state 169.00000 mm with 0 decimals of accuracy
[20:53:16][D][sensor:094]: 'Target1 Y': Sending state 549.00000 mm with 0 decimals of accuracy
[20:53:17][D][sensor:094]: 'Target1 X': Sending state 165.00000 mm with 0 decimals of accuracy
[20:53:17][D][sensor:094]: 'Target1 Y': Sending state 547.00000 mm with 0 decimals of accuracy
[20:53:17][D][sensor:094]: 'Target1 X': Sending state 161.00000 mm with 0 decimals of accuracy
[20:53:17][D][sensor:094]: 'Target1 Y': Sending state 537.00000 mm with 0 decimals of accuracy
[20:53:18][D][sensor:094]: 'Target1 X': Sending state 167.00000 mm with 0 decimals of accuracy
[20:53:18][D][sensor:094]: 'Target1 X': Sending state 166.00000 mm with 0 decimals of accuracy
[20:53:18][D][sensor:094]: 'Target1 Y': Sending state 540.00000 mm with 0 decimals of accuracy
[20:53:19][D][sensor:094]: 'Target1 X': Sending state 162.00000 mm with 0 decimals of accuracy
[20:53:19][D][sensor:094]: 'Target1 Y': Sending state 537.00000 mm with 0 decimals of accuracy
[20:53:19][D][sensor:094]: 'Target1 Speed': Sending state 0.08000 m/s with 2 decimals of accuracy
[20:53:19][W][component:204]: Component uart took a long time for an operation (0.06 s).
[20:53:19][W][component:205]: Components should block for at most 20-30ms.
[20:53:19][D][sensor:094]: 'Target1 X': Sending state 171.00000 mm with 0 decimals of accuracy
[20:53:19][D][sensor:094]: 'Target1 Y': Sending state 523.00000 mm with 0 decimals of accuracy
[20:53:19][D][sensor:094]: 'Target1 Speed': Sending state 0.00000 m/s with 2 decimals of accuracy
[20:53:19][W][component:204]: Component uart took a long time for an operation (0.06 s).
[20:53:19][W][component:205]: Components should block for at most 20-30ms.
[20:53:20][D][sensor:094]: 'Target1 Y': Sending state 536.00000 mm with 0 decimals of accuracy
[20:53:20][D][sensor:094]: 'Target1 X': Sending state 168.00000 mm with 0 decimals of accuracy
[20:53:21][D][sensor:094]: 'Target1 X': Sending state 167.00000 mm with 0 decimals of accuracy
[20:53:21][D][sensor:094]: 'Target1 Y': Sending state 547.00000 mm with 0 decimals of accuracy
[20:53:21][D][sensor:094]: 'Target1 X': Sending state 157.00000 mm with 0 decimals of accuracy
[20:53:21][D][sensor:094]: 'Target1 Y': Sending state 557.00000 mm with 0 decimals of accuracy
[20:53:22][D][sensor:094]: 'Target1 X': Sending state 173.00000 mm with 0 decimals of accuracy
[20:53:22][D][sensor:094]: 'Target1 Y': Sending state 554.00000 mm with 0 decimals of accuracy
[20:53:23][D][sensor:094]: 'Target1 X': Sending state 181.00000 mm with 0 decimals of accuracy
[20:53:23][D][sensor:094]: 'Target1 Y': Sending state 558.00000 mm with 0 decimals of accuracy
[20:53:23][D][sensor:094]: 'Target1 X': Sending state 150.00000 mm with 0 decimals of accuracy
[20:53:23][D][sensor:094]: 'Target1 Y': Sending state 551.00000 mm with 0 decimals of accuracy
[20:53:24][D][sensor:094]: 'Target1 X': Sending state 152.00000 mm with 0 decimals of accuracy
[20:53:24][D][sensor:094]: 'Target1 Y': Sending state 562.00000 mm with 0 decimals of accuracy
[20:53:24][D][sensor:094]: 'Target1 X': Sending state 156.00000 mm with 0 decimals of accuracy
[20:53:24][D][sensor:094]: 'Target1 Y': Sending state 566.00000 mm with 0 decimals of accuracy
[20:53:24][D][binary_sensor:036]: 'Zone1 Presence': Sending state OFF
[20:53:25][D][sensor:094]: 'Target1 Y': Sending state 572.00000 mm with 0 decimals of accuracy
[20:53:25][D][binary_sensor:036]: 'Zone1 Presence': Sending state ON

From the very detailed information you’ve given, it does seem that there is a logical shortcoming here: it looks like the way athua’s delay closes, it can’t be interrupted in the middle of the process, which would be a problem.
We may need to rewrite a function for it to manage and clean up this timer.

This is an important discovery, and it means a small bug exists.

1 Like

According to the documentation there is no error

(Required, time, templatable): When a signal OFF is received, wait for the specified time period until publishing an OFF state. If an ON value is received while waiting, the OFF action is discarded. while waiting, the OFF action is discarded. Or in other words: Only send an OFF value if the binary sensor has stayed OFF for at least the specified time period. When using a lambda call, you should return the delay value in milliseconds. Useful for debouncing push buttons.

The problem is that while waiting for the state, our push code won’t push the new state (because the compared state value is still ON and won’t break the time interrupt), which results in a canceled state that won’t be broken.
So this problem will be a bit more complicated.

I have had a look at the code and the following change seems to help. It may need some further testing to see if it does fix the issue, ie. move the push for the target exists when the target count changes rather than when the target presence changes:

          if (id(zone1_target_count).state != target_count_in_zone1){
            id(zone1_target_count).publish_state(target_count_in_zone1);
            id(zone1_target_exsits).publish_state(has_target_in_zone1);
          }
          //if (id(zone1_target_exsits).state != has_target_in_zone1 ){
          //  id(zone1_target_exsits).publish_state(has_target_in_zone1);
          //}
1 Like

Very genius approach! I think it will work very well and we will integrate this patch.

Added your fix (for all 3 zones) for testing. Will give feedback. Thx for the quick solution.

By starting with a concern about the unsatisfactory static capability of the 2A radar, we found time today to do a basic test using three radar modules:

  • HLK-LD1125F: It’s an alternative version of the LD1125H, which seems to have lower power consumption and greater range. We tested the CEM5825F at the same time and they have almost identical performance and hardware, as does the OP.
  • HLK-LD2410B: This is the radar used on top of the 1U, 1W, very well known and very cost effective.
  • HLK-LD2450: This is the radar used on top of the 2A, with three target tracking capabilities, but HLK only has one open at the moment.

After a brief test, we came up with some of these conclusions:

  • The micro-motion detection ability of the LD2450 is in fact quite good, not too much worse than the 2410 or 1125F, as long as there is a little bit of activity, the target will not disappear. Conversely, when there is very little movement, it will remain undetected on the 1125F for a while and then become unoccupied (utilizing the delay setting). With athua’s recent code contribution, the delay off added to 2A could better ameliorate this unoccupied state issue. The latest release, V230906_1_beta, further improves a shutdown logic that, in conjunction with the shutdown delay, allows for more reliable micromotion detection.
  • The LD2410 has great short range detection capability, but the displayed distance can be extremely off, making it difficult to adjust the parameters.
  • For fixed interference capability, the LD1125F is as bad as the LD2410B and requires adjusting the parameters to exclude it, while the LD1125F can only be adjusted for three levels of sensitivity.
  • The LD1125 has a very large detection angle and high sensitivity, and the distance also seems to be farther. But it was limited by being a desktop computer and couldn’t be moved to a larger living room to test it.
  • The 2A’s LD2450 looks like a great radar as a single mode, and has its own advantages over anti-jamming. While the LD2410 has an advantage in cost/performance ratio with a comprehensive setup, the LD1125F is simple to setup and has a very strong micro-motion detection capability with a greater range and angle.

Next, we hope to build a radar based on the LD1125F, our codename might be Human Sensor F25.

Here’s a video recorded during testing:

public version update to v230906_1 now

Tested it and it works as expected. One very small thing after ESP restart, the presence sensor for the zones stays at “unoccupied” (count is 1) if you are in front of the sensor. Move out and in the zone triggers the presence sensor fine.

If I add this code back in addition, it works correctly even after an ESP restart:

          if (id(zone1_target_exsits).state != has_target_in_zone1 ){
            id(zone1_target_exsits).publish_state(has_target_in_zone1);
          }
1 Like

This patch looks to add a layer of ensuring updates are in there, which is interesting. We’ll add it for testing as well.

If possible can the post startup logs replicate some of this and we can investigate together what this might be causing?

Thanks for a great job! Please advise, I slightly adjusted the source code for Wemos D1 Mini based on ESP8266) I hoped it would work. But unfortunately, there are zeros in the indicators, but in the logs:
02:50:01 [W] [component:204] Component uart took a long time for an operation (0.09 s).
02:50:01 [W] [component:205] Components should block for at most 20-30ms.

I still have Wemos based on ESP-WROOM-32 and ESP32-S2F, maybe they will fit, or the minimum supported board should be based on ESP32-ĐĄ3? Thanks!

I have my LD2450 connected via GPIO17 for TX and GPIO16 for RX on a Wemos Compatible D1 Mini ESP32 which is based on the ESP-WROOM-32 chip with no problems.

1 Like