Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[P159] Add LD2410 Radar presence detection #4852

Merged

Conversation

tonhuisman
Copy link
Contributor

@tonhuisman tonhuisman commented Oct 16, 2023

Resolves #4673

P159 - Presence - LD2410 (24 GHz Radar human presence detector)

Using a beta version of nvmreynolds/ld2410 library, with an open PR included to have Engineering mode, and other experimental patches like the Ambient Light sensor support.

Features:

  • All presence related measurements available from the sensor
  • All Engineering measurements available from the sensor
  • Ambient Light value (undocumented feature in Engineering mode, only available on boards that have the AL sensor)
  • Output pin state (undocumented feature in Engineering mode)
  • Supported commands:
    • ld2410,factoryreset : Reset sensor to factory default settings (no questions asked!)
    • ld2410,logall : Write all available values at INFO log
  • Available values: (usage: [<taskName>#<valueName>]
    • Presence : Presence (0/1)
    • StatPres : Stationary presence (0/1)
    • MovPres : Moving presence (0/1)
    • Distance : Distance in cm
    • StatDist : Stationary distance in cm
    • MovDist : Moving distance in cm
    • StatEnergy : Stationary object energy level
    • MovEnergy : Moving object energy level
    • StatSensGate0..StatSensGate8 : Stationary gate sensitivity value for gate 0..8 (range 0..100)
    • MovSensGate0..MovSensGate8 : Moving gate sensitivity value for gate 0..8 (range 0..100)
    • With 'Engineering mode' enabled:
    • AmbLight : Ambient light level (0..255) (unknown unit)
    • OutputPin : State of the output pin (0/1)
    • StatEnergyGate0..StatEnergyGate8 : Stationary object energy level for gate 0..8, 75 cm/gate
    • MovEnergyGate0..MovEnergyGate8 : Moving object energy for gate 0..8, 75 cm/gate
    • StatSensGate0..StatSensGate8 : Stationary sensitivity setting gate 0..8
    • MovSensGate0..MovSensGate8 : Moving sensitivity setting gate 0..8

TODO:

  • Rework fetching the data to make it respond faster to presence change, independent from Interval
  • Testing
    • LD2410 (confirmed)
    • LD2410B
    • LD2410C (confirmed)
    • Running from ESP8266 😊 (currently tested on ESP32 only)
  • Documentation
  • Add configuration options for fine-tuning the detection settings
  • Enable current configuration settings to be presented in the UI
  • ... and used in rules
  • Add commands:
    • FactoryReset
    • LogAll
  • Update EasyCodeMirror

src/_P159_LD2410.ino Outdated Show resolved Hide resolved
lib/ld2410/src/ld2410.cpp Outdated Show resolved Hide resolved
@iz8mbw
Copy link
Contributor

iz8mbw commented Oct 30, 2023

You can mark "Testing on LD2410C" as completed. Thanks Ton for you job!

@iz8mbw
Copy link
Contributor

iz8mbw commented Nov 14, 2023

@tonhuisman Ton please update also https://github.com/letscontrolit/ESPEasy/blob/mega/src/Custom-sample.h adding this new Plugin

@tonhuisman
Copy link
Contributor Author

@iz8mbw
Copy link
Contributor

iz8mbw commented Nov 14, 2023

Oh sorry, I miss it due to viewing with mobile phone

@iz8mbw
Copy link
Contributor

iz8mbw commented Nov 15, 2023

@tonhuisman as we know we well tested it on LD2410C and LD2410B models.
Here you specify "LD24x0" so I suppose you know the Plugin is software compatible also with LD2420?
And also the newest LD2410S, LD2450, LD2411S and LD2411?
If yes then make sense to rename "Presence - LD2410" to "Presence - LD24x0x" if instead we don't know or we know it's not software compatible we should not specify it as "LD24x0".

@iz8mbw
Copy link
Contributor

iz8mbw commented Nov 15, 2023

On ESPHome it seems they have 2 different implementation between LD2410 and LD2420.

https://esphome.io/components/sensor/ld2410
https://esphome.io/components/sensor/ld2420

@tonhuisman
Copy link
Contributor Author

Here you specify "LD24x0" so I suppose you know the Plugin is software compatible also with LD2420?

Originally I intended to support both the LD2410 and LD2420, but AFAIR, they are not fully very software compatible. Especially the changed baud rate, depending on the firmware revision, sounds troublesome/confusing (for end-users) to me, but also the LD2420 has a lot less data values and configuration options available. Still not sure if I'll implement all these derived models, and I don't expect to do that in this PR, but in follow-up PR's. Similarly, I've already ordered a 60 GHz radar presence sensor, that has even different features, like fall-detection... 😉

I'll have a look at what the differences between the ESPHome implementation implies, maybe it's needed there because of the change in available values, IDK.

@iz8mbw
Copy link
Contributor

iz8mbw commented Nov 15, 2023

OK, I totally agree with you, so if LD2410 and LD2420 are not very software compatible, it's better to leave this new Plugin as is it only for LD2410.
If you can also implement LD2420 it would be interesting.

About the other 60 GHz radar presence sensor, what is it? What chip?

Thanks!

@iz8mbw
Copy link
Contributor

iz8mbw commented Nov 15, 2023

and these new kind of Presence sensor using mmWave are much better than PIR.
mmWave technology is the future on presence detection.

@iz8mbw
Copy link
Contributor

iz8mbw commented Nov 15, 2023

This seems the LD2420 implementation in ESPHome.
See also: esphome/feature-requests#2219

@TD-er TD-er merged commit 98c8fff into letscontrolit:mega Nov 27, 2023
162 checks passed
@tonhuisman tonhuisman deleted the feature/P159-ld2410-presence-detection branch November 27, 2023 16:21
@netson01
Copy link

Where can I get build that supports LD2410?

This test build has expired links.
Releases Nov 30, 2023 and Dec 26, 2023 have no "Presence - LD2410 Radar detection" in the device list.

Tested both releases on ESP8266 and ESP32 (normal_ESP8266_4M1M and normal_ESP32_4M316k).

@tonhuisman
Copy link
Contributor Author

@netson01

Tested both releases on ESP8266 and ESP32 (normal_ESP8266_4M1M and normal_ESP32_4M316k).

On the Plugin overview page you can see that the plugin is included in the Collection G builds. If you install that type of build you will be able to select the LD2410.
It's been available since the November 2023 release.

@starfish1107
Copy link

I noticed considerable data flooding from this plugin to the mqtt broker - how can I reduce it?

@TD-er
Copy link
Member

TD-er commented Jun 10, 2024

You can act on the events sent by the task in the rules.
From there you can try to decimate the traffic, for example only to send if there was no presence for N amount of time.

Sending to MQTT can then be done via the publish command, or you copy the required values from the event to a dummy task and then call taskRun for that dummy task.
For this you should no longer send from the LD2410 task, but only from this dummy task to the MQTT controller.

@TD-er
Copy link
Member

TD-er commented Jun 10, 2024

By the way, it is better not to reply to closed issues or merged pull requests as not a lot of people will read them.
Better open a new issue.
However, this was a good example of some question to ask on the forum.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add Hi-Link HLK-LD2410 mmWave human presence sensor
5 participants