Sensors

I am trying to build a smart-room with an arduino. I want to turn on the light in the room when somebody walks in and there is not enough light. And I want to turn off the light when someone walks out and he/she is out for 5 minutes.

So I need some kind of a light sensor (to sense how much light is in the room) - the one that is easyest to use.

And I need to sense when somebody comes in and goes out. I was thinking of using some kind of a light sensor that goes to one side of a doorframe and an light source (probably IR?) that goes to the other side. I would use two sensors like this and calculate time when they were activated (if one sensor is activated before the other - someone has come in...). Any ideas what to use? Are there any sensors that track movement direction in a small area?

I was looking at the electronic stores but I can't find anything useful. Maybe this: http://si.farnell.com/panasonic-ew/amn13111/sensor-pir-compact-spot-5m-black/dp/4160290

problem is that this detects motion inside a wide area while I just want a point. I remembered some kind of IR sensors in public toilets. They flush automaticly when a person moves away from it. Maybe I would need something similar?

Try the Ping Ultrasonic Sensor from parallax .

You can get Passive IR sensors that are used to detect people who shouldn't be there, i.e. burglars! They are usually quite simple to connect to the alarm system, and should be OK with an Arduino.

@Anachrocomputer: I posted the link to one of them in my second post. Problem here is that this sensor detects when somebody is in the room not when they come in or go out.

Maybe that is the best way to do it but I don't know. How fast does it react to someone that comes in the room? I want to instantly turn on the light when somebody comes in.

when they come in or go out

Surely the Arduino could be programmed to detect a change of state? Sensor goes from off to on => someone has walked in. Sensor goes from on to off => everybody has left the room. You will probably need to add some sort of timing element, too. So if the sensor has remained off for say, a minute, then the room is unoccupied.

Don't quite understand why you need a "point" sensor?

With “point” sensor I mean that it makes some kind of a line between two sides of the doorframe. When the line is crossed the sensor is triggered.

But now that I think about it Passive IR sensor is maybe a better idea. If there is nobody in the room I can turn off the light.

When the line is crossed the sensor is triggered

Ah! So could you arrange an infra-red light beam that is broken when a person walks through? And detect the broken beam with an IR-sensitive photodiode? Rather like the customer-counters in some shop doorways.

Something like that yes (English is not my primary language so it is a little harder to explain what I want :)). I would then count how many persons are in the room and if there is no one ther I would turn off the light. I just don't know what to use.

And there is another problem of an ambient light sensor - I only want to turn on the light when there is not enough light in the room. What can I use for that? Probably some kind of an photo diode connected to analog input?

for sensing the light level in the room, you could use a LDR (Light Dependant Resistor) an hook it up together with a fixed resistor as a voltage divider to an analog input. Very easy, very cheap.

I'd like to do the same... MikMo said right for the LDR sensor. It's explained in Massimo Banzi's book, it's really easy.

For the people detector, I'd use a PIR sensor too. They're pretty reliable, cheap and easy to find, but I would put two of them in different position so to avoid false readings. I have a PIR+relay to turn on/off the light on the stairs, damn cheap, it works well except on summer which I noticed sometimes it turns on without reason - and there's no sunlight coming there.

Just to say we have some of these "smart" rooms at work and they are a bit annoying to use at times as the light levels are set wrong.

Also at one University they had these sensors in the toilets (U.S. translation:- bath rooms, although they didn't have a bath in them) which was all very well but when you went for a "sit down" it would stop seeing you and turn off the lights. This could be some what problematic at night. ::)

I will try to construct one that works like it should! ;) And of course I will still have manual control over the lights. And it is a nice project! But I still don't know what to use. passive IR sensor vs. something.

there's nothing better than try by ourselves and share the experience :D fortunately these kind of sensors are quite cheap.

You are right! I will buy a few of those PIR senors and try them. But I would still like a sensor for my other idea - to count how many people are in the room. But I don't know what to buy. Probably some IR diode and a IR sensor?

You could then have a look on Vishay's products, they have pretty good stuff

Please! I want specifics!

Would it work if I use a IR photodiode - like this:
http://si.farnell.com/sharp/gp1ux511qs/photodiode-ir-detector/dp/1243868

And an IR diode - like this:
http://si.farnell.com/osram/sfh415-u/ir-emitter-5mm-950nm/dp/1212749

If I put both in a tube and mount them to the doorframe, and then mount another pair 5cm away - would the detector detect both beams or just one?

I want something like this:
|* =|1
| |
| |
|* =|2

| ← Doorframe

  • ← IR diode
    = ← Detector

I don’t want detector from 1 detecting diode from 2. And of course the other way.

BTW don't buy a alarm system moving sensor, as those only turn on while there is mouvement. If someone is only sitting in a chair for 4-5 sec the sensor turn off, until new movement is detect.

I remebered that! Because of that I am moving back to my original idea.

Maybe put a receiver and transmitter on each side instead of 2 of each on a side which will bypass the interference issue ..

On a lighter note ;) may I just say that this can be an extremely complicated project, have you considered some of the probable issues that may arise?

Add a movement detector inside the room to override the zero count from the door sensors and switch the lights on. You dont wan't want Grumpy Mike calling you in the middle of the night to complain about the lights .. :o

A person may stand in the doorway chatting to someone outside breaking the beams repeatedly with arms movements Perhaps a pressure sensor under the doorway to exclude this saboteur from the count? 8-)

A person may elect to exit the room via the window bypassing the beams. I live in South Africa, this is likely here. Perhaps if the movement detector 'sees' nothing for an hour reset the person count to zero? If anyone is left in the room they are propably sleeping so they would appreciate 'lights out' anyway... ::)

A person may elect to steal the sensors. Again, I live in South Africa, this is very likely here. Perhaps disguise your sensors as security cams although not a good idea if the smart room is a toilet/bathroom. Perhaps rather include tamper switches which will make the lights flicker in an aggressive way when tampered with.. >:(

Good luck :)