Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LD2420 Support #14

Open
soubhik-khan opened this issue Apr 13, 2023 · 24 comments
Open

LD2420 Support #14

soubhik-khan opened this issue Apr 13, 2023 · 24 comments

Comments

@soubhik-khan
Copy link

Requesting support for LD2420

@patrick3399
Copy link
Owner

patrick3399 commented May 18, 2023

Will try to figure out how it works.

@vuquanhp
Copy link

I have bought 2 pcs. And both of them did not run. Use original LD2420 tool on PC, it cannot connect. OT1, OT2 and RX always in high state. Electric consumable is ~50mA - normal, as the datasheet.

@simonyel
Copy link

I have bought 2 pcs. And both of them did not run. Use original LD2420 tool on PC, it cannot connect. OT1, OT2 and RX always in high state. Electric consumable is ~50mA - normal, as the datasheet.

I got 5 on AliExpress and the same issue, mfg site has no tool or manual posted which is odd. I wonder if these even shipped with firmware loaded.

@andresv
Copy link

andresv commented Oct 13, 2023

Some observations: https://twitter.com/andresvahter/status/1712460762206372032

@simonyel
Copy link

Some observations: https://twitter.com/andresvahter/status/1712460762206372032

This note did the trick for me! Thank you!

@andresv
Copy link

andresv commented Oct 13, 2023

At least it responds to version query, but I haven't got reasonable sensor output yet.

I am using these resources:

Just started to try out scary chinesium tool and logging serial responses with saleae logic analyzer.

@janwego
Copy link

janwego commented Oct 14, 2023

Some observations: https://twitter.com/andresvahter/status/1712460762206372032

Thanks Andres, really helped me in getting it to work.
When connecting the device via USB Serial adapter and using the tool, I can see the live image from the device and it changes when I wave the hand in front of it. But when I only connect vial Serial it always says "Range 11 ON" and the Output pin (the correct one) is always high although nothing moved in front of the sensor.

Does anybody know what the values in the Tool mean?

BR,

Jan

@janwego
Copy link

janwego commented Oct 15, 2023

Okay, I solved it:

  1. You need to keep in mind what @andresv wrote, pin 3 and 5 are mixed and Baud is 115200
  2. I luckily ordered the UART from HiLink ( HLK-CH340E ) so I could connect a LD2420 and read its config with the HLK tool.
    I made a screenshot and translated it with google translate so I could understand the parameter at least a little bit.
    The problem why others only receive HIGH is: the delay-time (after the movement stopped) is 30 (THIRTY) seconds, every little movement adds again 30 seconds:

translated_image_de_edited

  1. To resolve this, I changed the value to 5 seconds and wrote the config to my device. All other sensitivity values were left untouched.
  2. The problem I described above (although movement stopped, device keeps sending "Range 11 ON" or "Range 12 ON" happens when you write config to the device. Don't know why but when I pull the usb-adapter out and insert it back again the device acts just as it should with the configured values.
  3. So reboot sensor after config write.
  4. Afterwards I could read the distance in cm from the console and after I stopped moving, five seconds later the output switched to "Off" until I moved again

@andresv
Copy link

andresv commented Oct 16, 2023

@janwego how did you read out distance?
I put sensor into streaming mode using hlk tool and I can see that following data is sent periodically (around 128 bytes). However it seems to have totally different header.

Screenshot 2023-10-16 at 12 02 09

Edit

Okay I was putting device into streaming mode and this is not documented, however hlk tool understands this.
After doing powercycle it goes to normal mode where range is sent in ASCII:

ON
Range 72

@janwego
Copy link

janwego commented Oct 16, 2023

You were faster than me - glad it works now for you :)
Don't even know what you meant by streaming mode - I just connected the device to the Serial Adapter and connected with Putty to COM-Port and Baud 115200

@andresv
Copy link

andresv commented Oct 16, 2023

If you start this:
Screenshot 2023-10-16 at 11 02 59
Then sensor starts to send ~126 bytes data packets to UART. Here it is mentioned that this mode is not documented anywhere: https://github.com/descipher/esphome/blob/24fa4147dd50f612dd284ef4647f42def0deab10/esphome/components/ld2420/ld2420.cpp#L134 so currently it seems that just HLK tool knows about it.

@janwego
Copy link

janwego commented Oct 16, 2023

Aaah okay, now I know what you mean - I meant that when I said "I can see the live image from the device" . Don't know if they'll ever deliver the code. The LD2420 isn't completely supported by ESPHome yet is it?

@jcard0na
Copy link

jcard0na commented Dec 7, 2023

Hi @andresv, @janwego

Were you able to decipher the LD2420 communication? I'm trying to write a driver for it, but the data I get from the device does not match the protocol documented here

Instead, I'm getting ASCII output like the one you observed:

Sent: [fd, fc, fb, fa, 4, 0, ff, 0, 2, 0, 4, 3, 2, 1]
Wait 100ms
Clear input buffer
Sent: [fd, fc, fb, fa, 4, 0, ff, 0, 2, 0, 4, 3, 2, 1]
Received: [4f, 4e, d, a, 52, 61, 6e, 67, 65, 20, 32, 35, d, a]
(in ASCII): 
ON
Range 25

The protocol documentation says I should expect a binary reply like [FD FC FB FA 08 00 FF 01 00 00 02 00 20 00 04 03 02 01]

I'll appreciate any pointers you can share! I've reached out to the manufacturer who have not been very responsive so far...

@andresv
Copy link

andresv commented Dec 7, 2023

I did not look into deciphering and just went with ASCII output.

@eried
Copy link

eried commented Jan 1, 2024

Hi @andresv, @janwego

Were you able to decipher the LD2420 communication? I'm trying to write a driver for it, but the data I get from the device does not match the protocol documented here

Instead, I'm getting ASCII output like the one you observed:

Sent: [fd, fc, fb, fa, 4, 0, ff, 0, 2, 0, 4, 3, 2, 1]
Wait 100ms
Clear input buffer
Sent: [fd, fc, fb, fa, 4, 0, ff, 0, 2, 0, 4, 3, 2, 1]
Received: [4f, 4e, d, a, 52, 61, 6e, 67, 65, 20, 32, 35, d, a]
(in ASCII): 
ON
Range 25

The protocol documentation says I should expect a binary reply like [FD FC FB FA 08 00 FF 01 00 00 02 00 20 00 04 03 02 01]

I'll appreciate any pointers you can share! I've reached out to the manufacturer who have not been very responsive so far...

maybe the protocol is the same as ld2410 instead?

@andresv I wonder if is the ld2420 the same with regards as reporting gates/energy in "engineering mode" as the ld2410? (as the later reports 9 values of static + 9 values of movement, I wonder if the ld2420 reports 15 of each)

@patrick3399
Copy link
Owner

@simonyel
Copy link

simonyel commented Jan 1, 2024 via email

@perlchamp
Copy link

perlchamp commented Jan 2, 2024

Hi, what we're talking about?
What Version of board you have ?
Mine is V2.1, the tool you need for that is V1.2.1.1 AND manual V1.3 from december '23.
But i can't find the manual for it. It has to be V1.3 manual, please in englisch or german.
The chinese version has inserted some jpeg instead of text so no copying/translating is possible...
Maybe somebody can find a english-version of this manual, thanks.

so long
Pc

@jcard0na
Copy link

jcard0na commented Jan 2, 2024

Thanks @perlchamp

I also have board v2.1. The manual I have is v1.2, and the manufacturer also provided a protocol document without a version number (attached).

HLK-LD2420 Protocol Document.pdf

@perlchamp
Copy link

perlchamp commented Jan 3, 2024

Hi, thank you. I have this document, too.
In a few days i will post the final version of the .exe.
GER__HLK-LD2420_TOOL(v1.2.1.1).zip

@elas123
Copy link

elas123 commented Jan 21, 2024

anyone know the latest firmware? i got with 1.5.9. is there newer?

@ihayri
Copy link

ihayri commented Apr 6, 2024

Does anybody have a library that works with the LD2420, need to get it running on an ESP32 without ESPHome, thanks.

@jbeam54
Copy link

jbeam54 commented May 2, 2024

Hi. My LD2420 works fine, but the Presence Signal Output (OT2) always has a high level (3.3V). Any ideas? Board v2.1

@Higgmeister
Copy link

For those coming here looking for an answer to why they are only seeing text (ON/OFF Range ##) when reading the LD2420.

It's a matter of being in the right mode and "Normal Working" mode is the default which is why you see the limited text. Following is a list of modes supported by the LD2420. The value (I do mine in HEX) must be sent to the LD2420 before reading the data stream. Once the sensor is put into "Report" mode, you can read the stream and it'll be 45 hex characters long. As mentioned above, once the sensor is power cycled or reset, it reverts into "Normal Working" mode again and needs to be set again.

This code puts LD2420 into report mode. Must do before reading buffer.
FD FC FB FA 08 00 12 00 00 00 04 00 00 00 04 03 02 01

This code puts LD2420 into Normal working mode. This outputs detection results and range gate of detected target.
FD FC FB FA 08 00 12 00 00 00 64 00 00 00 04 03 02 01

This code puts LD2420 into debugging mode.
FD FC FB FA 08 00 12 00 00 00 00 00 00 00 04 03 02 01

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests