Home automation is a really neat use of technology. Automating the process of turning off the lights when you leave the room is nice if you're a tad lazy like me, and also is a way of being kind to our Earth by saving energy!

I started this project mainly as a segway into teaching myself more about the MSP430 family after I was inspired by a college course in embedded systems last year. We learned how to program the family in C++ and Assembly, but really only scratched the surface. It has been a challenging yet fun project and has helped me veer away from the Arduino.

So without further ado, here's an explanation of what this Instructable aims to show you how to build:

The room visitor counter (as you might have expected...) counts how many people are currently in the room, given this room only has one means of entry. We're not talking firepoles here - I mean a doorway. When there is at least one person in the room, the relay is switched on. And vice versa, if the room is vacant, the relay is switched off. 

Using 3 blue LEDs, there is a binary count (I didn't have a 7-segment LED display/display driver at the time I built this) of how many people are in the room, with a maximum displayable count of 7 (when the count is incremented past 7, the LEDs simply remain on).


In this instructable, I assume a level of ability in soldering and prototyping skills. The detail in this instructable is on a higher level of abstraction. In other words, if you can solder, read a schematic and are comfortable downloading some software, you can do it!

Step 1: Making the Backplate

First off, we need to build something to hold it all together. I could have opted for an enclosed case, but I started off simple. If you are feeling adventurous, it wouldn't be a bad idea to enclose this in a box for better protection and visual appeal.


Here's what we'll need for my bare-bones hardware build:

* 3/16" thick plexiglass
-->This is cheap yet study enough to keep this all together (plus, I use plexi for everything)

* 2 threadedstandoffs, metal or plastic
-->These are for securing the circuit board (PCB) to the backplate
-->At least 1/4" long; I used 3/4" metal standoffs because that's what I had. 4 would certainly work better at securing the PCB

* 8 4-40 screws, sized to fit your plexiglass and standoffs
-->Make sure they are long enough to clear the plexiglass, PCB board, and then thread into the standoffs at least 1/8"
-->We'll use 4 of these to mount the PCB

* 4 nuts, sized and threaded to fit the machine screws
-->These are for mounting the IR sensors

I cut the plexiglass from a larger piece using a tablesaw. Since this is just plastic, you should be able to get by using any type of blade. 

The dimensional drawing can be printed in 1:1 scale 

<p>Hello sir,</p><p>I use MSP430G2231 microcontroller generates two direction switch signal output, how to achieve </p><p>When someone via IR-P1.3, then by IR-P1.6, P2.6-LED1 lit, it indicates to enter, </p><p>When someone via IR-P1.6, then by IR-P1.3, P2.7-LED2 is lit, the exit</p>
How to count the number of how, if they can be connected to a computer records the number of out of the situation like
&quot;<em>...given this room only has one means of entry....</em>&quot;<br> <br> Not necessarily.<br> <br> Some time ago I devised (but never got around to build, that's my curse) a system with a pair of IR detectors several cm apart, an IR LED between them and a mirror across every doorway leading to / from a room, all of them feeding their signals to a single controller.<br> Thus, Someone can enter the room, the counter increments to 1 and the lights turns on inmediately. Someone else enters, it increments to 2. One of them leaves through another doorway and it decrements to 1. After a while the other one leaves, and only then the lights go off (after a brief delay in case someone returns).<br> <br> From there, I realized that a natural extension was to have a pair of sensors in every doorway, enabling the system to &quot;know&quot; how many peope are in every room (people who increment some room head count always decrement some other room's head count, if one define &quot;outside&quot; as another room).<br> <br> Catch #1: How do one turns off the light whil remaining in the room? Maybe waving a hand in front of the sensor pair in the &quot;out&quot; direction. Of course, the system should not allow for negative counts (i.e. leaving the lights off when leaving a room whith zero count)<br> Catch #2: Too many wires everywhere. Maybe only wire power to the sensors and have them transmit a sequence of pulses encoding sensor and direction?&nbsp;
Fantastic! Keep going! Is there a way to hide the whole system inside the drywall, leaving only two peepholes for the sensors? Put 'em in all the rooms, and take out all the manual light switches! <br> <br>This could also be helpful in case of burglars or other unwanted visitors. Someone trying to hiding in a room wouldn't be able to turn off the lights, so if you come home and find the lights on...
Actually, I think that leaving it at pet height (or mounting it on the ceiling so that height is not an issue could be a good thing. <br> <br>Seeing lights going on and off at random (whenever the pets moves about) is an excellent way to deter would- be-burglars. <br>
That would definitely be cool, yes; I'm sure you could cut a small slit in the drywall, fit in the sensors an then full in the gaps with plaster of Paris or something of the like!
it would be cool to see the satistical data on which room gets the most use. with this set up it would be easy to save a file that is appended to every day with how min and max number of people to go in and out. <br> <br>could also control how much lighting is actually used by the number of people in the room. <br> <br>also last thing i would do is increase the height so that a house pet isnt turning on the lights since they really dont need them.
Ooh that's actually a really good idea! This would open up some really cool projects if made en masse and put into a sensor-node network in a household.
awesome! I like how you used two sensors to determine the direction of movement. looks like it works great!

About This Instructable




More by RPisces:Room Visitor Counter with Relay Control ATX Power Supply --&gt; Cheap Bench-Top Power Supply Automated Plug-In Appliances 
Add instructable to: