|
LD2410Async
Asynchronous Arduino ESP32 library for the LD2410 mmWave radar sensor
|
Go to the source code of this file.
Macros | |
| #define | RADAR_RX_PIN 16 |
| Example: Basic Presence Detection with LD2410Async. | |
| #define | RADAR_TX_PIN 17 |
| #define | RADAR_BAUDRATE 256000 |
Functions | |
| HardwareSerial | RadarSerial (1) |
| void | onDetectionDataReceived (LD2410Async *sender, bool presenceDetected) |
| Callback function called whenever new detection data arrives. | |
| void | setup () |
| Arduino setup function which initializes the radar and registers the callback. | |
| void | loop () |
| Arduino loop function which does nothing. | |
Variables | |
| LD2410Async | radar (RadarSerial) |
| Creates LD2410Async object bound to the serial port defined in RadarSerial. | |
| bool | lastPresenceDetected = false |
| bool | firstCallback = true |
| #define RADAR_BAUDRATE 256000 |
Definition at line 24 of file basicPresenceDetection.ino.
| #define RADAR_RX_PIN 16 |
Example: Basic Presence Detection with LD2410Async.
This sketch demonstrates how to use the LD2410Async library to detect presence using only the presenceDetected variable from the detection data callback. It prints a message with a timestamp whenever the presence state changes.
Definition at line 20 of file basicPresenceDetection.ino.
| #define RADAR_TX_PIN 17 |
Definition at line 21 of file basicPresenceDetection.ino.
| void loop | ( | ) |
Arduino loop function which does nothing.
The LD2410Async library runs a FreeRTOS background task that automatically handles all jobs that are related to the radar sensor. Therefore the main loop doesnt have to da any LD2410 related work and is free for anything else you might want to do.
Definition at line 103 of file basicPresenceDetection.ino.
| void onDetectionDataReceived | ( | LD2410Async * | sender, |
| bool | presenceDetected ) |
Callback function called whenever new detection data arrives.
Since only basic presence information is required in the example, it is just using the presenceDetected para of the callback. The logic in this methods just ensures that only changes in presence state are printed to the Serial Monitor.
Definition at line 54 of file basicPresenceDetection.ino.
| HardwareSerial RadarSerial | ( | 1 | ) |
Create a HardwareSerial instance (ESP32 has multiple UARTs) bound to UART1
| void setup | ( | ) |
Arduino setup function which initializes the radar and registers the callback.
radar.begin() starts the background task of the LD2410Async library which automatically handles incoming data and triggers callbacks. The onDetectionDataReceived callback is registered to receive detection data.
Definition at line 74 of file basicPresenceDetection.ino.
| bool firstCallback = true |
Definition at line 41 of file basicPresenceDetection.ino.
| bool lastPresenceDetected = false |
Definition at line 40 of file basicPresenceDetection.ino.
| LD2410Async radar(RadarSerial) | ( | RadarSerial | ) |
Creates LD2410Async object bound to the serial port defined in RadarSerial.