Picture of Room Visitor Counter with Relay Control
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!

yyhhgg1 year ago

Hello sir,

I use MSP430G2231 microcontroller generates two direction switch signal output, how to achieve

When someone via IR-P1.3, then by IR-P1.6, P2.6-LED1 lit, it indicates to enter,

When someone via IR-P1.6, then by IR-P1.3, P2.7-LED2 is lit, the exit

yyhhgg2 years ago
How to count the number of how, if they can be connected to a computer records the number of out of the situation like
Fik2 years ago
"...given this room only has one means of entry...."

Not necessarily.

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.
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).

From there, I realized that a natural extension was to have a pair of sensors in every doorway, enabling the system to "know" 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 "outside" as another room).

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 "out" direction. Of course, the system should not allow for negative counts (i.e. leaving the lights off when leaving a room whith zero count)
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? 
DQuinn20102 years ago
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!

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.

Seeing lights going on and off at random (whenever the pets moves about) is an excellent way to deter would- be-burglars.
RPisces (author)  DQuinn20102 years ago
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!
crackHacker2 years ago
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.

could also control how much lighting is actually used by the number of people in the room.

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.
RPisces (author)  crackHacker2 years ago
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!