Electronics Sensors "/>

Testing presence / occupancy sensors

12 September 2023 at 2:51 pm

Article image for Testing presence / occupancy sensors

For many years I’ve made museum and event installations where I need to detect the presence of a human. There’s lots of caveats to the sensors I currently use, so I’ve been looking into radar based sensors recently and these are my findings.

If nobody is present, you’ll usually want some kind of “Attract Mode”, just like one a Las Vegas gambling machine. You show something to draw the user in - something like a teaser trailer for a movie. Once you know that you have their attention, you can then show the full content.

Once someone is present, you want to know when they’re leaving so you can stop the experience. You don’t want to spend energy or add unnecessary sound/light pollution to the overall exhibit when nobody is around. There are several ways to do this, but for an upcoming project I want to test using Radar detection.

Detecting motion vs detecting presence/occupancy

Detecting if someone entered a room is really easy. You’ll just use a cheap PIR sensor - for instance to turn on/off the light in a room. Most have experienced the drawback of these sensors. Every time I go into my garage, the light turns on for 10 seconds, but if I don’t move, the lights will turn off. If you are using the sensor to show an exciting video, it is extremely likely that the user will be standing still. This makes PIR sensors very unsuitable.

Why radar?

The main problem with using a PIR sensor is that it will not detect the presence of a person. It will detect a movement, but only major movement. It will not detect a person standing still. This means that it’s great for turning on/off the light in a room - but not in the living room - where you might sit still enjoying a movie or book. Those movements are too small to register with PIR.

You can of course use light based sensors (like a GP2Y0A21YK0F from Sharp) or ultrasound, but these require something sticking out or a window that could easily be damaged by nefarious visitors. The IR light based sensors are also affected by daylight hitting the lenses and since they require quite a bit of energy, you’ll easily get a buzzing sound on any nearby audio device from the energy pulses. Ultrasound is quite sturdy and you can find automotive versions that have pretty good protection. These are what is used as edge detectors for cars. They are quite directional, but that’s their only main drawback. In my case, it is a major drawback and the only way around this was to put a load cell in the floor. That will perfectly detect occupancy/presence, but it puts some special requirements on the construction of your project.

So to find an “ultimate” solution, I’ve ordered a lot of different radar based sensors that claim to be able to measure occupancy. As always - the chinese vendor descriptions were quite vague and misleading, but some of the worked quite well!

Cheap vs expensive sensors

For my project, reliability is more important than price. There is however no reason to spend more money than required, so I won’t just go for the most expensive option right away. I also want to take this opportunity to learn as much as possible and to share my findings.

This is the list of sensors I’m testing:

Module name

Vendor

Price

INS-3330

InnoSenT GmbH

$42

HLK-LD2410 B/C

Hilink Electronics

$3

HLK-LD2420

Hilink Electronics

$4

HLK-LD2411S

Hilink Electronics

$5

HLK-LD1115H

Hilink Electronics

$3

HB100 module only

unknown

$3

HB100 on PCB

unknown

$6

HFS-DC06

unknown

$3

RCWL-0516

unknown

$0.35

Rd-01

AI Thinker

$6

Some common things

I’ve not looked at turnkey solutions, but rather radar sensors that will let me control things using microcontrollers such as Arduino, STM32 or ESP32-based boards.Sensors like these do vary a lot. What you should look for is Millimeter Wave Radar to get good results. The best of these can detect a human standing still by looking for tiny, tiny movements.

Some things are common for all the devices. They can all see through organic materials. You could place the sensor behind a wooden or plaster wall and they’d still see right through. Range is also quite extensive. Most can detect something like from 10cm to 10 meters. They become less precise the longer away you go. To detect micro-movements, you’ll often have to be 2-3 meters or closer to the sensor.

Blocking signals with a small faraday cage does affect directionality, but also signal quality. Many of the radars tested do not like being put close to a copper or aluminium foil at all.

HFS-DC06

Very sensitive. Minimum distance 3m/9feet. Does not measure occupancy if you stand still, so not much better than a PIR sensor. More details here.

+ Adjustable time and sensitivity

+ Good price

+ Precise distance

- Cannot detect presence

- Only works across large areas

HLK-LD1115H

Simple sensor that continuously sends out data on occupancy/movement (example output: “occ, 3 663” at 115200 baud), but the data seem inconsistent? I cannot get the same data by moving my hand in the same place. Makes it kind of worthless. Seems more like a multi-array PIR than a radar.

+ Good price

+ Continous Serial output

- Not precise

HLK-LD2410C & HLK-LD2410B

A small but very impressive sensor. I got it up and running right away using this library. Seems like a fresh, but solid library with an MIT license. Minimum distance is about 10cm.

The LD2410B has a wider form factor than the LD2410C. According to the website this form factor does not affect the signal in any way. The main difference seems to be that LD2410B has 1.27” pitch on it’s headers instead of 2.54” of the LD2410C. LD2410C seems to give more accurate readings for my use case, but both may be worth testing out.

Hi-Link also offers the HLK-2420 but I could not find a suitable library for this. It is however supported in ESP-home, so for that usage it’ll reportedly work fine. Apparently, this sensor also offers BLE/Bluetooth connection but I’ve not been able to test that.

+ Good price

+ Serial protocol, so easy to use

+ Good Arduino library exist

- Somewhat directional

HLK-LD2411S

This is a multi-element sensor that outputs a custom, undocumented protocol. It’s not that hard to decipher though. The output is always 7 bytes (Example: 0 85 85 170 170 2 37) at 256000 baud. The first five bytes are always the same. The sixth byte is either empty (0), movement (1) or occupancy (2). The third is distance (30-255 units). It has a cutoff distance of 12 cm (4.7”) where it’ll output a zero if you’re closer than the cutoff.

You could easily make this into something useful, but the best would be if there was a C/C++ library available. It’s supported in ESP-Home though, so you could use their implementation as a starting point. What they seem to do is just to look for two bytes with 0xAA (170 in decimal, as in example above) and then they set presence & motion based on the second last byte. Quite simple really?

This device is more directional than other HLK devices and might be well suited for detecting occupancy in small rooms. The company provides a Chinese only Windows software that can decode the protocol for testing. This is amusingly similar to the Rd-01 module from AI Thinker that we’ll look at next.

+ Quite directional

+ Good price

- Custom serial protocol

- Requires you make a custom library

Rd-01 radar module

AI Thinker makes pre-certified modules for many markets. Up until now, they’ve primarily focused on making development boards based on chips from Espressif (ESP8266, ESP32) but the last years they’re branching in LoRa and other things. Radar seems fairly new for them and they’ve integrated the chip named S3KM111L from Sidian Micro as the radar device. It is more than just a radar though, so it integrates a wifi & bluetooth chip (BL602) as well. This could make it a very integrated solution if it wasn’t for the fact that it’s extremely underdocumented and AI Thinker want you to flash this using a pre-made binary rather than something custom.

Just like the LD2411S, this is a serial device with a custom protocol communicating at 256000 baud. The protocol outputs more bytes than the HLK module though. It also has a fairly similar looking Chinese only Windows app. Sensing with this module is quite good, but I am able to fool if I stand still. I will have to stand completely still for maybe 10 seconds though, so this will work for many cases. It is also quite directional.

+ Quite directional

+ Good price

- Custom serial protocol. No library.

- Can be fooled if you stand still

RCWL-0516

Seriously bad. Less precise than a normal PIR sensor. Only reacts to big movements. I can drink coffee in front of it without triggering, but if I stand up it will notice. Does not measure occupancy. More info here but I can confirm it’s really bad.

+ Crazy good price

- Not directional at all

- No adjustment

- Not precise

- Cannot detect presence

INS-3330

Looking at the large resellers such as Digikey & Mouser, there’s quite a lot of occupancy sensors. After some reading of datasheets, I decided to test this one from InnosenT GMBH. At $42 per unit (down to $30 in volume) it’s not a very cheap solution.

It has more than 2 antenna elements and based on my experience, this indicates that it’s a Doppler device. Sure enough. Once you solder it up, it can detect not only movement, but also if a user is moving towards or away from the device. It even has indicator lights that make it a breeze to set up. As opposed to Chinese vendors, you’ll find a very solid datasheet, so going into production with this item would be super easy, right? Well, if you could only find the documentation for the serial protocol it outputs?

For some incomprehensible reason, you cannot find this information on the InnosenT website. The only information you can find is the datasheet that indicates that the data is sent at 38400 baud. There is no description of the data, so anyone buying this product will be just as puzzled as I was. After a lot of searching online, I found that this project has used the device. In this paper, they show how the data is built up (5 static bytes and then some actual content), but why on earth do I have to find that in a research paper?

Why do they make it so hard to get information on a custom protocol? Many vendors do this and it’s costing them lots of customers. It is not a sign of quality and it makes it much harder than it needs to be to use their hardware. After further testing, it seems that this sensor is incapable of differentiating between a human standing still and nothing happening, so I stopped my testing. Very promising and then very disappointing is my verdict on this sensor.

+ Somewhat directional

- Very expensive for what it does

- Cannot detect presence, only motion (with direction)

- Custom serial protocol. No library.

MH-ET LIVE & CDM324 (also sold as HB 100)

These are Doppler sensors emitting a signal that can be used to measure speed. They use radar at similar frequencies as the occupancy sensors I’ve tested here, but they cannot measure occupancy well. Here’s a good writeup on how these work and now to make a speed measuring device using them.

There are more than just these sensors that are sold as HB100 with words like “Microwave Sensor Module”, “Human Body Induction Switch” and “Arduino Wireless Motion Detector”. These are all misleading. It’s rather a Doppler Radar Sensor - a great device for measuring how something moves in relation to something else. These measure big movements.

Most of the other sensors are using the same radar technology to track “micro-movement” and thus occupancy through this. The reason this works is that most humans never stand really still. We all move a little and they use this to sense the presence of something.

Summing up

My conclusion is that the only sensors currently available (Sep 2023) that can reliably detect the presence of a human, are the ones from Hi-Link. For now, I’ll move forward with one of these in my project and I’ll update here if I discover something.

If you have a sensor you think I should test, please send me an email. The same applies if you are from InnosenT (or any other vendor) and want to show me where the researchers found the details on your protocol and how I could use it to detect presence and not just movement.