17#define LD2410_BAUD_RATE 256000
18#define LD2410_BUFFER_SIZE 0x40
19#define LD2410_LATEST_FIRMWARE "2.44"
28 LIGHT_BELOW_THRESHOLD,
76 for (
byte i = 0; i <= N; i++)
77 values[i] = other.values[i];
81 template <
typename ByteHandler>
82 void forEach(ByteHandler func)
const
84 for (
byte i = 0; i <= N; i++)
91 unsigned long timestamp;
92 unsigned long mTargetDistance;
94 unsigned long sTargetDistance;
96 unsigned long distance;
107 byte noOne_window = 0;
110 byte lightThreshold = 0;
114 unsigned long version = 0;
115 unsigned long bufferSize = 0;
118 String firmware =
"";
119 byte firmwareMajor = 0;
120 byte firmwareMinor = 0;
122 bool isEnhanced =
false;
123 bool isConfig =
false;
124 unsigned long timeout = 2000;
125 unsigned long dataLifespan = 500;
126 byte inBuf[LD2410_BUFFER_SIZE];
134 bool sendCommand(
const byte *command);
145 MyLD2410(Stream &serial,
bool debug =
false);
476 bool setGateParameters(
byte gate,
byte movingThreshold,
byte stationaryThreshold);
515 bool setMaxGate(
byte movingGate,
byte stationaryGate,
byte noOneWindow = 5);
OutputControl
The auxiliary output control status.
Definition MyLD2410.h:36
AutoStatus
The status of the auto-thresholds routine.
Definition MyLD2410.h:46
LightControl
The auxiliary light control status.
Definition MyLD2410.h:25
byte getLightLevel()
Get the Light Level.
Definition MyLD2410.cpp:768
bool inEnhancedMode()
Check whether the device is in enhanced mode (continuously sends enhanced presence data)
Definition MyLD2410.cpp:317
bool setMovingThreshold(byte gate, byte movingThreshold)
Set the moving target threshold for a particular gate.
Definition MyLD2410.cpp:576
bool requestParameters()
Request the sensor parameters: range, motion thresholds, stationary thresholds, no-one window.
Definition MyLD2410.cpp:545
byte getLightThreshold()
Get the Light Threshold.
Definition MyLD2410.cpp:780
byte getMaxMovingGate()
Get the maximum moving gate.
Definition MyLD2410.cpp:667
bool requestReboot()
Request reboot.
Definition MyLD2410.cpp:688
byte getFirmwareMajor()
Get the Firmware Major.
Definition MyLD2410.cpp:408
bool requestFirmware()
Request the Firmware.
Definition MyLD2410.cpp:524
bool enhancedMode(bool enable=true)
Request enhanced mode.
Definition MyLD2410.cpp:479
bool setMaxMovingGate(byte movingGate)
Set the maximum moving gate.
Definition MyLD2410.cpp:641
bool setMaxStationaryGate(byte stationaryGate)
Set the maximum stationary gate.
Definition MyLD2410.cpp:654
bool autoThresholds(byte _timeout=10)
Begin the automatic threshold detection routine (firmware >= 2.44)
Definition MyLD2410.cpp:494
bool configMode(bool enable=true)
Request config mode.
Definition MyLD2410.cpp:470
void debugOn()
Set the debug flag.
Definition MyLD2410.cpp:297
Response check()
Call this function in the main loop.
Definition MyLD2410.cpp:73
bool requestResolution()
Request the resolution (gate-width)
Definition MyLD2410.cpp:531
bool inBasicMode()
Check whether the device is in basic mode (continuously sends basic presence data)
Definition MyLD2410.cpp:312
bool requestAuxConfig()
Request the current auxiliary configuration.
Definition MyLD2410.cpp:487
byte getStatus()
Get the status of the sensor: 0 - No presence; 1 - Moving only; 2 - Stationary only; 3 - Both moving ...
Definition MyLD2410.cpp:322
bool setAuxControl(LightControl light_control, byte light_threshold, OutputControl output_control)
Set the Auxiliary Control parameters.
Definition MyLD2410.cpp:794
bool setGateParameters(byte gate, byte movingThreshold, byte stationaryThreshold)
Set the gate parameters for a particular gate, or for all gates at once.
Definition MyLD2410.cpp:552
MyLD2410(Stream &serial, bool debug=false)
Construct a new MyLD2410 object.
Definition MyLD2410.cpp:266
String getMACstr()
Get the Bluetooth MAC address as a String.
Definition MyLD2410.cpp:394
bool setBaud(byte baud)
Reset the serial baud rate. The sensor reboots at the new rate on success.
Definition MyLD2410.cpp:739
bool requestReset()
Request reset to factory default parameters.
Definition MyLD2410.cpp:681
bool setMaxGate(byte movingGate, byte stationaryGate, byte noOneWindow=5)
Set the detection range for moving targets, stationary targets, as well as the no-one window.
Definition MyLD2410.cpp:594
unsigned long getRange_cm()
Get the maximum detection range in [cm].
Definition MyLD2410.cpp:458
AutoStatus getAutoStatus()
Get the status of the automatic threshold detection routine (firmware >= 2.44)
Definition MyLD2410.cpp:505
byte stationaryTargetSignal()
Get the signal from the stationary target.
Definition MyLD2410.cpp:352
void debugOff()
Reset the debug flag.
Definition MyLD2410.cpp:302
const ValuesArray & getStationarySignals()
Get the Stationary Signals object, if in enhanced mode.
Definition MyLD2410.cpp:357
byte getMaxStationaryGate()
Get the maximum stationary gate.
Definition MyLD2410.cpp:674
byte getRange()
Get the maximum detection gate.
Definition MyLD2410.cpp:451
bool begin()
Call this function in setup() to ascertain whether the device is responding.
Definition MyLD2410.cpp:272
bool setBTpassword(const char *passwd)
Set a new BT password.
Definition MyLD2410.cpp:709
bool setResolution(bool fine=false)
Set the resolution of the sensor.
Definition MyLD2410.cpp:538
bool setStationaryThreshold(byte gate, byte stationaryThreshold)
Set the stationary target threshold for a particular gate.
Definition MyLD2410.cpp:585
bool presenceDetected()
Check whether presence was detected in the latest frame.
Definition MyLD2410.cpp:337
bool requestBTon()
Turn Bluetooth ON.
Definition MyLD2410.cpp:695
unsigned long detectedDistance()
Get the detected distance.
Definition MyLD2410.cpp:382
byte getResolution()
Get the sensor resolution (gate-width) in [cm].
Definition MyLD2410.cpp:751
byte getOutLevel()
Get the Light Level.
Definition MyLD2410.cpp:816
LightControl getLightControl()
Get the Light Control parameter.
Definition MyLD2410.cpp:773
bool resetBTpassword()
Reset the BT password.
Definition MyLD2410.cpp:732
const ValuesArray & getMovingSignals()
Get the Moving Signals object, if in enhanced mode.
Definition MyLD2410.cpp:377
bool resetAuxControl()
Reset the Auxiliary Control parameters to their default values.
Definition MyLD2410.cpp:809
byte movingTargetSignal()
Get the signal from the moving target.
Definition MyLD2410.cpp:372
const SensorData & getSensorData()
Get the SensorData object.
Definition MyLD2410.cpp:432
unsigned long stationaryTargetDistance()
Get the distance to the stationary target in [cm].
Definition MyLD2410.cpp:347
bool requestBToff()
Turn Bluetooth OFF.
Definition MyLD2410.cpp:702
bool movingTargetDetected()
Check whether a moving target was detected in the latest frame.
Definition MyLD2410.cpp:362
byte getFirmwareMinor()
Get the Firmware Minor.
Definition MyLD2410.cpp:415
OutputControl getOutputControl()
Get the Output Control parameter.
Definition MyLD2410.cpp:787
void end()
Call this function to gracefully close the sensor. Useful for entering sleep mode.
Definition MyLD2410.cpp:291
const byte * getMAC()
Get the Bluetooth MAC address as an array byte[6].
Definition MyLD2410.cpp:387
bool requestMAC()
Request the Bluetooth MAC address.
Definition MyLD2410.cpp:517
bool inConfigMode()
Check whether the device is in config mode (accepts commands)
Definition MyLD2410.cpp:307
String getFirmware()
Get the Firmware as a String.
Definition MyLD2410.cpp:401
bool stationaryTargetDetected()
Check whether a stationary target was detected in the latest frame.
Definition MyLD2410.cpp:342
unsigned long getVersion()
Get the protocol version.
Definition MyLD2410.cpp:422
byte getNoOneWindow()
Get the time-lag of "no presence" in [s]. The sensor begins reporting "no presence" only after no mot...
Definition MyLD2410.cpp:463
const ValuesArray & getStationaryThresholds()
Get the detection thresholds for stationary targets.
Definition MyLD2410.cpp:444
bool setNoOneWindow(byte noOneWindow)
Set the no-one window parameter.
Definition MyLD2410.cpp:632
const char * statusString()
Get the presence status as a c-string.
Definition MyLD2410.cpp:327
const ValuesArray & getMovingThresholds()
Get the detection thresholds for moving targets.
Definition MyLD2410.cpp:437
unsigned long movingTargetDistance()
Get the distance to the moving target in [cm].
Definition MyLD2410.cpp:367