Presence - LD2410

LD2410 24 GHz Radar human presence detection sensor

Plugin details

Type: Presence

Name: LD2410

Status ESP32: COLLECTION G

Status ESP8266: COLLECTION G

GitHub: P159_LD2410.ino

Maintainer: tonhuisman

Used libraries: ncmreynolds/ld2410, with ‘skoona’ and ESPEasy specific enhancements

Description

Detecting (human) presence can be achieved in several ways, like via IR detection sensors, or a light-beam that’s interrupted by someone passing. But these sensors have quite some limitations, like limited sensitivity, no information about the distance, or weather a person is there but not moving.

The limitations of these existing sensors are not applicable when using radar-based presence detection, and since some time, rather affordable radar human-presence detectors are available. These are available with 5 GHz, 10 GHz, 24 GHz and 60 GHz radar frequency transmitter/receiver chips. Because of the accuracy and range, achievable with 24 GHz sensors, these are quite popular, so support has been added to ESPEasy. Some notes about “false positive” detections: based on our test and experience some false positive presence detections can happens. For example if the sensor is near to plant, the movement of leaves can be incorrectly translated as presence detection; also electric cables in front of the sensor can provide noise to the sensor. To avoid false positive presence detection try to leave the sensor as free from obstacles as possible.

Some examples of these sensors:

LD2410b with bluetooth support, 35 x 7 mm in size

LD2410b with bluetooth support, 35 x 7 mm in size

LD2410c, 22 x 15 mm in size

LD2410c, 22 x 15 mm in size

(Images are sourced from AliExpress vendors)

Configuration

../_images/P159_DeviceConfiguration.png
  • Name: Required by ESPEasy, must be unique among the list of available devices/tasks.

  • Enabled: The device can be disabled or enabled. When not enabled the device should not use any resources.

Sensor

See: Serial Helper configuration

For this sensor, only the Serial port, and for ESP32 or Software Serial, the GPIO selection options are available.

Warning

The SWSerial option should better not be used, because of the high speed (256000 baud) that is used for the serial connection!

Device Settings

  • Engineering mode: With this option set Yes, when changed the settings will be saved and the page reloaded, several extra Values are made available for selection. When not using the extra values available, Engineering mode should best be set to No to lower the system-load.

../_images/P159_EngineeringMode.png
  • Available options: Yes or No (the default).

  • Generate Events only when changed: Checking this option prevents sending an event if none of the values has changed on the next Interval.

Output Configuration

  • Number Output Values: Select the number of values that should be available. Default set to Quad (4).

../_images/P159_NumberOutputValues.png
  • Select from Single (1) to Quad (4).

After submitting the page, the number of Values will be changed to the selected number.

  • Value 1 .. Value 4: For each Value the desired data can be configured, depending on the setting for Engineering mode, the available options are adjusted.

  • Engineering mode = No:

../_images/P159_ValueOptionsStandard.png
  • Engineering mode = Yes:

../_images/P159_ValueOptionsEngineering1.png ../_images/P159_ValueOptionsEngineering2.png

Available options:

  • Presence: 0 = No presence, 1 = Presence detected

  • Stationairy presence: 0 = No stationary presence, 1 = Stationary presence detected (Stationairy = non-moving person)

  • Moving presence: 0 = No moving presence, 1 = Moving presence detected

  • Object distance: Distance of the detected presence, in cm.

  • Stationary Object distance: Distance of the detected stationary presence, in cm.

  • Moving Object distance: Distance of the detected moving presence, in cm.

  • Stationary Object energy: Energy level of the detected stationary presence, undefined unit, range 0..100.

  • Moving Object energy: Energy level of the detected moving presence, undefined unit, range 0..100.

Engineering mode enabled:

  • Ambient light sensor: If the unit includes an ambient light sensor, and many do, then this will hold the light level, undefined unit, range 0..255. This is an undocumented setting from the device, only usable on boards that have this sensor installed.

  • Output pin state: This reflects the Out pin, available on most boards. This is an undocumented setting from the device.

  • Stationary Object energy gate 0..8: 9 selections of the Stationary Object energy level for each ‘gate’ (the concept of gates is explained below)

  • Moving Object energy gate 0..8: 9 selections of the Moving Object energy level for each ‘gate’

Sensitivity settings

Once the task is enabled, and a sensor is connected, extra configuration settings are available, that are disabled by default, and show the current configuration, as read from the sensor. To change any of these settings, the Modify sensor settings checkbox must be enabled, and the input fields will be enabled. The settings available are for configuring the idle time, number of active gates and sensitivity per gate.

A gate is an area in view of the sensor. Each gate is aproximately 75 cm distance (sequentially) from the sensor, and the highest active gate-number, default set to the max. value, is 8 (number starts at 0, so there are 9 gates). These active gates can be configured separately for detecting Moving and Stationary objects/persons. The lowest gate-number that can be selected is 2.

../_images/P159_SensitivitySettings.png

By default, the Modify sensor settings checkbox is unchecked.

After checking the checkbox to enabled state, the settings will be available immediately:

../_images/P159_SensitivitySettingsEnabled.png
  • Firmware version: The version of the firmware installed on the sensor. The version shown in the screenshots is only shown as informational, and not a required value. For the Bluetooth enabled LD2410b sensor, updates for the firmware, when available, can be installed by using the LD2410 Mobile phone app. This firmware update feature is not available from ESPEasy.

  • Modify sensor settings: Enable the checkbox to change the sensitivity settings, and store these in the sensor when the page is Submitted.

  • Idle seconds: The number of seconds the Presence stays active after presence is removed, can be set here. Default value 5 sec. max. value is 65535 sec.

  • Max. Moving gates: The number of active gates for detecting Moving presence. Range 2 .. 8.

  • Max. Stationary gates: The number of active gates for detecting Stationary presence. Range 2 .. 8.

  • Sensitivity, Gate 0 .. 8: For each type of detection, the sensitivity treshold can be set, range 0 .. 101, where 0 is the most sensitive, and 101 means it won’t trigger, as 100 is the max. value that will be reported.

For each gate the distance range in meters is also shown. When the highest enabled Gate is less than the default 8, then only up to that gate-number is shown and configurable.

If the Modify sensor settings checkbox is checked when submitting the page, the settings are sent to the sensor, and the sensor will be restarted to activate them. The configured values are persistently stored in the LD2410 sensor.

Might the configuration not be set correctly, and changing them again doesn’t seem to work, then resetting the sensor, by issuing the ld2410,factoryreset command while the task is enabled and the sensor connected, the factory defaults will be restored. (See the list of supported commands, below.)

Data Acquisition

This group of settings are standard available configuration items.

  • Single event with all values: When this setting is enabled, all available values will be sent in a single event <TaskName>#All, with all values in order as arguments to the event.

  • Show derived values: When checked, the Devices overview page, and the /json endpoint (used for updating the Devices overview page) will include any Derived values as defined. See the TaskValueSetDerived and TaskValueSetPresentation commands.

  • Event & Log derived values: When checked, the Derived values will be generated as Events, to be handled in Rules, and sent to logging devices like the Syslog server and/or SD-card logging.

(The derived values options are only available if String variables feature is included in the build.)


  • Send to Controller: Select the Controller(s) to send the Values to, either on a TaskRun command applied to the task, or on an Interval time action.

Send to Controller is only visible when one or more Controllers are configured.

Depending on the controller capabilities, some configuration settings may be shown:

../_images/Task_config_page_Controllers_section.png

All configured Controllers are shown here, including the enabled or disabled state (multiple Controllers can be enabled, only a single MQTT Controller can be enabled at one time!).

For each controller the user can select wether the data should be sent on each Interval (or explicit TaskRun).

For the Domoticz controllers the value index (IDX) has to be configured.

For some controllers, like Home Assistant/openHAB, there are extra options available.

  • Group: This represents the group id to combine all values from multiple tasks into a single grouped-device during MQTT AutoDiscovery. Groups, by design, can span multiple ESPEasy devices, if desired, as long as the Task/Valuename combinations are unique. If a group should only combine Tasks from a single ESPEasy unit, the group id should be unique across multiple ESPEasy units. The group description, default Group <n>, can be adjusted in Home Assistant. If the Group value matches the current Unit nr, the Unit name, %sysname%, is used instead of Group <nr>.

  • Retained: For MQTT Controllers, this setting can be enabled to send the values for the current task with the Retain flag set. The Publish Retain flag in the Controller settings will override this by sending all task values with Retain flag enabled.

  • Send derived: This checkbox determines if any configured Derived values should also be sent to the controller (and included in the AutoDiscovery if that’s available and enabled).

  • Resend MQTT Discovery: When checked, will start a resend of the MQTT Discovery process for this task after a random delay, when Submit is clicked, so any changed settings will be updated in the MQTT broker. This setting is only available if the controller is enabled, the Auto Discovery feature is available and enabled for the controller. This setting is not stored.

Other controllers, like f.e. FHEM HTTP, do not support additional settings besides the checkbox to enable sending the data.


  • Interval By default, Interval will be set to 0 sec. as this is optional for this device. The data will be collected and optionally sent to any configured controllers using this interval. For sending the values to the enabled controller(s), the command TaskRun,<taskName|taskNr> can be used.

Values

The plugin provides user configurable values, where the names will be changed according to the selected sensor value. A formula can be set to recalculate. The number of decimals can be set as desired, and defaults to 0.

In selected builds, per Value is a Stats checkbox available, that when checked, gathers the data and presents recent data in a graph, as described here: Task Value Statistics:

Commands available

Command Syntax

Extra information

ld2410,factoryreset

Sending this command to the task and a sensor is connected, then the sensor will be reset to the factory default settings, and restarted. There are no questions asked or extra arguments to provide. Use with caution of you have carefully configured, f.e. the sensitivity settings.

ld2410,logall

This command will send all available sensor values (see below) to the log at INFO level. This can be viewed via an USB serial connection, when the Serial console is enabled, or via another log view, like the Tools/Log page. The minimum log level has to be set to INFO for the values to be shown.

Get Config Values

Get Config Values retrieves values or settings from the sensor or plugin, and can be used in Rules, Display plugins, Formula’s etc. The square brackets are part of the variable. Replace <taskname> by the Name of the task.

Config value

Information

[<taskname>#Presence]

Returns the currently reported Presence state, 0 (no presence) or 1 (presence detected)

[<taskname>#StatPres]

Returns the currently reported Stationary Presence state, 0 (no presence) or 1 (presence detected)

[<taskname>#MovPres]

Returns the currently reported Moving Presence state, 0 (no presence) or 1 (presence detected)

[<taskname>#Distance]

Returns the distance of the detected object from the sensor, in cm.

[<taskname>#StatDist]

Returns the distance of the detected Stationary object from the sensor, in cm.

[<taskname>#MovDist]

Returns the distance of the detected Moving object from the sensor, in cm.

[<taskname>#StatEnergy]

Returns the energy level of the detected Stationary object from the sensor, unknown unit, range 0..100.

[<taskname>#MovEnergy]

Returns the energy level of the detected Moving object from the sensor, unknown unit, range 0..100.

[<taskname>#AmbLight]

Returns the level of the ambient light, when available, unknown unit, range 0..255.

[<taskname>#OutputPin]

Returns the currently reported Output pin state, 0 (no presence) or 1 (presence detected)

[<taskname>#StatEnergyGate0..8]

Returns the energy level of the Stationary object per gate 0..8, unknown unit, value range 0..100.

[<taskname>#MovEnergyGate0..8]

Returns the energy level of the Moving object per gate 0..8, unknown unit, value range 0..100.

[<taskname>#StatSensGate0..8]

Returns the configured sensitivity level of the Stationary object per gate 0..8, unknown unit, value range 0..100.

[<taskname>#MovSensGate0..8]

Returns the configured sensitivity level of the Moving object per gate 0..8, unknown unit, value range 0..100.

Change log

Changed in version 2.0:

added 2023-11-13 Initial release version.