DIY Human Sensor L12 Base on HLK-LD2412

Used your @Rihan ext.component, works, but Moving target is always clear.
Tried @screek-workshop code from git also, but it compiles “empty” bin somewhy for me… can’t get the reason for now. Using lolin s2 mini board.

Hi @OwlBawl, I saw your issue on github, I’ll reply you there.

@jtenniswood the component is “LD2412”. You can see an example on the README. I need to add the distance_resolution that I just fixed, but for the rest it should work. The sintax is the same of LD2410 in the official espHome documentation. Some of the feature doesn’t work and will raise an error on compilation, but for the rest is the same.

Thanks, I managed to get it working, I was using lower case, as that was the code used on the screen code, but noticed your code was using upper case, so all good.

I managed to use some of my existing code for zones, just needed to add the ID’s in.
The 2412 doesn’t update as quickly or as specifically as the 2410, the results are still good though.
Thanks for pulling this together.

In case anyone needs it…

external_components:
  - source:
      type: git
      url: https://github.com/Rihan9/LD2412
      ref: main
    components: [LD2412]

Hi,
Next time I’ll add this sample in the README.md, thanks!
For the slow response: It can be a sensor problem or the baudrate Is too slow. Try to increase It from the app (you Need to set the same boudrate in the esphome configuration)

managed to run @screek-workshop component (just the same way - components: [LD2412] )
It shows movement for me and so on.
The data update is much faster in their approach because, as i noticed, they switch module to engineering mode, and it can’t be switched off in app so. so any changes are lightning fast in HA.

As I understand, the HLK 2412 protocol itself supports the Sensitivity parameters, Engineering mode, Resolution Parameters, Min/max distance parameters setup via uart?

Protocol description for v1.05

Yes, correct

managed to run @screek-workshop component (just the same way - components: [LD2412] )
It shows movement for me and so on.
The data update is much faster in their approach because, as i noticed, they switch module to engineering mode, and it can’t be switched off in app so. so any changes are lightning fast in HA.

@OwlBawl Ok, I checked the code from screekworkshop and understand what you mean. I’ll work on implementing the engineering mode in the future. For know, I’m checking why in the periodic message the values that supposed to have the moving target information are 0 or the code doesn’t catch them.

1 Like

Good to hear, sure hlk community need 2410 like integration of new 2412 with full HA settings and data :+1:

Could you add the sensor for detection distance, as it’s useful to have an overall distance for zone sensors, rather than just moving and still.

It exists in 2410, so hopefully isn’t much work.
Thanks!

I tried out the screek version, the performance is really good, it’s nice to see the distance be much more accurate rather than in 75cm groups. One issue I can see is that at long range the false positives keep the presence on longer than it should.

It would be useful to have control over the thresholds as the 2410 offers, this would help adjust it so it can sense no presence a fair bit quicker.

Thanks all!

I’m glad to see everyone exploring the LD2412 together. I’m sorry I haven’t been able to respond in a timely manner recently due to being busy.
Adding distance seems to be a simple implementation, and it can be achieved by simply combining a distance. However, it must also be considered that the distance of LD2412 is quite inaccurate and is only of reference value. HLK’s explanation for this is that the ranging part has been sacrificed, and the algorithm prioritizes detection range.

2 Likes

It would be much better if you could add uart sensitivity threshold…. It would be almost full in usage so via HA

I’ll work on it.
Meanwhile I fixed the uart boud rate picklist, the bluetooth switch and the factory reset button.
In the “Dev” branch you can also find the engineering mode and the background noise detenction implemented. It’s not merged yet because I’m going to test it a little bit more

1 Like

Would make a try with you ext.component a bit later again. Thank you for your work

@Rihan Hey I have used Your code and I am pretty pleased with it.

One thing is that mine LD2412 is connected to ESP32-C3 board on default UART GPIO21/20 and after boot up It wont communicate to LD until I change baud rate.

Second thing does anyone have experience with frequently turning engineering mode (I knot that is is not accessible right now) on and off just to pull data from that luminance sensor ? Only disadvantage that I could find is that it is “resource consuming”

Hi Kosy,
thanks for your feedback!
For the first think I think I need a way to retain the UART boudrate after restart, noted. If you can open an issue I’ll appreciate it.
EDIT: forget the issue, is not really a problem on the sensor implementation. You should be able to do it with your esphome configuration. Like a on_boot lambda script to reset the uart boudrate based on the sensor select value

For the second think, if you switch to te dev branch, you can find the basic implementation of the engineering mode. Is still work in progress, so it’s still lack of the light sensor and gate threshold implementation. I don’t like how the light sensor work however. Is just a plain number from 0 to 255 and is too sensible. In my sensor just a background light is enough to complete saturate it. I’ll still plan to implement it just because maybe there is someone who wants it. Or maybe with a little cover, it can be used better.

Good point.
During playing around with on_boot I just realizsed that uart component has baud_rate entry on its own setting it up to 460800 did the trick.

I will surely check dev branch after little fight with LVGL.
I do not expect anything big from that light sensor. Whole mmWave will activate night light form my kids as they are very good at breaking/losing zb remotes :wink:

Hi All,
can I ask you something? I’m experiencing some “lag issues” with LD2412. The sensor took like 2 or 3 seconds to detect a new person entering the range. Do you also experience something similar? Is the OUT_PIN more responsive than the UART? Maybe this issue is due to a saturation in the uart buffer