Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 5190

Automation, sensing and robotics • Re: Connecting a LD2410 radar sensor to a RaspberryPi 3 B+

$
0
0
I have been playing with my LD2410C, and had the same lack of serial communication, until setting the baud rate to 9600.
Check that your LD2410 device is operational with the HLKRadar tool - this operates via bluetooth

Test the serial connection on using either:
(1) https://github.com/vjsyong/LD2410

with the baud rate to 9600

In the `example.py` file:

Code:

   radar = LD2410("/dev/ttyAMA0", baud_rate=PARAM_BAUD_9600, verbosity=logging.INFO)
Output of `example.py, on Rpi5B`:
(py312)[Rpi5NVMe:.+-LD2410C/LD2410]$ python example.py
INFO:root:Serial port initialised at /dev/ttyAMA0, with baud rate 9600
INFO:root:Reading firmware version
b'\xfd\xfc\xfb\xfa\x0c\x00\xa0\x01\x00\x00\x00\x01\x04\x02\x11%\x02#\x04\x03\x02\x01'
V2.04.23022511
INFO:root:Editing detection parameters
INFO:root:Editing gate sensitivity
INFO:root:Reading detection parameters
([2, 3, 1], [50, 50, 40, 50, 20, 15, 15, 15], [27, 36, 40, 40, 30, 30, 20, 20])
INFO:root:Radar polling started
([2, 73, 0, 73, 100, 55], None, None)
([3, 75, 100, 63, 100, 53], None, None)
([3, 66, 67, 63, 100, 51], None, None)
INFO:root:Enabling engineering mode
([3, 30, 100, 30, 100, 0], [8, 100, 100, 66, 99, 60, 35, 12, 12, 3], [0, 0, 100, 100, 100, 100, 62, 39, 21, 119])
([3, 68, 100, 76, 100, 0], [8, 100, 100, 100, 30, 15, 3, 4, 12, 5], [0, 0, 100, 100, 100, 100, 80, 47, 32, 122])
([3, 64, 100, 30, 100, 38], [8, 100, 100, 100, 10, 7, 13, 10, 6, 7], [0, 0, 100, 100, 100, 100, 85, 50, 34, 123])
INFO:root:Disabling engineering mode
INFO:root:Radar polling stopped
INFO:root:Restarting module
INFO:root:Enabling Bluetooth
INFO:root:Getting Bluetooth Address
00:fe:01:00:00:04

(2) Alternative python code: https://github.com/csRon/HLK-LD2450, again 9600 baud:
(py312)[Rpi5NVMe:.+10C/HLK-LD2410B]$ python print_targets.py
Target State: both_targets
Moving Target Distance: 54
Moving Target Energy: 100
Static Target Distance: 63
Static Target Energy: 100
Distance: 41

------------------------------

Target State: both_targets
Moving Target Distance: 66
Moving Target Energy: 100
Static Target Distance: 54
Static Target Energy: 100
Distance: 42
(py312)[Rpi5NVMe:.+10C/HLK-LD2410B]$ python plot_targets.py
/home/stg121/Software/HLK-LD2410C/HLK-LD2410B/plot_targets.py:65: UserWarning: frames=None which we can infer the length of, did not pass an explicit *save_count* and passed cache_frame_data=True. To avoid a possibly unbounded cache, frame data caching has been disabled. To suppress this warning either pass `cache_frame_data=False` or `save_count=MAX_FRAMES`.
ani = FuncAnimation(fig, update_plot, blit=True)
40
41
39
38
39
41
41
41
42
43
:

I am not sure whether the serial 9600 baud requirement is an issue with my sensor.

Statistics: Posted by SteveRPi — Tue Aug 13, 2024 12:44 am



Viewing all articles
Browse latest Browse all 5190

Trending Articles