The hunt for the best room occupancy solution

Intro
Hello, I am a fellow home assistant user looking for a fast and reliable way to detect if a person entered, a person left and how many people are in the room. Room occupancy seems like a vital piece of information for doing some nice home automation and to efficiently optimize certain tasks like heating and cooling. In my research, there are many ways that people creatively proposed solutions to this problem. One of the rules in home automation that I learned is that if you have to do and extra action everytime to solve a problem, there is no gain out of that solution. Using BLE methods is not ideal because you have to carry things and my family don’t were smart watches either. I have also read somewhere about using logic to decide whether there is a person or not. Ex. a person walks in, motion sensor detects motion, turns on light, person sits down on computer, motion sensor doesn’t sense motion but doesn’t turn off light because computer is pulling power. This is a nice idea if you solely want to control the lights. If you want to for example turn off the computer when no one is in the room this solution would not know the difference. This leads me to asking you about what is your room occupancy solution.

Some Ideas I have
My first idea was, since indoor cameras are really cheap because of wyze cameras, why not pair that up with Doods (an object detection service) and detect people. I have tried that for my bedroom and it works 80% of the time. I have it setup so it runs a scan every minute to check if people are present and if no it doesn’t see a person for 5 consecutive times the room is not occupied. It also runs a scan when there is motion detected by motioneye. The problem rose when I went to bed. Since I, like most people wear a blanket when going to sleep the camera can’t see my body or my face, so it just sets the room unoccupied even though it is. A simple solution to this can be placing a sensor underneath the bed to detect if someone is on it or not. I didn’t really want to put more sensors in the system (mostly because I am too lazy :laughing:) so I just abandoned it but it is definatly viable.
BTW if you are interested, I was using a rpi 4 and doods with the tensorflow detector as it was more accurate. it used up about 10% of the processor for 1 scan per camera and 20% for motioneye (about 30% for 2 cameras).

Another thing that came to mind but I haven’t tried is to use motion sensors. Now I know what you are thinking but hear me out. We divide our house into rooms by walls and use doors to go in and out of the room. If we put a motion sensor on the ceiling on each side of the door and use simple timers to see if the person left the room or entered the room. For example if motion sensor 1 detects motion then following that motion 2 detects motion we can see the direction of the movement. Using that information we can see how many people are in the room. While writing I also realized we can use the sensors that automatic door openers use in malls and stores. A thing that might throw the system off is that if person 1 enters, person 2 enters and both people leave the room at the same time which will leave the room empty but it will think that one person is in the room. So it will definitely need a sensor with a really thin line of sight to overcome this.

If you have more ideas about room occupancy. I would really love to see your thoughts and ideas about this.
Thank you.

Seen this: https://www.room-assistant.io/?

edit: I am not actively using it as I find it (still) hard to get.

That does look like a nice solution but then again not many people (like to) carry things around. The thermopile option does look intriguing though. Thanks

I was wondering if instead of using motion sensors we can use esp32 cams on the ceilings and run object detection to detect heads. that way when 2 people pass through the door we can see 2 heads leaving. Or if 1 people leaves and 1 stays at the door we can see 1 head being detected by both cameras and 1 head only being seen by one. I couldn’t think of a way to break the system yet. I am gonna order some esp32 cams to test this out. In the mean time if you guys think of a way that might break the system, go ahead.

Sonic or video(object detection)

These (2) are ultimately best solution.
Unfortunately I will never put cam in house and I not aware of available off the shelf sonic sensor

I will be using a esp32 with a camera since their cheap and good for the job. Because of privacy It’ll be only on the ceiling near the door. There will be 2 to see if the person is entering, leaving or just standing at the door. All in all it will all local so it’s not that bad.

What do you mean by Sonic sensors. Do you mean ultrasonic sensors, if so no I won’t be using ultra sonic sensors as of I do I won’t be able to tell when 2 people leave at the same time which will break the system.

Carbon Dioxide. Humans emit large quantities of it, if you can reliably sense it in every room, you can tell with extreme accuracy if there are people in the room, and in most cases how many. Values need to compensated for ventilation changes.

Combined with wide field thermal imaging (which does not need to be high res), and you will be able to see in realtime exactly where everyone is.

3 Likes

I like the sounds of that!
From a quick Google search it seams the sgp30 seems like a good candidate as it senses both CO2 and VOC which humans both produce so that can give an accurate reading if Hoomans are present

human VOC output is far too low relative to other sources that might be present, but can be used to detect if humans are doing something that produces VOCs, like drinking alcohol or cooking food

1 Like

Hi!

Did you had any luck trying out the ESP32, or CO2 solutions?
really strugling to finding a viable solution myself.

Hello,
The CO2 solution didn’t work as reliably as expected, it had too many false positives. The best way I have found so far is to use the AMG8833 Thermal-array sensor to detect hot spots. I am currently working on a device that can be hung near a door to detect if someone is leaving or entering a room/space. I am just optimizing the algorithm I am using so it’s more reliable. Any other thermal sensor can work but so far I found this one to be the cheapest.

For what it’s worth, I got deeply vested in Room Assistant in an effort to really dial in local presence detection and pulled the plug on it (after purchasing a bunch of Pi Zero’s exclusively for this purpose). The reason was that it was killing the battery on every device that I included in Room Assistant.

As an example, my Apple Watch will normally stay alive for at least 20-22 hours. I wear it 24/7 and charge it for about 1-1.5 hours per day to top it off mid-day and it’s quite consistent. With Room Assistant I was draining my watch battery in about 6 hours. Even after tweaks that rendered Room Assistant somewhat useless (like polling every 5 minutes, which doesn’t lend itself to accurate presence detection in the house) I could only get as high as about 12-14 hours of battery life.

It was finally my wife that caused me to pull the plug on RA, she was getting pretty ticked that her watch was dying so fast when she charges it all night long and it was completely dead by 3pm when she wanted to work out.

I intend to re-visit RA at some point because I think it’s well written and really a cool piece of software, but so long as it’s a battery killer I have to weigh if having a cool room presence detection is worth having a dead watch and phone and a rocky marriage. :stuck_out_tongue_winking_eye:

I started down this path as well, using Fibaro motion sensors on each side of every door so I could detect, via time stamps, entry and exit somewhat reliably. The problem was that it couldn’t determine if one or two people triggered it, so it wasn’t as accurate as I wanted for the time and expense and headache of the experiment.

I still think the most reliable way is something like Room Assistant since it’s actually detecting a bluetooth device in range and you easily know if there is one or two people in a room and who it is. My plan is to find some kind of hybrid solution that gets me as close as possible without negative side effects.

ye that’s why I chose thermal arrays rather than motion as they can detect how many people/hotspots are in the area. it’s still far from perfect as of right now and room assistant is a really good plug-in-play solution as far as accuracy goes.

It’s certainly an interesting concept, but if two people pass through a door at close to the same time, how are you differentiating that it’s two people and not one? If they are on each others heels then it’s a bigger thermal blob, if it’s within a second of each other isn’t that too close for the thermal sensor to detect?

Don’t mistaken my questions as being critical of the solution, but more me being inquisitive as to a solution I might be interested in playing with.

1 Like

Been looking into RA too, but encountered the same battery issue.

Noticed RA has support for thermal, could it be an idea to drop the BL and run RA solely on thermal?

Getting room presence working would really up the automations (and getting us a step closer to a real «smart home»)

2 Likes

yup those are the few caveats of this system that makes it work 80% of the time. Still improving on that and looking to improve on it. I am doing this in ESPhome and will be willing to share the code that I have if you’re interested.

Agree 1000%!

Really? That’s very interesting.

I would very much be, if for no other reason than to tinker and collaborate for a good solution.

Here is The write up on Room Assistant thermal.

It looks like they are using it to detect hotspots to determine if there is someone inside are not. Seems pretty reliable but the obvious downside is the sensor has a limited range so big rooms will need multiple sensors.