Automatic Closet Lightswitch


[Dillon] wrote in to tell us about his latest project, an automatic light switch for a the hallway closet in his house. Although this project could probably be done very simply, [Dillon] accomplished everything in a way that actually looks professionally done and has some neat features. Check out his site for more pictures of the build.

Not that we at [HAD] mind a bit of messy wiring, but if it’s going inside a house, neater is always better. On the other hand, this project took nearly a year to go from idea to implementation, so please keep submitting your spaghetti-wired projects.  We understand.

As an electrical engineering major, [Dillon] didn’t skimp on basic electrical components, and has schematics available on his site. A MSP430 microcontroller provides the “brains” for everything, turning the light off after 5 minutes if the doors are not shut. Be sure to check out his video overview after the break with footage of it in action.


33 thoughts on “Automatic Closet Lightswitch

  1. Rube Goldberg would be oh so proud.

    Nothing like taking a VERY simple switch and timer and making it into a huge over complicated micro controller based frankenswitch.

    What are they teaching EE’s these days (or should I say what AREN’T they teaching them)?

    1. Can you do this whole project with a mechanical switch and a 555 timer? Sure. But why? There’s nothing wrong with using a microcontroller to do something simple.

      An MSP430 costs <$1.50 in quantities of 1 at Digikey. Microcontrollers are easy to program and it's fast to get something working. You can solve a lot of problems without placing an order if you have a few spare microcontrollers sitting around.

      There's nothing wrong with microcontrollers, and there's nothing wrong with the engineers using them. This is a good project; I suggest that there's something wrong with the engineers who think otherwise.

      1. I agree with you in that there is nothing wrong with using a micro to do something simple, it just seem that this is so simple that it seems almost unnecessary (like using a micro to turn on an LED). I just feel that there is nothing useful to learn in doing this.

        1. Well, maybe there’s nothing for you to learn with this project. Of course the guy who built it isn’t you, so he did learn something. Don’t think of it as a waste of time, think of it as a practical experiment for what he’s learning in class. Maybe what he learned was you’re right, that it was overkill for this application.

    2. …it’s still an engineering course, so what would you expect?

      of course i could argue he’s still missing a motion detector. Or It could be much more efficient and use two laser or ultrasound switches to detect people going in and out and turning the light only when there were somebody inside. …or maybe a floor pressure plate…

  2. I like the end result, simple and functional. I do agree with vonskippy though, this is MASSIVELY over-engineered. Personally, I would have probably used a 555 in monostable to provide the 5min timer rather than waste an entire avr, Also I think it would have been cool (and pointless) to add some sort of dimmer so the more open the door is the brighter the light.

    1. Really I’m getting sick of these “over engineered” comments. Quite often the results are actually cheaper, simpler with less component counts, use lower power, and far more configurable by reaching for a simple microcontroller.

      Just think about that section of the datasheet next time you make a project. A NE555 uses 2-3mA, an AVR with a timercounter and interrupt enabled uses an order of magnitude less.

      1. If I were to use an msp for this incredibly simple function then I would need to splash out approx $1.50 for the part, buy a programmer, plus learn how to program it, AND add passive components. If I were to use a 555 timer, I would spend about $0.15(if I didn’t use one of the many I already have), use 3 or 4 passive components, have it set up the same time or less whilst excercising my knowledge and experience of digital logic (something incredibly valuable to everyone). Really I’m getting sick of these lazy people who think the simplest thing should be done with a microcontroller ‘coz it’s ‘easier’.

        1. Try again. An LM555 costs $1.03 for a SOIC, $1.11 for a DIP in quantities of 1 at Digikey:

          Programming a microcontroller doesn’t “use up” the programmer; if you’re going to ever use one once, it’s cost is irrelevant if you use it again.

          For a difference of <40 cents, use what's easiest. Or use the low power solution. There's no right or wrong in engineering – only works or doesn't work.

          1. And I’m fully aware that programming doesn’t use up the programmer, but personally I don’t own one and using a 555 negates the need for even needing to go near one whilst keeping the cost extremely low.
            TFA states that he took approx a year to design and build this, being a studying EE he should have been able to whip this up on a breadboard in a few hours or less.

          2. got my figures a little wrong there. 19 pence works out to approx 29 cents. I could still get around 5 of these for the same price the OP paid for 1 msp430

  3. Unless you really really like leaving your closet door open, you can for the cost of wire and a small microswitch wire the light to go out when the door is shut. Simple and requires only 2 pieces of wire and 1 microswitch. Oh and a screw or two.

  4. I’d be concerned about two things: resale and insurance. Home inspectors get really nervous whenever the homeowner touches the home’s electrical system. You’d better be prepared to rip that all out and put the original gear back in when you get ready to sell the unit.

    Also, if your home ever catches on fire, be prepared to definitively prove to your insurance company that it wasn’t due to your non-UL approved gear. If your mods caused the fire, or even perhaps if they believe it may have, you might not be receiving an insurance check.

    I’m looking at doing some similar things regarding home automation, etc. But to keep everything UL approved, I’m looking at Insteon for any of the switches and wallplates. With a USB dongle and a RPi, you can add any sensors you want, but they need not be UL approved, as the approval requirements end when line voltage does; at the RPi power supply.

    1. Oh, the drawback is Insteon is MUCH more expensive than this elegant, low-cost hack. A KeypadLinc Timer and an I/O Linc Sensor kit will run you about 110 USD. But between those two items, I believe you could replicate 100% of this hack’s functionality.

      1. Are you a certified electrician or home inspector? Can you provide citations for your assertion?

        I’m not, but I think it’s more than just using a UL approved relay. There are requirements concerning separation of voltage levels and such. The whole system that uses the relay would likely have to be UL approved, not just built with UL components.

        That’s where X10, Insteon, and the like come in; they’ve gone through the underwriting process with the completed device.

  5. The fuse is in the wrong place.
    It should protect the transformer. If the secondary of the transformer fails, you could potentially have a fire on your hands.
    CFL doesn’t need fuse as it’s already protected by the fuse on the main electrical panel.

  6. I really don’t see a problem with using a µC for timing, it makes it very simple to set up different times and changing the circuit function after putting away the soldering iron. I do however not like the enormously huge wires used for the sensors, he could have gotten away with something like a 3-way strip of ribbon cable or a thin headphone extension wire, it would have let him drill a 3mm hole in the ceiling instead of the enormous hole that’s there now.

    Also there is nothing limiting the current to the sensors, if something goes wrong the sensor boards could easily heat up enough to cause a fire, there should be fuses or at least resistors on the power lines to those boards.

    Also no consideration of EMI on those long wires.

  7. Well, my bedroom closet automatic light switch went from concept to finished in about 3 hours, including drive time. I got some of that LED rope light and lined the inside of the doorway into the closet so it would illuminate fairly evenly from the front of both sides and across the top, I plugged that into an outdoor motion sensor floodlight fixture I had installed one of those screw-in-base-to-two-prong-outlet adapters, and I wired that to an extension cord that I plugged in to an outlet I had located inside the closet. The motion sensor was mounted above the doorway inside the closet pointing down so all one needs to do is waive their hand inside the closet and the rope light (which draws ridiculously low current, provides sufficient light output and doesn’t present a fire risk from heat) comes on. The turn-off timer was set so that it turns off after a short delay when no motion is sensed. I adjusted it so that if my wife or I are putting clothes away it mostly stays on and you rarely have to re-activate the light intentionally. It is angled just so that traffic outside of the boundary of the closet does not activate the light and we both got instantly accustomed to it. It just works.

    Not as elegant as the one featured here, but it is all inside the closet and nothing is visible from the outside unless, say, a clip comes off the rope light or something and it hangs in view.

Leave a Reply

Please be kind and respectful to help make the comments section excellent. (Comment Policy)

This site uses Akismet to reduce spam. Learn how your comment data is processed.