#heartbeat #sensors #serial #interfacing #module #radar #respiratory

hlk_ld6002

A library for interfacing with the HLK-LD6002 respiratory and heartbeat radar module

1 unstable release

0.1.0 Feb 24, 2024

#891 in Hardware support

MIT/Apache

14KB
286 lines

HLK-LD6002

A library for community with HLK-LD6002 radar respiratory and heartbeat sensors.

Supports both sync and async serial ports using embedded-io or embedded-io-async.

A note about serial adapters.

The sensor use 1.382.400 baud UART for communicating, not all serial adapters support baud rates this high. Using an adapter that doesn't support this baud rate (like the common CP210 based adapters) can lead to silent failures.


lib.rs:

A library for community with HLK-LD6002 radar respiratory and heartbeat sensors.

Usage

use embedded_io_adapters::std::FromStd;
use hlk_ld6002::{Data, MessageStream};
use serialport::ClearBuffer;
use std::time::Duration;

let port = serialport::new("/dev/ttyUSB0", 1_382_400)
    .timeout(Duration::from_millis(50))
    .open()
    .expect("Failed to open port");

let mut messages = MessageStream::new(FromStd::new(port));

let mut data = Data::default();

for message in messages.flatten() {
    data.update(message);
    println!("{data:?}");
}

Dependencies

~0.5–1MB
~21K SLoC