7
\$\begingroup\$

I have recently wondered if I could build some kind of useful and cool device, using some sensors, transmitting signal and doing something with it - I think people who answer questions on this site will know what I mean - some desire to tinker something.

So, I wondered about Internet and searched for some ideas, and found one that I would like to try to implement.

So, the idea is that there is a door, and when it opens and it is night time - the lights should be turned on for a minute or two, if there are no other lights on already. I think it is basic enough idea and I could get the experience of making something by implementing it. Now, I know there could possibly be already existing solutions, and I might be reinventing the wheel, but I want to try.

My question is - how do I approach this?

If I understand right, 1. there should be some sensor to detect if the door is open. 2. also another device which keeps track of the day time, so I know if its night or not. 3. some switches to operate with the lights - on and off states 4. some way to transmit the signal from switches and 5. something which will decide if the lights near door should be turned on or not

About the requirements - those things should probably be lightly powered so that they can run a lot of time without needing recharge (possibly using some AA batteries, or something smaller, what kind of power source could I use?), pretty much most of the time the devices should be automatically offline (maybe only switch on at night time?). Considering that I want it to be minimal in dimensions, so that I could easily install it anywhere I want - when the device is finished it should be somewhat compact (perhaps attachable to walls or something?), and of course - this shouldn't cost hundreds of dollars to buy and make, I mean its pretty much a small trinket?

So, given all this, my question is - where do I start? what should I look at? Can anyone describe the whole process to me? Including the final step of putting the electronics to some wrap, so that its inside some plastic and doesn't display the cords and patches and etc? Any advices and explanations are welcome.

\$\endgroup\$
7
  • \$\begingroup\$ Do you want a circuit drawn up? (I'm guessing not) or hints as to what to use and how. Do you want the main room light to turn on or a small light near the door? What electronics experience do you have already? \$\endgroup\$
    – Oli Glaser
    Commented Jan 11, 2013 at 19:12
  • \$\begingroup\$ I guess not the circuit yet - I am familiar with basics of electronics and remember a lot from my physics classes, but I will probably not understand the drawing yet. Also, the purpose of the device is to make light near the door, so I can for example remove the boots and coat and etc. If its dark - its inconvenient. That's what I want to change with this device. \$\endgroup\$ Commented Jan 11, 2013 at 19:17
  • \$\begingroup\$ Okay, thanks. I'm just dropping in and out briefly at the moment, but I'm pretty sure you will get some good answers very soon. Try and give as much info as clearly as possible and answer any questions asked (e.g. the above question about the main light/light near door I'm not totally clear on - in the 3rd paragraph you say "lights should be turned on", but then in the 5th paragraph you mention "lights near the door") \$\endgroup\$
    – Oli Glaser
    Commented Jan 11, 2013 at 19:24
  • \$\begingroup\$ Thanks! ) I have time, don't worry about it - it isn't like its really urgent or mission critical. I had a class on ubiquitous computing a year ago, and this is first time I decided to make something from this "new era", like "smart house" implementation. I want to start small and progress from there. \$\endgroup\$ Commented Jan 11, 2013 at 19:33
  • \$\begingroup\$ Okay, I added a couple of "get you started" circuits with part links and some explanation. Hope this helps a bit. \$\endgroup\$
    – Oli Glaser
    Commented Jan 12, 2013 at 0:17

2 Answers 2

14
\$\begingroup\$

You've got the general idea down already, so start documenting what you know - make a block diagram. Draw the blocks (processor, battery, light switchy thingy), determine where you have to draw lines that connect them together. Put a lot of '?'s all over the place for everything you don't know.

Above all figure out specific questions!

For example, you know you need a door sensor - but what kind? I just did the first thing I thought of - Google it. Despite all of the results I know (from experience) that you'll probably want a door sensor similar to this or at least one that follows the same principles. So read up on it, figure out how it works (in this case one side is a magnet and the other is a Hall effect sensor that detects the magnet) and then find more questions: how do I connect this to a microcontroller for example.

You've got a lot of specifics and a lot of questions. Write down and sketch out everything you know, figure out what you don't know, do research and think up specific questions to ask here. Trust me - we get enough bad, vague general questions (fake example: "How do I make a robot that responds to my voice?") but we're more than happy to answer specific well-reasoned questions like "I have this Hall Effect sensor but I can't tell from the datasheet if the output is TTL or just an analog voltage. What is the best way to connect this to a microcontroller to determine if a magnet is present?"

And sadly, expect a lot of delays and frustrations. I tried making a Halloween costume this year and I'm still working on it for various reasons: I designed the reset circuitry for my microcontroller incorrectly so I couldn't program it until I ripped it all apart, I had the wrong PCB footprint for my contact switches so none of them worked, I didn't put an external power connector on the board so I could only work on it while I had a ready supply of 9V batteries, my PWM outputs cause so much noise on my accelerometer (analog) output lines that they're unusable, my accelerometer is so noisy I can't integrate its output to obtain velocity, my Bus Pirate needed a firmware upgrade so it wouldn't choke on my serial data, yada, yada, yada. I may not be done by next Halloween! You'll definitely need a lot of patience because these things happen and happen often.

Good luck.

\$\endgroup\$
3
  • \$\begingroup\$ My biggest problem is not knowing what is out there. What kind of different types of chips, microchips, magnets, switches and etc are there for each part of the system I am trying to build. I can't google for something I don't know the term for. \$\endgroup\$ Commented Jan 11, 2013 at 20:40
  • 2
    \$\begingroup\$ +1 for block diagram/documenting, very important to have a goal/specs/plan to work towards. @Toly - I'd follow the above advice and work slowly and methodically; otherwise your body may swell and go green, your clothes tear, and then suddenly you'll become the "AngryEE" ;-) \$\endgroup\$
    – Oli Glaser
    Commented Jan 11, 2013 at 20:59
  • 1
    \$\begingroup\$ @Toly I feel your pain but there's simply no substitute for banging your head against the wall repeatedly until you find the door. You'll have to search for things you only vaguely know the names for, struggle to understand web sites not written to your level of experience and make multiple mistakes because in the real world there are no guides, no tutorials and what you're doing has never been done before so no one can help you. That's the reality: you can't search Google for an answer that's no one else has found; you have to find it yourself. \$\endgroup\$
    – AngryEE
    Commented Jan 11, 2013 at 21:58
9
\$\begingroup\$

I'll try and approach this bit by bit:

First off, you need something that detects light/dark. This is nice and simple, there are various light sensitive components, one of which is called an LDR (Light Dependent Resistor)
Using this, a resistor and a transistor you can make a simple circuit that will output "high" (e.g. the supply voltage, or "logic high") or low (0V or "logic low") Which way round is not too important, but let's choose a high output for when it get's dark.

Components:

  • LDR - here are some examples, let's pick this one (no particular reason other than it's cheap really)
    According to it's datasheet, it has a resistance of 1MΩ when it's dark, and a resistance of 40.5kΩ when it's light (10 lux).

Now depending on how sharp you want the turn on to be (e.g. either the output gradually rises as it get's dark, or switches fully at a certain point, you can design your circuit accordingly. We'll make it simple and use a general purpose NPN transistor:

LDR Light Detect

Here's the simulation, the LDR resistance value is swept from 40.5kΩ to 1MΩ (this is the X axis) We plot the OUT voltage as the resistance rises (it gets darker) Notice the output starts rising around 600kΩ, and is nearly at 5V at 800kΩ

LDR Light Detect Sim

You can change the turn on point easily by changing R1 - if you want the output to rise earlier then reduce R1 (e.g. using 50kΩ will make it turn on at around 350kΩ
If you want to have the ability to change it easily, then you can replace R1 with a potentiometer (e.g. a 100kΩ pot would do nicely) You would connect one end to ground, and the other end plus the wiper to the transistor base/LDR node.
The transistor part number is not so important - any general purpose NPN transistor will work. However, the BC337-40 is an excellent transistor, so it's very useful to have a bunch lying around.

Sensor

The next thing you need is the sensor to detect whether the door is open or closed. There are a few ways of doing this (magnetic, pressure, optical, microswitch, etc)
I'm going to pick a microswitch such as this one (a lot more here), since with a slight alteration of the previous circuit we could have a very simple solution.
If we pick a MOSFET (instead of the NPN transistor above) capable of driving a high current white LED (e.g. a 600mA part - the LED part number shown is not a suggestion, just one of the LEDs available in LTSpice, which I am using to simulate these circuits), then this circuit may suit your requirements:

LDR Door microswitch

We use a 9V supply for this circuit, though this can be changed if desired.
Here, we use the microswitch both to turn the MOSFET off if the door is closed, so the light detect only works if the door is open, and the circuit draws almost no current if the door is closed, or the room is light, which means the batteries should last a long time.
We used a different LDR here which ranges from 12kΩ (light) to 200kΩ (dark) (we could still use the other LDR, in fact it would be better for battery lifetime - I was just tinkering around with things and used this one to try and idea out and it got left in there)
I also chose a MOSFET in a through hole package so it will be easy to work with. The part is far overspecced for the task of driving a small LED/Light, but it's cheap, easy to solder into your circuit, and you can upgrade to a higher current light if you wish.

Simulation:

LDR Door microswitch simulation

The blue trace only represents the door closed/open (it's the only way to simulate it easily in SPICE) All it means is if the level is low, the door/microswitch is open, and if it's high the microswitch/door is closed)
You can see the door starts out open since the blue trace is at 0V. The light level drops, and the MOSFET turns on when the LDR reaches around 80kΩ. Then we simulate the door being closed, you can see when the DOOR_CLOSED voltage goes high, even though the LDR is dark (so the MOSFET and LED should be lit) it turns the LED off.

Let me know if you have any questions, there's anything you don't understand, or you want to change how it works. There are plenty of ways to do this, I've just attempted to find a very simple solution for you to start with (we can quite easily complicate it ;-) )


Timed Version

Here is a version that will turn the light off again after ~2 minutes:

Door Light Timed

Simulation:

Door Light Timer Simulation

It is assumed the room is dark for this simulation (LDR set to 200kΩ) I won't show the light room simulation since we already know the LED will not turn on.
You can see the door starts out closed (represented by the blue trace at 1.1V), then at 10s, the door opens and the LED turns on. At around 130s, it turns off again (even though the door is still open)
Hopefully this is close to the kind of thing you are looking to achieve. The supply voltage is 12V, so you could use an LED lamp or strip like one of these:

12V white LED strip

This strip would be used in place of the LED and resistor shown (as it has onboard current control) There are many other options to choose from, 12V is a common lamp voltage, so have a look on Farnell, Digikey, etc and take your pick - the FET shown will handle a large current, so you could use a very bright lamp if desired. For example, this LED lamp is rated at 17.2W, uses a supply of 12.3V and would be brighter than the strip above:

LED Lamp

Parts List

  • 555 Timer
  • Some general purpose transistors , like BC337-40 (or BC337-25), or 2N3904, 2N2222 (selection here)
  • Resistors (grab the values shown, plus a few extra in between values) a kit from somewhere like Sparkfun is not a bad idea.
  • Ceramic capacitors - 100nF (also sold as 0.1uF), 10nF, 1nF, 100pF
  • Electrolytic capacitors - a few values ranging from 100uF to 1000uF, try for over 16V voltage rating
  • LDR (from the examples link above) and/or phototransistor, photodiode might be good to have handy.
  • Some logic gates - NAND, OR, Inverter may be useful.
  • Power source - a 9V or 12V wall wart rated for >500mA (mainly depends on how bright you want your LED lmap to be) should be okay. Or batteries could be used, e.g. 6 * AA Ni-Mh could be used.
  • Many of the above can be purchased in the form of a kit such as this. More kits here (note there are 4 pages)
\$\endgroup\$
12
  • \$\begingroup\$ Tell me if I read it right: This circuit closes when a) door is closed(?!) and b) it is dark near the light sensor? So, I guess the parts could be re-arranged to make it functional when the door is open after being closed and it is dark, right?? Or it doesn't work this way? Also, I don't see anything that makes the LED/Lamp/Light-bulb powered for another 1-2 minutes after. So, scenario again: Stage 1. Situation: It is dark. The door is closed. (I think the idea you have can detect this state) Stage 2. if (Stage 1) and door is opened - we need to turn the lamp on for 1-2 minutes. \$\endgroup\$ Commented Jan 12, 2013 at 5:27
  • \$\begingroup\$ In other words, I have a !Basic Lamp basic lamp with a switch circuit, and want to add the functionality of automatic turning of the lights on to it. \$\endgroup\$ Commented Jan 12, 2013 at 5:36
  • \$\begingroup\$ For a) The light is held off if the door is closed (whether it's light/dark - I thought this would be useful to save power). For b) the circuit as it stands turns on if and only if it's dark and the door is open. So we just need to add the functionality for the light to stay on for 1-2 minutes after door opening/dark (so even if the door closes again, the light remains on for a while. Sorry I missed this bit last night) Is this correct? \$\endgroup\$
    – Oli Glaser
    Commented Jan 12, 2013 at 10:12
  • \$\begingroup\$ @Toly - I added a timed version based around the cheap and easy to use 555 timer. \$\endgroup\$
    – Oli Glaser
    Commented Jan 12, 2013 at 15:20
  • \$\begingroup\$ Sorry, the new circuit drawing seems to be above my level to read it through. The only question I have managed to get by looking at it is this - after we switch on the lights for 2 minutes - will they stop immediately because LDR will now detect light and "stop"? I mean, from what I understand, LDR seems to be in the key position for the LED lamp to be switched on. If it stops being part of the conduit (unsure here if it will happen at all) - the chain between power source and LED breaks and the lamp turns off. \$\endgroup\$ Commented Jan 13, 2013 at 19:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.