Intro: Motion Detector Activated Vanity Light
I bought an infrared motion detector unit on eBay for $1.50 and decided to put it to good use. I could have made my own motion detector board, but at $1.50 (which includes 2 trim pots for adjusting the sensitivity and shut off timer) it wouldn’t even be worth the time it would take to solder a home build together. I live in a very small studio apartment (1 kitchen/bathroom + 1 living/bedroom). I enter my apartment through the kitchen. There are several lights, but the vanity light over the sink seems to be on the most. I notice it burning for no reason while I’m in the living room and I end up turning it off, just to turn it on again a few minutes later when I’m back in the kitchen. It’s pretty efficient, using a 3 Watt LED bulb, but there’s a lot of empty space behind it for gadgets, so it was time for a mod ;-) This should work for any light that has sufficient room for parts.
Step 1: Find the Right Parts
The Motion detector runs on a variety of DC voltages and I happened to have a very old NiMH laptop battery that I was planning to throw away. The laptop is long gone, it wasn’t holding a charge and the technology is outdated anyway. I opened up the case to find 10, 3800 mAh, 1.2v cells. I built the NiMH battery charger shown at the beginning of the schematic just to see if I could get anything out of the old batteries. After 24 hours and some testing, I managed to salvage 6 of them. Cutting the connections and re-soldering, I ended up with a 7.2v battery pack (be careful if you do this – heat sometimes makes them explode). I taped the case back together and soldered on a wire with a plug on it that I salvaged from an old laser printer. I could have run the motion detector just on that battery (it only draws 50 microamps) but NiMH batteries are notorious because they drain themselves at around 1% per day just in storage. After 2 months of inactivity, they’re useless. Since I didn’t feel like taking the lamp apart to charge the batteries, I integrated the battery charger into my build. Since the idea was to use the detector to switch on the lamp, I figured I could use the mains to charge the batteries when the light is on.
Step 2: Parts List
IR Motion Detector (eBay) $1.50
9v DC, 240v AC, 7A Relay $0.74
LM317T Volt Regulator $0.23
2n7000 N-Channel Mosfet $0.10
Aluminum Heat Sink $0.30
10Ω 5W Resistor $0.25
Glass-Epoxy Prototyping PCB 7x5cm $0.49
DG350 Screw Terminal Block (optional) $0.20
330uF, 35v Electrolytic Capacitor (from junk parts) $0.00
Transformer (old wall wart) $0.00
Batteries (old lap top battery) $0.00
2 - 1n4148 Diodes (pulled from old printer) $0.00
1n4007 Diode (from printer) $0.00
Cables, headers, connectors (from printer) $0.00
I buy most of my parts at Tayda Electronics (highly recommended).
Step 3: The Circuit
The LM317 charging circuit uses low amperage, constant current to trickle charge the batteries. More info here: http://www.talkingelectronics.com/projects/ChargingNiMH/ChargingNiMH.html For the amount of time I’ll be charging the batteries, there should be no danger of overcharging them. If I were only running the charger, it would provide 120 milliamps at 8.4 volts (that’s the 7.2v from the batteries detected by the LM317’s adjust pin, plus the regulator’s minimum output pin voltage of 1.2v). Theoretically, I could charge my battery pack with that circuit in 32 hours. In my case, there’s also a drain of around 45 milliamps when the relay is on, so I only have 75mA left to charge the batteries when the light is on. Since I only want to keep them topped up, this should be sufficient unless I leave for a two month vacation. Here’s a little math on that subject:
Drain on batteries when the light is not on: 50 microamps per hour (1.2 milliamps per day - motion detector standby) + 1% of the 3.8 amp battery pack per day of storage (38 milliamps). That means, I lose a total of 39.2 milliamps from the battery pack for every day it is connected and not charging. When the light (and charging circuit) is on, the batteries will be trickle charged at 75 milliamps per hour, so theoretically I should make up for a day of non use if the light is on for around 32 minutes per day. I’ll post an update if this doesn’t work out in the real world, but so far it’s been working as planned. After all this, you might ask why I didn’t just use the transformer to power the motion detector without the battery. Well, I wanted it to be energy efficient and running the transformer 24/7 would use more energy than the light itself. In that case, why not use a more efficient switch mode power supply? I simply didn’t have one on hand that met my specifications for the project.
Step 4: Cut a Hole in Your Unit
Since the motion detector has a round plastic Fresnel lens with a square base, I had a choice of hole size. I decided to make a square hole using my moto tool. I could have made a round hole but the plastic case on my vanity light is pretty thick, so only a portion of the lens would stick out of the hole. As it turned out, the thickness of the vanity light housing is about the same thickness as the Fresnel lens base, so it fits almost flush. There are two screw holes in the motion detector board but they’re not threaded. Since I couldn’t find the right size machine bolts with nuts, I just used two tiny wood screws and screwed them in from the inside of the lamp. The lamp housing holds the screws in place without nuts, but it does mean you can see the ends of the screws from the outside of the vanity lamp. I think it still looks ok.
Step 5: Circuit Schematic Details
D1 and D2 may be unnecessary. D1 was included in one of the battery charging circuits that I found on the net - possibly as reverse polarity protection. I included D2 to insure that the 10 Ohm resistor would have no possibility to drain my batteries, but I’m not sure that would have been electronically possible in this case. Since the 1n4148s were free for me, I didn’t worry too much about the logistics. By the way, I’m using a 5W resistor because I don’t have a 1W, 10 Ohm resistor. There should be 1 Watt dissipating through the resistor in my circuit, although that will vary with the battery voltage. The value for C1 is not critical; just make sure the voltage it can handle is above what you would expect in your circuit. In my case, I can expect a maximum of around 17v so the 35v, 330uF capacitor that I found in my junk box is plenty. Anything over about 100uF would be ok, and the whole circuit would probably still work without the cap but the voltages would be a bit unstable. D3 is absolutely necessary to prevent flyback voltage from the relay coil burning up your transistor, but my 1n4007, 1000v rectifier diode is overkill. There are many others that will do the job just fine. If the batteries are fairly low, the LM317 gets pretty hot, so I would advise using a heat sink. In my case, the LM317 is dissipating around 8.6 volts x .12 amps (or 1.032 Watts). When the batteries are lower, the LM317 gets hotter because it’s blocking more current and voltage from the transformer. I measured mine at around 50ºc with the heat sink (sorry Fahrenheit freaks :-) while it was working just as a charger alone. In the complete light circuit, it’s just warm to the touch (with the heat sink). I didn’t want to melt anything. I salvaged my transformer from an old wall wart cell phone charger. It was originally designed to hook up to a charging cradle including electronics to charge the phone. Inside my wall wart, there was only a transformer and a bridge rectifier so I added C1 to stabilize the voltage. If you’re using a regulated voltage source, you can ignore the transformer, the bridge rectifier and the capacitor in my circuit. I’m using the 2N7000 as a switch to activate the relay. I’m a bit surprised that the 3.3v signal from the detector was enough, but it works fine. Be sure to connect the negative side of the load to the drain when using N-Channel MOSFETs. I chose a 9v relay because the circuit provides 8.4 volts when the light is on. That is sufficient for the relay coil to remain activated. Surprisingly, 7 volts is also enough, so I got lucky there too.
Step 6: Mounting the Electronics
This step will only make sense if you happen to have a vanity light that is similar to mine, so I won't spend too much time on explanations here. Basically, I just hooked up the components, hot glued the heavy parts to the case so they wouldn't rattle around, and screwed in the motion sensor. If something goes wrong, I can easily remove the battery pack, the transformer or the circuit board for troubleshooting. The vanity light hooks up to the mains like any other lamp. I'm assuming you know how that works in your country. I'm in Europe, so I'm running it with the 230v a.c. mains. The vanity light includes a grounded socket for hair dryers and such as well as a switch which I could still use to switch off the light and bypass the sensor.
I’ve been running the motion detector light for a few days and there’s no more fumbling around for the light switch when I return home in the middle of the night. I hope you enjoyed the build. If you’re wondering why my vanity light has a melted spot, so am I. That’s the reason why the previous owner gave it to me. It was like that long before I got it and has nothing to do with the electronics I added. Watch the video ;-)