Jump to content


Photo
* * * * * 1 votes

Room Occupancy Counters -- Need Help!


  • Please log in to reply
50 replies to this topic

#1 Jon S.

Jon S.

    Cocooner

  • Registered
  • PipPip
  • 21 posts

Posted 13 February 2011 - 04:05 PM

Hey guys,

Note: See pictures attached below.

I've come to the conclusion that I really, really want to have room based occupancy detection AND counting. Motion detectors are just not fast enough or accurate enough for me and my setup. I want to know when someone enters a room, leaves a room, and how many enter/leave. This way I can keep lights on and allow lights/music to "follow" someone around the house - instantly. No waving of hands in the air, no inaccurate counting. So over the past few weeks I have been experimenting with creating my own room counting interface based off a PIC16 micro controller. It works much like a retail store people counter by using infrared beams in the doorway. Total cost per doorway: around $10. Here is the setup:

Most of my doorways are exactly 3 foot wide.

At one side of the doorway I have placed an IR LED that is pulsing infrared light at 38kHz. On the other side there are two IR receivers that are calibrated to receive only a 38kHz frequency, side-by-side. When there is no presence in the doorway, the IR beam is detected by both of the sensors. When someone walks through the doorway, one of the IR receivers will be blocked before the other, thus, using some pretty simple logic, I can determine the direction of the person as they travel through the doorway by figuring out which of the two beams was 'broken' first. Then, once an entry or exit has been established by the counter, the 'node' would communicate back to my main controller and in return more complex logic would executed to determine what needs to happen based on other room counts, etc. For this I have a whole-house RS485 network that I already use for other nodes to communicate on anyway. (Bed occupancy sensor, temperature sensors, very small motion sensors, pipe temperature sensors, joist sensors, humidity sensors, rain gauge, etc.)

As I'm sure you are probably already thinking, there are plenty of things that can go wrong by me counting the breaks in the beams. I've been testing my code out over the past few weeks and here are the things that I have implemented to get pretty much 99% reliability.

- What about when someone swings their arms as they walk in? I have the sensors mounted about 44 inches above the floor. This eliminates most of the problems that would occur from this. Now, if you have something in your arms that sticks out, most likely it will block both beams the entire time that you and the thing you carry cross through the doorway. In order to prevent the counter from seeing some object that is ob-longed shaped and their torso as another, I made it so that the both beams have to be broken for a minimum amount of time (in milliseconds) or the count will be canceled. The thickness of the average torso from the side allows me to guarantee that both beams will be broken for this minimum amount of time given that they walk at a normal pace. Now, if someone were to sprint through the doorway, it won't count them. But walking at a fast pace all the way down to barely moving will be counted correctly.

- What about when someone enters the doorway and stands there? I built some more logic into the counter that would check which beam was returned to normal first so that I could detect, even after someone stood in the doorway for a long time, which direction they ultimately decided to go in. If someone walks in the doorway and stands there, then backs up, no update is ever transmitted. However, if the same thing happens and someone does decide to continue through the doorway, then the update is transmitted. Again, it's all based off of what beam is restored first.

- What if someone walks in right behind me? Unless you are literally holding on to each other with no space between your torsos, the beams will be restored as soon as the first person passes. I have a very small time threshold that must be met for both beams to be clear before the next person can walk in in order to prevent baggy clothing from setting off the sensor. I've tested this with 4 people virtually walking in a conga line and no problems whatsoever.

- What about walking side-by-side? I don't have this problem as my doors are only 3ft wide for the most part and I don't know of a time where I would walk side-by-side with someone through the doorway. The french doors are a different story. For these, it just won't be as accurate if you have multiple people who walk in and out side by side. For the times that I do have an inaccurate update, the logic in the main controller should be able to tell if there was a slip up based off of what rooms are connected and how many people walk into each of these rooms.

- What is someone waves their hand over the sensor to run up the count? This could happen, but they would have to do it slow enough for both beams to be broken for the minimum amount of time I specified. If someone waves their hand over it the counter just ignores it.

- What about TV remotes? TV remotes do operate on the same frequency of IR that I am using, however, because of the minimum time required for both beams to be broken, they don't cause a problem. They transmit way to quick (even holding down a button) for the signal to meet the time threshold.

- What about sunlight? This I'm not so sure about. I've been testing this on three of my inside doorways and I have not had a problem. I don't know what effect the sun will have on this if I use it on an external door or one right next to a bright window. My guess is it won't be much at all.


With all that out of the way, I have been testing 3 doorways for weeks using masking tape on the sensors to hold them up and it works great. But, here is where I run into my problem. How in the world do I make this aesthetically pleasing?

My plan is to have a small project box (3"x3"x3") below each doorway in the crawlspace where the RS485 network will hookup to it and the micro controller is housed. I distribute power over my network as well, so each control box will only need 1 cat5 cable going to it. That's no problem and easily done compared to my other projects. My problem lies with installing the sensors in the door frame. They are small - the IR LED is literally only the size of a small normal LED. The receivers are both square and 3/16th of an inch each, so two side by side are 3/8ths of an inch wide by 3/16th of an inch tall. They do have leads that come out the bottom and can be bent back. (see pictures) It will take a 22 or 24 awg 4-conductor wire for the receiver run and a 22 or 24 awg 2-conductor wire for the LED transmitter run. So the cables will be small, that's not an issue. The issue is how in the world do I mount these things to make them look good and run the wires behind the door frame to the crawlspace below where they will hookup to the control box. Here is what I have come up with so far:

- Pull the door frame off, drill holes in it and attach the receivers and transmitter in recessed holes and run the wire down through the floor in the wall to the crawl space. Very work intensive and honestly beyond my expertise :o) If I went this route I would probably have to have a contractor help me. But it would probably look the best.

- Route or trench out a small channel all the way from the sensors to the floor on each side where I will then take it directly below to the crawl space. Then putty over, sand, and paint the channel so it can't be seen.

- Use super-thin, flat wire that you can find online and paint over it. This will be hard to attach the sensors on the end though and it's VERY expensive.

- Drill holes in the doorway and fish the wires down. This will work for some of them, but for the doorways that are right near an adjoining wall, this is nearly impossible for one of the two sides due to the 2x4s.


I know this is a long post, but I truly believe this is an awesome solution to my problem after trying it out the past few weeks. If I could have this implemented in all my doorways, it would make things so much more efficient and fast. Any advice anyone has or suggestions, good or bad, would be great. :)

Attached Files


Edited by Jon S., 13 February 2011 - 04:11 PM.


#2 JFab Design

JFab Design

    Dedicated Cocooner

  • Professionals
  • PipPipPip
  • 211 posts
  • Location:PA
  • Software:Custom
  • Hardware:2GIG, DSC, HAI OmniPro II, Custom
  • Tech:Z-Wave, ZigBee, RadioRA2
  • Audio:Custom
  • Video:Custom
  • CCTV:analog, ip, dvr
  • Phone:Vonage

Posted 13 February 2011 - 05:57 PM

I would pull the trim off one side of the door and run the wire between the framing and the door jambs. You could then drill into the basement when the trim is off. This seems like the easiest thing to do.

#3 DELInstallations

DELInstallations

    Cocoonut

  • Professionals
  • PipPipPipPip
  • 5400 posts
  • Software:Custom
  • Hardware:Custom
  • Tech:ZigBee
  • Audio:Custom
  • Video:Custom
  • CCTV:analog, ip, dvr

Posted 13 February 2011 - 06:57 PM

Not to be Nancy Negative, but that'll work fine until the first time the doorjamb is painted.

#4 signal15

signal15

    Cocoonut

  • Registered
  • PipPipPipPip
  • 1296 posts

Posted 14 February 2011 - 12:42 AM

Not to be Nancy Negative, but that'll work fine until the first time the doorjamb is painted.


If we're talking doorjambs with woodwork... it shouldn't be a problem. Painting nice woodwork faded out with Eisenhower after the 1950s. The insurgence of LSD in the 60's opened peoples minds and made them realize that painting woodwork and authority were silly. :)

#5 DELInstallations

DELInstallations

    Cocoonut

  • Professionals
  • PipPipPipPip
  • 5400 posts
  • Software:Custom
  • Hardware:Custom
  • Tech:ZigBee
  • Audio:Custom
  • Video:Custom
  • CCTV:analog, ip, dvr

Posted 14 February 2011 - 06:29 AM

Look at his pictures ^_^

While I can applaud the idea and effort, I don't think it's as clean as what we've done using SureAction pulsors in a bunch of our installs. Seems like a lot of work for what it's going to accomplish combined with the asthetics of the completed project. I'd see all sorts of issues if I had to install those for a paying client, however YMMV.

#6 drozwood90

drozwood90

    Cocoonut

  • Registered
  • PipPipPipPip
  • 1195 posts
  • Experience:guru
  • Software:HomeSeer
  • Tech:X10-RF, UPB, Z-Wave
  • Audio:Custom
  • Video:Custom

Posted 14 February 2011 - 08:29 AM

Don't the Pulsars require motion though? That is, if you sit down and put your feet up, it won't see you any longer?

--Dan

#7 Jon S.

Jon S.

    Cocooner

  • Registered
  • PipPip
  • 21 posts

Posted 14 February 2011 - 08:45 AM

Look at his pictures ^_^

While I can applaud the idea and effort, I don't think it's as clean as what we've done using SureAction pulsors in a bunch of our installs. Seems like a lot of work for what it's going to accomplish combined with the asthetics of the completed project. I'd see all sorts of issues if I had to install those for a paying client, however YMMV.


Well, the issue for me with Pulsors are that I can't "count" people. When more than one person walks in a direction, the Pulsors would indicate a single person walked through due to the area of the joist it covers. I actually use Pulsors as bed occupancy sensors (see my website in signature below for details) on my RS484 network. I do agree with you though that if you had to install this for people it would be way too much work :)

#8 Photon

Photon

    Dedicated Cocooner

  • Registered
  • PipPipPip
  • 440 posts
  • Location:SE Wisconsin
  • Hardware:Elk M1
  • Tech:X10-PLC
  • Video:Windows Media Center
  • CCTV:analog, ip
  • Phone:Vonage

Posted 14 February 2011 - 09:43 AM

Here is what I have come up with so far:

- Pull the door frame off, drill holes in it and attach the receivers and transmitter in recessed holes and run the wire down through the floor in the wall to the crawl space. Very work intensive and honestly beyond my expertise :o) If I went this route I would probably have to have a contractor help me. But it would probably look


Since you were able to install an Enforcer door strike in your wiring closet, you clearly have the skills needed to remove the moulding from the door frame to install your components and hide the cables. Since your trim is painted, you can recover from any mishaps with minimal diffulty. No need to pull the entire frame.

#9 ver0776

ver0776

    Dedicated Cocooner

  • Registered
  • PipPipPip
  • 446 posts

Posted 14 February 2011 - 10:57 AM

I like it and want to support it in my software and house. Maybe you can make a project guide out of it listing required hardware, and any source required to interface to the board.

I like it because my dogs will not set it off like my hard to place motions...

Vaughn
OpenSourceAutomation

#10 Jon S.

Jon S.

    Cocooner

  • Registered
  • PipPip
  • 21 posts

Posted 14 February 2011 - 12:57 PM

Since you were able to install an Enforcer door strike in your wiring closet, you clearly have the skills needed to remove the moulding from the door frame to install your components and hide the cables. Since your trim is painted, you can recover from any mishaps with minimal diffulty. No need to pull the entire frame.



Lol installing the enforcer was more of a "cut until it fits" project ;) I might can tackle this. I guess I just lack the experience when it comes to building construction. Since my doorways are painted, it almost looks like everything is one piece, even though I know it's not. I guess I just have to sit down and figure out what comes off and how to get it off without ruining the door frame Lol

#11 ano

ano

    Cocoonut

  • Registered
  • PipPipPipPip
  • 3464 posts
  • Location:AZ
  • Experience:guru
  • Hardware:HAI OmniPro II
  • Tech:UPB, ZigBee
  • Audio:HAI
  • Phone:Ooma

Posted 14 February 2011 - 01:00 PM

I think anytime you can have more tools in your arsenal, this is a good thing. I could see this technique being used for closets, where you really want the light to go on when someone enters and off when someone leaves. Maybe even also for some occasional use rooms. For most rooms, probably not. Plus the physical requirements of mounting it in the doors, hooked up to control logic isn't all that practical for most areas. A motion detector turning on the light, and a human turning it off is the best solution in most cases. Plus with LED lights, power is so low, really the cost of running them is quite low, its not all that important to turn them off anyway. If I want to have the lights follow every step I take, I'll just wear a miners hat with a light built-in.

I've used the Pulsor's as well, and again, just another tool in the arsenal. For me they are not very helpful, as I have a cement slab foundation and no second floor. I haven't found a good use that a simple motion detector can't fill, but again, the more solutions, the better.

#12 Jon S.

Jon S.

    Cocooner

  • Registered
  • PipPip
  • 21 posts

Posted 14 February 2011 - 01:04 PM

I like it and want to support it in my software and house. Maybe you can make a project guide out of it listing required hardware, and any source required to interface to the board.

I like it because my dogs will not set it off like my hard to place motions...

Vaughn
OpenSourceAutomation



This is actually one of the reasons I want to do this too. I have a cat who thinks she should be part of the circus and sets off mine. I'll definitely post the schematic, full writeup, and code to program the chips (it's easy) when I get it all installed and working. I might could even sell the kit for the lazy people and program the chips for them. The process of adding the writeups to the website is time intensive, but I could make it a priority.

#13 Jon S.

Jon S.

    Cocooner

  • Registered
  • PipPip
  • 21 posts

Posted 14 February 2011 - 01:34 PM

I think anytime you can have more tools in your arsenal, this is a good thing. I could see this technique being used for closets, where you really want the light to go on when someone enters and off when someone leaves. Maybe even also for some occasional use rooms. For most rooms, probably not. Plus the physical requirements of mounting it in the doors, hooked up to control logic isn't all that practical for most areas. A motion detector turning on the light, and a human turning it off is the best solution in most cases. Plus with LED lights, power is so low, really the cost of running them is quite low, its not all that important to turn them off anyway. If I want to have the lights follow every step I take, I'll just wear a miners hat with a light built-in.

I've used the Pulsor's as well, and again, just another tool in the arsenal. For me they are not very helpful, as I have a cement slab foundation and no second floor. I haven't found a good use that a simple motion detector can't fill, but again, the more solutions, the better.


I completely agree. The more tools and sensors the better. When it comes to me though, I'm lazy and I try to push the limits. This is probably a little complicated to describe, but the counting aspect of it is what I really want. Here is why:

- Body Count - A household body count is, for me, the ultimate in what I want to achieve. With sensors like these on all exterior doors, I will know how many people are in the house at all times. Right now, everyone who lives in my house has an iPhone and I detect body count by pinging the iPhones constantly on wifi to detect presence. When guests arrive, I have to set them manually with an override. All beds in my house have sensors on them that not only tell when someone gets in them, but how many people are in them as well. Using the household count I can see if everyone in the house has gone to bed, and immediately turn off lights if they are. If only one out of the two people are in bed, then turn off the lights just in the room where they are sleeping and when someone walks into the bathroom adjoining that room, dim the lights on. When that person finally gets in a bed, then shutdown the house. If someone gets up int he middle of the night, turn on guidance lights. If all people are up, dim the lights on gradually if they were sleeping for more ten 30 minutes.

- Auto Arm - Upon leaving the house through the garage, I want the house to detect when the last person leaves. If I'm the only one home, and I walk out of the garage, get in my car, open the garage door, back out of the driveway, I want the house to shutdown instantly and arm the security system. I have directional based driveway sensors, garage door sensors, etc. that will all relay back to the system to make the judgment call to shutdown.

- Blinds - This is going to sound crazy, but I told you I try to push the limits... I have plantation shutters built in throughout my house on the inside. I have begun to install servo motors in the bottom of them (facing toward the window, on the bottom so you can't see from the inside or out), ran the wire to my crawlspace my drilling a hole straight through, and it connects to a control box that attaches to my RS485 network along with separate power hookup because they draw several amps. Using these I can control opening and closing of them precisely. Well, I have blinds over my bathroom tub (and it's a big 250 gallon one) that is extremely annoying to close. When I walk into the master bathroom at night I want them closed instantly, and for some of the other rooms in the house as well. My house is rather strange, very contemporary, no hallways in the entire house. So for my setup, it works great.

- Music following - For the rooms I don't use that often, I would like to try allowing music to follow me. I have a Nuvo Grand Concerto with the expander kit, so I have 12 amplified zones and an additional 4 non-powered zones. I use RS232 to control outputting speech in only the zones I want and the same for music.

Alright, I know I'm probably going into too much detail so I'm going to stop rambling. It's a fun hobby for me, so I guess the extra work involved in making it smarter is worth it for me ;)

#14 Deane Johnson

Deane Johnson

    Dedicated Cocooner

  • Registered
  • PipPipPip
  • 412 posts
  • Location:Omaha, Nebraska
  • Experience:average
  • Software:CQC
  • Tech:Z-Wave

Posted 14 February 2011 - 01:47 PM

Great work you're doing Jon. Sometime when you get time, it would be cool if you could provide more information on your servo motors closing your shutters. This comes up from time to time on the forums, but I haven't seen anyone previously figure out how to do it.

Deane

#15 Dan (electron)

Dan (electron)

    CocoonTech Admin

  • Admin
  • PipPipPipPip
  • 10865 posts
  • Twitter:@CocoonTech
  • Location:Central NY
  • Experience:guru
  • Software:EventGhost, HomeSeer
  • Hardware:Elk M1, Mi Casa Verde Vera, Ocelot
  • Tech:X10-RF, UPB, Z-Wave, ZigBee
  • Audio:AirPlay
  • Video:SageTV
  • CCTV:analog, ip, dvr
  • Phone:OBi100/110

Posted 14 February 2011 - 02:21 PM

Very cool, keep us posted please! If you want this posted as a tutorial, let me know, and I can help with the layout etc.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users