// HLK-LD2410 mmWave presence/distance sensor driver, over UART. // // Chosen over a plain PIR for this app's "believable" ethos (per the spec): // the LD2410 reports moving-target distance/energy AND stationary-target // distance/energy separately, not just a boolean "something moved" — richer // signal for the anomaly pipeline (Workstream K) to work with, and it can // tell a séance's "someone opened a door" from "the sitter shifted in their // chair" in a way a PIR fundamentally cannot. Tradeoff: it's a more complex // protocol than a PIR's single GPIO pin, and this driver's frame parser is // UNVERIFIED against a real module — see README.md's honesty section and // the parsing notes in ld2410.c. // // Default wiring (3.3V logic — do NOT wire directly to a 5V-logic UART): // LD2410 TX -> ESP32 RX (LD2410_UART_RX_GPIO) // LD2410 RX -> ESP32 TX (LD2410_UART_TX_GPIO) // LD2410 VCC -> 5V (module runs its sensor front-end at 5V; UART logic is // 3.3V-tolerant per module datasheet -- double check your // specific board revision before wiring) // LD2410 GND -> GND // Default UART settings: 256000 baud, 8N1 (module factory default). #pragma once #include "esp_err.h" #include "sensor_driver.h" #ifdef __cplusplus extern "C" { #endif #ifndef LD2410_UART_PORT #define LD2410_UART_PORT 1 #endif #ifndef LD2410_UART_RX_GPIO #define LD2410_UART_RX_GPIO 17 #endif #ifndef LD2410_UART_TX_GPIO #define LD2410_UART_TX_GPIO 18 #endif #ifndef LD2410_UART_BAUD #define LD2410_UART_BAUD 256000 #endif // sensor_driver_t-compatible entry points. esp_err_t ld2410_init(void); esp_err_t ld2410_read(sensor_reading_t *out, size_t max_out, size_t *out_count); #ifdef __cplusplus } #endif