{"id":29977452,"url":"https://github.com/mvdschee/ld2410s","last_synced_at":"2026-02-25T12:37:27.661Z","repository":{"id":308092859,"uuid":"1031411152","full_name":"mvdschee/ld2410s","owner":"mvdschee","description":"LD2410S driver","archived":false,"fork":false,"pushed_at":"2025-08-03T17:22:07.000Z","size":1,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-08-04T06:06:12.850Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mvdschee.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-08-03T17:22:06.000Z","updated_at":"2025-08-03T17:22:10.000Z","dependencies_parsed_at":"2025-08-04T06:06:16.729Z","dependency_job_id":"e77ffdeb-3390-4a49-84a5-b38c0b856298","html_url":"https://github.com/mvdschee/ld2410s","commit_stats":null,"previous_names":["mvdschee/ld2410s"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/mvdschee/ld2410s","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mvdschee%2Fld2410s","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mvdschee%2Fld2410s/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mvdschee%2Fld2410s/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mvdschee%2Fld2410s/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mvdschee","download_url":"https://codeload.github.com/mvdschee/ld2410s/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mvdschee%2Fld2410s/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":268683044,"owners_count":24289733,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-04T02:00:09.867Z","response_time":79,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-08-04T10:40:52.236Z","updated_at":"2026-02-25T12:37:27.648Z","avatar_url":"https://github.com/mvdschee.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"# LD2410S Rust Driver\n\nA Rust library for reading and controlling the **HLK-LD2410S** 24GHz radar presence sensor over UART.\nSupports both **desktop** (via [serialport](https://crates.io/crates/serialport)) and **embedded** (via [esp-idf-hal](https://crates.io/crates/esp-idf-hal)) targets.\n\n## ✨ Features\n\n- Works with **desktop** and **ESP-IDF** environments using the same API.\n- **Unified UART interface** so your application doesn’t need to handle serial quirks.\n- Built-in **frame parsing** for:\n  - **Minimal Packets** (Presence state, Distance)\n  - **Standard/Engineering Packets** (Distance, Signal Energy arrays)\n  - **Firmware Version** \u0026 **Serial Number**\n- **Configuration Support**:\n  - Switch between Minimal and Standard/Engineering modes.\n  - Configure reporting frequency (e.g., 8Hz).\n  - Configure response speed.\n- Automatic caching of last reading if no fresh data is available.\n\n## 📚 Documentation\n\nThis library implements the protocol defined in the official HLK-LD2410S manuals:\n\n- [HLK-LD2410S Serial Communication Protocol V1.00](./docs/HLK-LD2410S_serial_communication_protocol-V1.00.pdf) (26 Nov 2024)\n- [HLK-LD2410S User Manual V1.2](./docs/HLK-LD2410S_User_manual-V1.2.pdf) (20 Apr 2024)\n\n## 📦 Installation\n\nAdd to your `Cargo.toml`:\n\n```toml\n[dependencies]\nld2410s = { git = \"https://github.com/mvdschee/ld2410s\", tag = \"v0.1.2\", features = [\"serial\"] }    # desktop serialport\n# ld2410s = { git = \"https://github.com/mvdschee/ld2410s\", tag = \"v0.1.2\", features = [\"embedded\"] } # embedded ESP-IDF\n```\n\n## 🚀 Examples\n\n### Desktop (via USB-to-UART adapter)\n\n    cargo run --example desktop --features serial\n\n```rs\n\tlet port = serialport::new(\"/dev/tty.usbserial-123\", BAUD_RATE)\n\t\t.timeout(Duration::from_millis(50))\n\t\t.open()?;\n\n\t// 1. Initialize sensor (Standard Mode = Engineering Data)\n\tlet mut sensor = LD2410S::new(SerialPortWrapper(port), OutputMode::Standard);\n\tsensor.init()?;\n\n\t// 2. Configure for faster updates (8Hz)\n\tsensor.set_distance_frequency(8.0)?;\n\tsensor.set_status_frequency(8.0)?;\n\tsensor.set_response_speed(10)?;\n\n\tloop {\n\t\tif let Some(reading) = sensor.read_latest()? {\n\t\t\tmatch reading.data {\n\t\t\t\tld2410s::Packet::Standard(s) =\u003e println!(\"Dist: {} Energy: {:?}\", s.distance_cm, s.energy),\n\t\t\t\t_ =\u003e {}\n\t\t\t}\n\t\t}\n\t}\n```\n\n### ESP32 (via `esp-idf-hal`)\n\n    cargo run --example esp --features embedded\n\n```rs\n\tlet peripherals = Peripherals::take().unwrap();\n\tlet pins = peripherals.pins;\n\tlet cfg = Config::default().baudrate(BAUD_RATE.Hz());\n\tlet uart = UartDriver::new(\n\t\tperipherals.uart1,\n\t\tpins.gpio4,\n\t\tpins.gpio5,\n\t\tNone, None,\n\t\t\u0026cfg,\n\t)?;\n\n\tlet mut sensor = LD2410S::new(EspUartWrapper(uart), OutputMode::Standard);\n\tsensor.init()?;\n\tsensor.set_distance_frequency(8.0)?;\n\n\tloop {\n\t\tif let Some(reading) = sensor.read_latest()? {\n\t\t\tmatch reading.data {\n\t\t\t\tld2410s::Packet::Standard(s) =\u003e println!(\"Dist: {} Energy: {:?}\", s.distance_cm, s.energy),\n\t\t\t\t_ =\u003e {}\n\t\t\t}\n\t\t}\n\t}\n```\n\n## ⚙️ Advanced Configuration\n\n### Manual Thresholds\n\nYou can manually set the sensitivity (energy threshold) for each of the 16 distance gates.\n\n- **Trigger Threshold**: Energy required to switch from Unoccupied -\u003e Occupied.\n- **Hold Threshold**: Energy required to maintain Occupied state.\n\n```rs\n// Set gates 0-15. Lower value = Higher sensitivity.\n// Example: High sensitivity for close range (gates 0-2), lower for far (3-15).\nlet triggers: [u16; 16] = [\n    15, 15, 20, 30, 40, 50, 60, 60,\n    60, 60, 60, 60, 60, 60, 60, 60\n];\nsensor.set_trigger_thresholds(\u0026triggers)?;\n\n// Hold thresholds are usually slightly lower than trigger to prevent flickering\nlet holds: [u16; 16] = [\n    10, 10, 15, 25, 35, 45, 55, 55,\n    55, 55, 55, 55, 55, 55, 55, 55\n];\nsensor.set_hold_thresholds(\u0026holds)?;\n```\n\n### Automatic Calibration\n\nUse this **once** during installation with an **empty room**. The sensor will measure background noise and set thresholds automatically.\n\n```rs\n// 1. Trigger Factor (added to noise floor for Trigger)\n// 2. Retention Factor (added to noise floor for Hold)\n// 3. Scanning Time (seconds)\n// Example: factor=2, retention=1, scan=120s\nsensor.set_auto_threshold(2, 1, 120)?;\n```\n\n## ⚙️ Feature Flags\n\n- `serial` → Use [serialport](https://crates.io/crates/serialport) (desktop/hosted)\n- `embedded` → Use [esp-idf-hal](https://crates.io/crates/esp-idf-hal) (ESP32)\n\n## 📝 License\n\nMIT License.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmvdschee%2Fld2410s","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmvdschee%2Fld2410s","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmvdschee%2Fld2410s/lists"}