LD2410Async
Asynchronous Arduino ESP32 library for the LD2410 mmWave radar sensor
Loading...
Searching...
No Matches
receiveData.ino File Reference
#include <Arduino.h>
#include "LD2410Async.h"

Go to the source code of this file.

Macros

#define RADAR_RX_PIN   16
 : Example: Receive detection data from the LD2410
 
#define RADAR_TX_PIN   17
 
#define RADAR_BAUDRATE   256000
 

Functions

HardwareSerial RadarSerial (1)
 
void onDetectionDataReceived (LD2410Async *sender, bool presenceDetected)
 
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.
 

Macro Definition Documentation

◆ RADAR_BAUDRATE

#define RADAR_BAUDRATE   256000

Definition at line 29 of file receiveData.ino.

◆ RADAR_RX_PIN

#define RADAR_RX_PIN   16

: Example: Receive detection data from the LD2410

This sketch initializes the LD2410 radar sensor on Serial1 and prints detection data to the Serial Monitor as soon as it arrives. This sketch demonstrates how to:

  1. Initialize the radar on Serial1.
  2. register a callback to receive detection data.
  3. Get a pointer to the detection data struct.
Warning
Important: Make sure to adjust RADAR_RX_PIN and RADAR_TX_PIN to match you actual wiring.

Definition at line 25 of file receiveData.ino.

◆ RADAR_TX_PIN

#define RADAR_TX_PIN   17

Definition at line 26 of file receiveData.ino.

Function Documentation

◆ loop()

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 124 of file receiveData.ino.

◆ onDetectionDataReceived()

void onDetectionDataReceived ( LD2410Async * sender,
bool presenceDetected )

Definition at line 56 of file receiveData.ino.

◆ RadarSerial()

HardwareSerial RadarSerial ( 1 )

Create a HardwareSerial instance (ESP32 has multiple UARTs) bound to UART1

◆ setup()

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 94 of file receiveData.ino.

Variable Documentation

◆ radar

Creates LD2410Async object bound to the serial port defined in RadarSerial.