Lighting controller counts how many people are in a room

[Deekshith Allamaneni] built this controller which will automatically turn the lights in a room on and off. No big deal, right? You can already get a replacement light switch at the home store that will do this for you. But there is one big difference. The commercial solutions we’ve seen simply rely in a motion sensor and a timer. But [Deekshith] found a way to count the number of people that enter a room, turning the lights on when the first person enters and off when the last person leaves.

The video after the break shows a demo of his test rig. At first we just thought that this was only counting how many times an object passes between the sensors. But it can also detect in which direction that object was traveling. Now the system just needs to be scaled up for use in a doorway.

These photoresistor/phototransistor based sensors work really well when you have the light source that close, but when you have your gate mounted on oposite sides of a door, things might get a little funky. Also, it’s always a good idea to be able to manually overide the current number, so the number doesn’t get too far off

I Thought about doing exactly the same thing, cause atm the traditional sensors are absolutely not perfect (when I’m sitting in the room at my laptop, after a few minutes the light switches off).

But how can this be extended to detect when two persons are going through the door, one leaving and one entering?
I already thought about infrared thermometers or thermal imaging cameras, but they’re either to expensive or I couldn’t imagine the ‘perfect’ way to use them…

one of the problems will be people that just pop their head around the corner of a room to tell someone dinner is ready of that the taxi is there or something and then the number will likely be way off….

I have eliminated this problem in the code. The microcontroller is programmed to check for a sequence of steps which eliminates false triggering.
The circuit is what you have expected but not the code.

In the real world counting who is in the room is very problematic. If you have children and/or pets the count can quickly become incorrect. We’ve tried this with software such as Misterhouse and the majority of folks quickly give up on this route. It appears technology such as kinect like devices can be used to solve this problem but this gets expensive for each room of the home.

It doesn’t work for all the reasons mentioned before: people coming together, kids, pets, people not going out totally etc.
Tried it personally.
The best way to do it? I really don’t know, motion sensors fail if you sit still. Probably one of those occupancy sensors.

Hey, do not judge that we cannot do. I have programmed it to eliminate those common errors. I have tested it with a 1 meter width gap(door) today. It works pretty fine (except that it is draining my batteries a lot). You will be convinced that it works only after seeing what I have done in the code.

Can you explain how the code works?
Also, provide more details as to how far the sensors are from eachother and at what height.

I know someone who has done a lot of work trying to make this work. The problem is that you cannot use just 2 sensors for all cases. There are multiple cases that will generate the same senzor output sequence. There are things that will distract you like how a person holds the hands, if there is something carried, if two people enter, if they hold eachother etc.

The real problem is that all this generates a cummulative error so once that appears things go bad until you have an opposite error.

Hi Everybody.
I made this circuit. I have gone through all the comments. I will answer all of them soon. People have listed some problems which i have already solved and some others which I never thought of. Thank you for your interest in this circuit.

I will soon write a post on my blog (www.deekshith.in) explaining it more clearly and provide the link here.

This is a very, very old principle. :) When I was a child, I saw this kind of a light switch in some ancient book (yes, an ancient book made of paper :) ) which I got from local library. Of course, there was an old-school circuit made of discrete elements (it seems that there was no even logic ICs, but I can’t remember exactly now) and relays.

Ha ha, Not any more. I am going to release it on my blog for free soon (possibly in a week or two). Yes, I have asked for money as I have spent on it. But, I got the money I’ve spent on it from a team of students (Ajay, Victor and Vidhyarthy) who took training from me for making it as their college project. I can now make it open-source whole heartedly.

Making it open-source will not only benefit others but also the project as many people are expected to contribute to it.
I need your feedback on this.
Thank you for you all.

Hey..It’s a simple counter, and it will should not work in a real room, where ambient light is a consideration. Moreover, what have you accounted in the code, you can only use the value that your sensors give and sensors will give you a high when two people are entering together. I doubt colleges accept such hacks as projects in India. It’s a 2 – 3hrs job for an EECS student.

I bought this circuit from Deekshith and it works fine upto a separation of 2 meters even in sun light. I too thought this is a simple ciruit at first glance but first thing to be noticed is that it detects direction. Not only that, it uses a data pattern for sensors not just continuous light making it immune to ambient light. It has accounted almost all kinds of errors possible during its operation. Although the error due to multiple persons entering at a time is not completely solved, there is also a solution given to reduce it. I hardly get any errors practically installed to a door. Unlike the prototype shown the version I got has a two sets of sensors placed up and down (probably for improved accuracy). Although the code is too large than expected, I am quite happy with this after experimenting with many similar circuits.