Instructables
Picture of Motion Activated AC Switch

I hate Christmas tree lights.

Well not really, I just don't enjoy having to climb under the tree every time I want to plug in or unplug the lights. In the interest of saving my sanity, I decided to build a motion activated switch that can power the lights for me. It has an integrated adjustable timer so they will stay on for as long or as short as I want. Here's a video showing the final test on the fish tank light.

 
Remove these adsRemove these ads by Signing Up

Step 1: Safety and the parts and tools list

Picture of Safety and the parts and tools list
tools.JPG

First, a word about safety. We will be working directly with AC mains voltage, so BE EXTREMELY CAREFUL!! Make sure that any time you are testing the circuit, you have your work space clear and anyone around you is aware of the danger. Also, don't burn yourself with the soldering iron. It is hot. Don't be that person.

I salvage what I need/want from whatever device I can get my hands on. Most parts are still useful as long as you take care in how you remove them from the original board. That being said, none of the parts are expensive, so it shouldn't be hard to come across them if need be. Also, many times the exact part is not absolutely required, just something that is compatible, e.g. a 2N2222 NPN BJT instead of the 2N3904 listed.

The Parts:

- 1 power transformer. Any transformer that has a step down factor of 10 will work here. We want an output of about 12-15VAC, but if your outlet supplies 220VAC, it will still work.

- 1 board mounted outlet. You can find these on the back of DVD players, home theater systems, and VCRs.

- 1 rubber grommet. This one came with the AC power cable attached to the transformer and is used to secure the cable to the housing. Very handy if you can get one.

- AC power cable. We don't need a grounded cable here, so 2 wires will do fine.

- board pins as needed/desired for connecting AC lines. You can also solder directly to the copper pads but it may not be as secure.

- 1 board mounted fuse holder. I used a 5X20mm fuse.

- 1 fuse rated for slightly less than the relay max current rating. Mine is a 250VAC 4A, slow blow.

- 1 555 timer IC with 8-pin socket. Any brand will work.

- 1 7809 +9VDC voltage regulator. You can use whatever regulator you have so long as it matches the DC input rating on your relay switch. You also don't want a 7909 regulator as it will provide -9VDC, which you don't want.

- 1 Parallax PIR sensor. Found mine at radioshack for about $10.

- 1 2N3904 bipolar junction transistor, or BJT. Any NPN BJT should work here.

- 4 1N4001 rectifying diodes. You can also get a bridge rectifier if you want, since that is what we are going to build.

- 3 capacitors: 1 0.01uF (103) ceramic disc; 1 470uF electrolytic; 1 large electrolytic. I used a 1000uF. The large electrolytic will be used to run the timer, so the bigger it is, the longer your max time can be.

- 4 resistors: 2 1k; 1 4.7k; 1 10k

- 1 potentiometer. Mine is a 4 megaOhm pot. This pot will allow for adjusting the timer. With the 1000uF cap, mine will run for about 2.5 hours.

- 1 9VDC relay. The coil voltage should match the regulator voltage. The switch portion of the relay needs to have a decently high current rating since we will be running AC current directly through here to the device we want to power. Mine is rated for 250VAC 5A.

- 1 LED and 1k resistor (optional, LED not pictured). Used mostly for testing, I didn't keep it for the final build.

- screws, wires, heat shrink, glue as needed

- plastic project enclosure

- printed PCB

The Tools:

- Digilent Analog Discovery. Highly recommended as it will allow you to verify circuit function using the built in oscilloscope.

- soldering iron and solder. I use a 40W for just about everything.

- wire cutter/stripper, pliers, hobby knife, screwdriver

- breadboard for testing

- digital multimeter

- saw and/or rotary tool (not pictured)

how could I adjust the working time of the circuit to 15-20 minutes?
brmarcum (author)  rameezkoya00728 days ago
You can get anywhere from <1 minute to over 2 hours with the schematic as is. Look at the schematic to Step 5. The potentiometer (P1) and the 1000uF cap (C3) determine the timing. Changing either one for a component with a smaller value will shorten the time. The large 4M pot makes getting a precise time difficult since a small change on the pot will result in a large change in the timer output, but you can get 15-20 minutes as is. You just have to test different values to get it where you want it.
I have a doubt.
Help me please.
can I connect two PIR sensor in the circuit ?.
I yes ,how?
If it's possible I could place those sensors on the the either sides of my garden pavement.
brmarcum (author)  rameezkoya00728 days ago
Yes absolutely. The best way I can think of to do it is to pass the two inputs from the two PIR sensors through an OR gate on an IC (like this one). That way, when either sensor triggers, the timer starts and the lights go on.
bcraun3 months ago

Just curious; what is the max on time when using the 4M ohm adjustable resistor? Is the point to keep the PIR in re-trigger mode constantly with movement in the room, or to maintain the on state using the timer?

Thanks.

brmarcum (author)  bcraun3 months ago
In theory the timer could run forever. The threshold pin on the 555 requires a certain voltage level to allow the output pin to go high. A larger cap/pot combo will give a longer time. This particular build ran for about 2.5 hours. I have another project I built that would run for about 4 hours.
Unfortunately the timer isn't able to reset to zero every time it triggers. Once it triggers, it's on and will run until the cap runs out.
bcraun brmarcum3 months ago
Gotcha. So, aside from the RC combination, the theory is that once the PIR triggers the circuit, it's active for around 2.5 hours. At that point, any movement in the room would re-trigger for another 2.5 hours...and so on? So the assumption is that someone will move at least every 2.5 hours to keep the lights on?
brmarcum (author)  bcraun3 months ago
Yes. Once it triggers, it ignores all subsequent signals from the PIR until the cap runs out, and then resets back to zero. It's not ideal, but it will work
DBoulanger3 months ago

After re-reading your intro, which described your main objective, with pretty much the same parts and a few more, you could potentially consider creating some sort of toggling circuit, with the 555 and a LDR, which could be controlled via a small laser light, like the ones we have on some keychains.

If you want, you can also go for an IR led approach, like the ones in TV sets, DVD players, etc..., allowing you to toggle the circuit with your current TV remote control, or mostly any remote control for that matter.

In either case, strategic positionning of the LDR or IR led is mandatory to prevent false triggering by external lighting, naturally.

Finally, you could also consider a RF switch. The beauty of that little beast is that it can be completely hidden and you can even toggle the switch without having to aim at the receiver. Plus, it isn't affected by the light, which could be considered as an advantage.

Anyhow, you have plenty of choices, so just let your imagination guide you !

Have fun !

brmarcum (author)  DBoulanger3 months ago
I'm really intrigued by those ideas. LEDs can actually be used as phototransistors as well. Forrest Mimms did a lot of pioneering work in that area many years ago.
matsk3 months ago

I love this easy electronic project with a practical usage!
And my 20 cent improvments would be to change the PIR to a PIR with adjustable sensitivity and delay like http://tinyurl.com/opb5sqr or equal.

That would make the 555 obsolete.


brmarcum (author)  matsk3 months ago
Thank you for your advice. I have no experience with that particular sensor, but I have been warned to be wary of really low price PIRs. If it is working for you, that's great. I may try it with something else.
matsk brmarcum3 months ago

The PIR's i have bougth on ebay have two different pin layout. I have bougth PIR's from five different seller on ebay and I haven't found "bad quality". The schematic is mostly the same a D203 sensor and a LM324 OP amp or equal.

DBoulanger3 months ago

Nicely done. You obviously have good soldering skills. Personally, I kind of dislike those 30-40-50W soldering irons. I treated myself and got an Hakko FX888D soldering station. It's a real gem for the electronic enthousiast that I am.

Concerning the PIR sensor, it must be understood that this little beast is actually activated by a variation of heat, not really motion as some of us are lead to believe with the advertisements.

The PIR is a "Passive Infrared sensor" device that reacts to small variations of heat close to it (within 10 feet or so). I discovered it when I installed my so called "motion detector" at the top portion of my garage door, with the sensor pointing down towards the floor.

When my dogs are going outside or coming back, the sensor activates, letting me know with flashing leds that something/someone crossed the doorstep.

However, when the door is left opened, the sensor also reacts to air drafts. If there is some air flow, of warmer or cooler air than the air actually being "monitored", the sensor may activate despite there is no human / animal movement / motion.

Globally, that PIR sensor takes an infrared snapshot of the area it's pointing to and if there is any sufficient heat change detected, would it be because of a human, an animal or simply air flow, the device will trigger.

Nothing really scientific, but might be interesting to know, either to adjust accordingly and prevent false triggering, or simply incorporate this "feature" in one of your future project.

Regards.

brmarcum (author)  DBoulanger3 months ago
Thank you for the compliment and for explaining how PIR sensors work. You are absolutely correct and this project could be a bit tricky in a home with pets. Most PIRs come with sensitivity adjustments, but they are not all created equal.
ASCAS made it!3 months ago

Love it! That PIR motion sensing is quite useful. I added your PIR motion sensing idea to my DIY Home Automation Box. Since there's no more room for the PIR, I hacked my dollar store Motion-Door chime and added a $3 RF module. I must say, it makes life more convenient ! Thanks for the wonderful idea! Cheers! :D

DSC_0160as.jpg
brmarcum (author)  ASCAS3 months ago
Very glad to hear that you were able to improve your own project. Do you have a link to it?
witkowski83 months ago

Pro instructions, great

tsaltzman3 months ago

I really like your idea and what you did but if you had a switch outlet in the room where your xmas tree is you could just replace the wall switch with a motion one and put a time between the wall outlet and xmas tree...but making things is so much better. ;)

brmarcum (author)  tsaltzman3 months ago
Well my wife wants the tree on the other side of the room from that switch. So I get to have fun building.
transistor23 months ago
do you know how to switch from DC current to ac ?
brmarcum (author)  transistor23 months ago

DC to AC inversion is not something I've used with any project so far, though I do have a current project that will require it, so I'm doing my research into that as well. There are a few methods I've found so far: using a 555 timer IC and some transistors, using only transistors, or using a relay. All three look promising, it just depends on the requirements for the circuit you want to build and the space/weight considerations you have available and/or want to take up.

gada8883 months ago

Thanks for your info.l love the 'parts kit'and 'discovery',but i am not in USA.so the discount bundle is not available to me.who can help me to get them as student or academic special i pay him extra through paypal.

gada8883 months ago

Thanks for your feedback.i am thinking of taking one.Do you use simulators to assist you design? Electronics calculation is also my headache.What book you find is most useful in this field.I am a newbie need advice.

brmarcum (author)  gada8883 months ago

I have found simulators to be very useful in very specific applications, though not in the large majority of the time. I usually just build and go with it, but that comes with some experience.

As far as electronics calculations go, the best way to get it is to just do it. That being said, I recommend http://digilentinc.com/Classroom/RealAnalog/. This is one of the better (but not only) online resources for learning analog electronics. It's laid out like a university level EE course, starting at the basics and going through much more advanced concepts.

I also recommend http://learn.digilentinc.com/. Click on "Browse Individual Projects" on the left, then on "Analog" in the green box toward the top. The projects are pretty focused on gaining product knowledge, but on the right hand side you will see several buttons for related topics, like "voltage" or "current". Click on those to get a more general idea of those concepts. This site will eventually contain a similar course layout as the previous site, but that is still being developed.

As far as printed books go, as soon as I get mine back from my friend, I will let you know.

padbravo3 months ago

This is one of the best explained instructables that I've found on this site (year from now).
And that is because it explains not only the construction, but the theory behind each steep, and in electronics, this is not that easy.

BTW:
link to find this device? (the analog discovery scope)

brmarcum (author)  padbravo3 months ago
Wow, thank you. That's very kind.
The Discovery is listed as the first tool in step one. The name is highlighted, which is a link to the product page.
gada8883 months ago

Very nice informative tutorial.by the way,is Digilent analog discovery a worthwhile investment. I own a traditional bulky analog oscilloscope,but i want on e better or carry more functions.

brmarcum (author)  gada8883 months ago
I've been using the analog discovery for several months, both for school and work. In the interest of full disclosure, I am an intern at Digilent, but I was using it before that and have found it to be a remarkable piece of equipment. It easily takes the place of thousands of dollars of benchtop equipment, like an o-scope, spectrum analyzer, power supply, & logic analyzer. It does have limitations as it is powered by USB, but for everything I've done, it has performed beautifully. If you do need more power or scope channels than the discovery can provide, check out the Electronic Explorer Board, also from Digilent.
tl;dr: yes, definitely worth it.

What a great idea to save yourself the hassle of climbing under the tree to turn the lights on and off! I hate doing that too since I'm always afraid I'm going to knock it over or break the ornaments near the bottom of the tree.

Exactly. This also keeps my kids safe, since we know how much 3-5 year olds love to help. I love the help, but not plugging things into the wall socket while squirreling around under the tree.