25#define RADAR_RX_PIN 16
26#define RADAR_TX_PIN 17
29#define RADAR_BAUDRATE 256000
60 Serial.println(
"=== Detection Data ===");
62 Serial.
print(
"Target State: ");
63 Serial.println(LD2410Types::targetStateToString(data.
targetState));
65 Serial.print(
"Presence detected: ");
68 Serial.print(
"Moving presence: ");
71 Serial.print(
"Stationary presence: ");
74 Serial.print(
"Moving Distance (cm): ");
77 Serial.print(
"Stationary Distance (cm): ");
80 Serial.print(
"Light Level: ");
83 Serial.println(
"======================");
100 Serial.println(
"LD2410Async Example: Receive Data");
107 Serial.println(
"Radar task started successfully.");
112 Serial.println(
"ERROR! Could not start radar task.");
Asynchronous driver class for the LD2410 human presence radar sensor.
bool begin()
Starts the background task that continuously reads data from the sensor.
void onDetectionDataReceived(DetectionDataCallback callback)
Registers a callback for new detection data.
const LD2410Types::DetectionData & getDetectionDataRef() const
Access the current detection data without making a copy.
HardwareSerial RadarSerial(1)
void setup()
Arduino setup function which initializes the radar and registers the callback.
void onDetectionDataReceived(LD2410Async *sender, bool presenceDetected)
LD2410Async radar(RadarSerial)
Creates LD2410Async object bound to the serial port defined in RadarSerial.
#define RADAR_RX_PIN
: Example: Receive detection data from the LD2410
void loop()
Arduino loop function which does nothing.
Holds the most recent detection data reported by the radar.
void print() const
Debug helper: print detection data contents to Serial.
bool stationaryPresenceDetected
True if a stationary target is detected.
byte lightLevel
Reported ambient light level (0-255).
TargetState targetState
Current detection state.
bool presenceDetected
True if any target is detected.
bool movingPresenceDetected
True if a moving target is detected.
unsigned int movingTargetDistance
Distance (cm) to the nearest moving target.
unsigned int stationaryTargetDistance
Distance (cm) to the nearest stationary target.