TL;DR
The DFRobot SEN0395 (Leapmmw HS2xx3A series) is a fabulous sensor for triggering lighting. It is quick, highly configurable and has been extremely reliable over many months.
Intro
Having recently stumbled upon rumors of a potentially upcoming Aqara mmWave presence sensor, it got me thinking of the potential.
One of the most useful projects deployed to date using Home Assistant is motion based lighting for under-counter LED strips in the kitchen. So successful in fact, that the SO more often than not, will cook entire meals without touching the overhead light switch.
This however came with workarounds. PIR sensors do not detect when a person is static for a period of time and every sensor tested to date is fooled. Including Hue, Zooz, Ecolink, Sonoff, Aqara, etc…
My SO loves to practice mime skills and fool the motion sensors; mmwave to the rescue!
With my growing confidence in ESPHome, from the EmporiaVue2 and the NSPanel, it seemed like a natural fit. Acquiring a DFRobot SEN0395 (aka Leapmmw) 24Ghz mmWave sensor, and with some basic assembly of a single GPIO and UART using a logic level shifter/converter we were in business.
Finessing components into a cheap ABS project box is a skill only those without a 3D printer will appreciate It works just fine with the plastic cover in place (not shown). The greatest challenge is to come.
While this worked out of the box using a single GPIO, I have to confess that it can be challenging to use as a standalone sensor in high motion environments. It is very sensitive. When they say, “mmwave”, they do mean detection by the millimeter! As a bedroom sensor, it is perfect.
In a high-clutter environment I would sometimes encounter situations where the lights might turn on because the detection range of the mmWave includes reflections. So it will bounce around corners and catch you coming!
Install placement and tuning - take 3
With the enablement of the uart_target_output
switch I have parsed four (4) of the eight (8) possible targets. These are viewable on the internal webserver since they are very noisy. This opens up new possibilities in both tuning and automations.
** WARNING ** leaving a browser sitting open on the ESP web_server with all 16 target (dist/SNR) updating realtime may cause your ESP to reboot after a few minutes. Please use the web_server for tuning purposes only. Since the target distand/SNR are internal, Home Assistant will be fine.
num_targets
however is not internal. You may wish to set it that way or exclude it from logger;
HA configuration.yaml:
logbook:
exclude:
entity_globs:
- sensor.num_targets*
Tuning by SNR
Traditional tuning procedures require moving to a location where the binary_sensor
turns off to determine the “end of detection range/angle” for a particular deployment. The problem with this approach is that “edges are fuzzy” and the latency setting impacts whether or not a sensor will report no detection.
By Using the target SNR you can now better understand the impact of different sensor placement/orientation by observing changes to the SNR (<1 is weak detection, the higher the better).
You can now predict when the sensor will report indicate “no presence” by the fact that the last target goes below 0 SNR then disappears. At this point, increasing latency may increase the potential detection range since the target may “flap” and be detected and dropped again within that time period.
Tuning by distance
Since you can now observe target distance, this aids immensely in the configuration of max target distance
. Being able to review what the sensor sees will help dispel any assumption of detection range. This is especially true since I made the assumption that a simple measuring tape would suffice in setting distance. When in fact, the sensor doesn’t report the very edge of the target, but sometimes reflections or “deeper” into a target.
It has also transformed certain lighting scenarios where placement was forced to point towards hallways and may trigger on someone who may passersby. You no longer have to measure or guess what the sensor detects and how far it measures. You assumed it was pinpoint accurate didn’t you It measures in 15cm increments and that means even +/- 1 increment isn’t pinpoint
This approach lets me leave the bathroom door open and the light no longer turns on when someone walks by when using the Hue PIR.
A note about distance: do not assume the mmwave signal will “go-through”, “bounce off” or “be stopped by” walls. Construction materials vary. And while the signals may “bounce off” my walls (around corners) the behavior may be different in your setting.
New Automation Opportunities?
By combining certain SNR & distance scenarios it may be possible to include/exclude combinations. Much testing is needed here and feedback welcome. I will be observing if I can differentiate small pets versus humans based on certain distance/SNR ratios.
Installation
Thanks to @hjmcnew for the new installation approach that greatly simplifies deployment.
Please see https://github.com/hjmcnew/esphome-hs2xx3a-custom-component/tree/release for both options.
Install Option 2:
- Download the leapmmw_sensor.h file into your esphome configuration directory
- Include the following in the YAML configuration for your ESP board:
substitutions:
device_name: leapmmw
# This will vary based on your board
uart_tx_pin: TX
# This will vary based on your board
uart_rx_pin: RX
# This will vary based on your board
gpio_pin: D0
# (Optional) Path to the leapmmw_sensor.h file relative to your esphome configuration directory.
header_file: leapmmw_sensor.h
packages:
remote_package:
url: https://github.com/hjmcnew/esphome-hs2xx3a-custom-component
ref: release
file: packages/leapmmw_sensor.yml
Conclusion
I don’t think we are at the end quite yet…
Bored? See my other projects below or wait for the upcoming “mmWave wars!” Hi-Link vs Leapmmw vs SeeedStudio where we attempt to quantify detection ranges for nano-motion (sleep), micro-motion (sitting), and motion (standing/walking). Because I know you all read the max range and think to deploy the sensor 9 meters away for sleep monitoring
FAQ
- Will
num_target
count the number of people in a room? - No! It counts sources of movement at a smaller level. And a person has many potential movement sources (head, torso, hands, feet) that may be counted as individual targets. - Will my fan, cat, HVAC blown drapes get detected? - Yes.
- The [INSERT SETTING HERE] doesn’t work! - check your UART wiring.
Changelog:
[edit] - with help from @phillip1 there is now a greatly simplified tuning process directly from within HA. Thanks Phillip!
[edit] - updated yaml 5/20/22
[edit] - new features! 6/13/2022
- hidden sensitivity feature unlocked
- LED control
- UART output control
[edit] - new target detection features! 7/26/2022
- add target parsing and target sensors
- add query buttons (no parsing at this time)
[edit] - lamba code cleanup by @phillip1 7/27/2022
- I make spaghetti, he brings the meatballs…
- all eight targets exposed to web_server
[edit] - want to find the limits of an ESP32? We’ve found them. 8/1/2022
- reduced targets and tracking output interval as >4 overload an ESP32 web_server
[edit] - parameter synchronization code added 8/10/2022
[edit] - a new install process! 8/11/2022
- a big thank you to @hjmcnew for packaging up the sprawling configuration into a remote_package
My mmWave Projects
Tracking Radar
mmWave Presence Detection
Low-Latency DFRobot+PIR
mmWave Wars: one sensor (module) to rule them all
Where to buy
Look at Mouser / Digikey for local availability.
This seller has been responsive on Ali and has been able to source all three Leapmmw variants