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

Go to the source code of this file.

Macros

#define RADAR_RX_PIN   32
 ESP32 pin receiving data from the radar (radar TX)
 
#define RADAR_TX_PIN   33
 ESP32 pin transmitting data to the radar (radar RX)
 
#define RADAR_BAUDRATE   256000
 UART baudrate for radar sensor (default is 256000)
 
#define LED_PIN   2
 GPIO for internal LED (adjust if needed)
 

Functions

HardwareSerial RadarSerial (1)
 HardwareSerial instance bound to UART1.
 
void enableConfigModeCallback (LD2410Async *sender, LD2410Async::AsyncCommandResult result)
 Callback for enableConfigModeAsync().
 
void extraCommandCallback (LD2410Async *sender, LD2410Async::AsyncCommandResult result)
 Callback for extra commands.
 
void disableConfigModeCallback (LD2410Async *sender, LD2410Async::AsyncCommandResult result)
 Callback for disableConfigModeAsync().
 
void printPaddedNumber (unsigned long value)
 Print a number padded to 6 characters width.
 
const char * resultToString (LD2410Async::AsyncCommandResult result)
 Convert AsyncCommandResult enum to human-readable text.
 
void scheduleNextSequence ()
 Schedule the next test sequence.
 
void onDetectionDataReceived (LD2410Async *sender, bool presenceDetected)
 Callback triggered when new detection data is received.
 
void setup ()
 Arduino setup function.
 
void loop ()
 Arduino loop function.
 

Variables

LD2410Async ld2410 (RadarSerial)
 LD2410Async driver instance.
 
Ticker delayTicker
 Ticker for randomized delays.
 
unsigned long enableStartMs = 0
 Timestamp when enableConfigModeAsync() was called.
 
unsigned long minEnableDurationMs = ULONG_MAX
 Minimum execution time measured so far.
 
unsigned long maxEnableDurationMs = 0
 Maximum execution time measured so far.
 
unsigned long totalEnableDurationMs = 0
 Sum of all measured durations.
 
unsigned long measurementCount = 0
 Number of successful measurements.
 
unsigned long failureCount = 0
 Number of failed measurements.
 
unsigned long delayMs = 0
 Delay before the tests.
 
unsigned long dataCount = 0
 Used to count received data frames.
 

Macro Definition Documentation

◆ LED_PIN

#define LED_PIN   2

GPIO for internal LED (adjust if needed)

Definition at line 32 of file enableConfigModeTest.ino.

◆ RADAR_BAUDRATE

#define RADAR_BAUDRATE   256000

UART baudrate for radar sensor (default is 256000)

Definition at line 31 of file enableConfigModeTest.ino.

◆ RADAR_RX_PIN

#define RADAR_RX_PIN   32

ESP32 pin receiving data from the radar (radar TX)

Definition at line 29 of file enableConfigModeTest.ino.

◆ RADAR_TX_PIN

#define RADAR_TX_PIN   33

ESP32 pin transmitting data to the radar (radar RX)

Definition at line 30 of file enableConfigModeTest.ino.

Function Documentation

◆ disableConfigModeCallback()

void disableConfigModeCallback ( LD2410Async * sender,
LD2410Async::AsyncCommandResult result )

Callback for disableConfigModeAsync().

Once config mode is disabled, schedules the next test sequence.

Parameters
senderPointer to the LD2410Async instance
resultResult of the command

Definition at line 231 of file enableConfigModeTest.ino.

◆ enableConfigModeCallback()

void enableConfigModeCallback ( LD2410Async * sender,
LD2410Async::AsyncCommandResult result )

Callback for enableConfigModeAsync().

Updates statistics, prints results and triggers an extra command.

Parameters
senderPointer to the LD2410Async instance
resultResult of the command

Definition at line 153 of file enableConfigModeTest.ino.

◆ extraCommandCallback()

void extraCommandCallback ( LD2410Async * sender,
LD2410Async::AsyncCommandResult result )

Callback for extra commands.

Parameters
senderPointer to the LD2410Async instance
resultResult of the command

Definition at line 212 of file enableConfigModeTest.ino.

◆ loop()

void loop ( )

Arduino loop function.

Empty because everything is event-driven using callbacks and ticker.

Definition at line 300 of file enableConfigModeTest.ino.

◆ onDetectionDataReceived()

void onDetectionDataReceived ( LD2410Async * sender,
bool presenceDetected )

Callback triggered when new detection data is received.

Parameters
senderPointer to the LD2410Async instance
presenceDetectedConvenience flag for presence detection

Definition at line 249 of file enableConfigModeTest.ino.

◆ printPaddedNumber()

void printPaddedNumber ( unsigned long value)

Print a number padded to 6 characters width.

Parameters
valueNumber to print

Definition at line 71 of file enableConfigModeTest.ino.

◆ RadarSerial()

HardwareSerial RadarSerial ( 1 )

HardwareSerial instance bound to UART1.

◆ resultToString()

const char * resultToString ( LD2410Async::AsyncCommandResult result)

Convert AsyncCommandResult enum to human-readable text.

Parameters
resultEnum value from LD2410Async
Returns
const char* String representation

Definition at line 83 of file enableConfigModeTest.ino.

◆ scheduleNextSequence()

void scheduleNextSequence ( )

Schedule the next test sequence.

Waits a random time between 1–5000 ms before calling enableConfigModeAsync().

Definition at line 102 of file enableConfigModeTest.ino.

◆ setup()

void setup ( )

Arduino setup function.

Initializes Serial, the radar UART, and the LD2410Async library. Starts the first test sequence by calling scheduleNextSequence().

Definition at line 267 of file enableConfigModeTest.ino.

Variable Documentation

◆ dataCount

unsigned long dataCount = 0

Used to count received data frames.

Definition at line 52 of file enableConfigModeTest.ino.

◆ delayMs

unsigned long delayMs = 0

Delay before the tests.

Definition at line 51 of file enableConfigModeTest.ino.

◆ delayTicker

Ticker delayTicker

Ticker for randomized delays.

Definition at line 39 of file enableConfigModeTest.ino.

◆ enableStartMs

unsigned long enableStartMs = 0

Timestamp when enableConfigModeAsync() was called.

Definition at line 45 of file enableConfigModeTest.ino.

◆ failureCount

unsigned long failureCount = 0

Number of failed measurements.

Definition at line 50 of file enableConfigModeTest.ino.

◆ ld2410

LD2410Async driver instance.

◆ maxEnableDurationMs

unsigned long maxEnableDurationMs = 0

Maximum execution time measured so far.

Definition at line 47 of file enableConfigModeTest.ino.

◆ measurementCount

unsigned long measurementCount = 0

Number of successful measurements.

Definition at line 49 of file enableConfigModeTest.ino.

◆ minEnableDurationMs

unsigned long minEnableDurationMs = ULONG_MAX

Minimum execution time measured so far.

Definition at line 46 of file enableConfigModeTest.ino.

◆ totalEnableDurationMs

unsigned long totalEnableDurationMs = 0

Sum of all measured durations.

Definition at line 48 of file enableConfigModeTest.ino.