DIY Automatic Night Light

1,860

17

2

About: I’m an electrical engineer with too many hobbies.

Make a simple night light that turns on in the dark and off in the light!

Step 1: SAFETY!!!

Warning: this project uses a circuit known as a "capacitve dropper" or a "transformerless power supply" to step the 120vac from the wall outlet down to the 12.8vdc needed for the LEDs. These types of power supplies ARE NOT ISOLATED from the wall outlet! This means if you touch part of this circuit and something that is grounded you can get shocked!!! This circuit is safe to use if and only if it is built into a plastic box without any exposed wires.

It is also important to use an isolation transformer if you are going to be probing around in this circuit with an oscilloscope. Without the isolation transformer you stand a good chance of toasting up your scope.

This circuit is only as safe as you are, please be careful.

Step 2: How Does It Work?

Before we can build this night light we must understand how it does what it does.

The general idea is as follows: the first part of this circuit is a half wave rectified capacitive dropper who's output averages 7.5ma. This is used to feed four 3.2v warm white LEDs. When enough light hits the light sensor the output to the LEDs is shorted out and the 7.5ma flows through the transistor instead of lighting the LEDs.

If you are interested in how each component interacts see below:

The input is the two wire pads on the left of the schematic labeled AC1 and AC2. These pads accept the 120vac from the wall outlet. We need a way to limit the current flowing through this circuit to something the LEDs can handle.

This current limiting could be done by a resistor but the resistor would waste a lot of power as heat. This is just wasteful so we'll use a capacitor to limit the current instead. This is where the circuit gets the name "capacitve dropper". How does the capacitor limit current?

C1 limits the current to roughly 15ma. The way C1 does this is by what's called impedance. Explaining what impedance is and where it comes from beyond the scope of this instructable but just think of impedance as resistance that changes with frequency. Impedance for a capacitor is given by the equation: Xc = 1 / (2 pi F C) where Xc is the impedance in ohms, pi is 3.14, F is the AC frequency 60Hz in the US, C is the capacitance if Farads. We need 15ma max so after some higher level math C1 ended up being 0.33uF class X capacitor. Current limiting capacitors should be class X capacitors as they are made to fail open and not burn the place down.

R1 is there to discharge C1 when the night light is unplugged so no one gets shocked off the prongs. It was chosen to be a 470k ohm 1/4 watt resistor but anything from 470k to 1meg would work.

R2 is a 470 ohm resistor to limit the surge current that could flow through the circuit when the night light is first plugged in.

D2 is a half wave rectifier that charges C2 with a 15ma pulse every time AC1 goes positive. Since AC1 is positive only half the time the average current through D2 is 7.5ma. 7.5ma was found to light up the LEDs bright enough for a night light while keeping power consumption to a minimum.

D1 is needed to let C1 charge up the opposite way every time AC1 goes negative. If D1 wasn't here C1 would only send one 15ma pulse through D2 but with D1 the cycle of pulses can continue forever.

C2 is a 470uF electrolytic capacitor that smooths out the current pulses from D2 so that the LEDs don't flicker at 60Hz.

Pads CDS1 and CDS2 are where the CDS cell connects to the pcb. A CDS cell is a special resistor who's resistance goes down as more and more light is shown on it. This CDS cell works toturn transistor Q1 and short out C2. Because capacitive droppers are current limited supplies their outputs can be shorted together without harm.

R3 is there to increase the amount of light needed to turn Q1 on and so if you increase R3 the room will need to be darker for the light to turn on. A value of 4.7k ohm seems to be just right.

Finally LED+ and LED- are the pads to connect the string of 4 LEDs.

Step 3: PCB

While this circuit can be built on perf-board it is best to make a real printed circuit board for this as wiring errors end really, really badly when plugging things into the wall.

I designed a single sided PCB that is roughly 1in X 2in so that it would fit in most common wall wart cases.

One thing to keep in mind is to leave lots of space between pads and traces when dealing with 120v or more. Arcing between traces is as fun as you think it would be.

Step 4: Parts

1x cheap wall wart switch mode power supply (can be any voltage we just want a plastic case with prongs)

1x pcb

1x 0.33uF class x capacitor

2x 1N4007 diodes

1x 470k ohm resistor

1x 470 ohm resistor

1x 4.7k ohm resistor

1x 2N3904 NPN transistor

1x 470uF 16v electrolytic capacitor

1x CDS cell

4x 5mm warm white LEDs

NOTE: all resistors are 1/4 watt

Step 5: Open the Case

Pry open the wall wart case using a flat tip screwdriver. Most cheap switch mode ones off ebay pop apart easily if the screwdriver is started where the cord comes out.

Step 6: Remove the PCB

Unsolder the two wires that connect the switch mode pcb to the prongs. These are usually the cheapest wire around so we will replace them with better wires later. Toss the pcb in the junk box for future projects.

Step 7: Drill Holes

First drill a test hole in a scrap piece of plastic to make sure the LEDs will fit. It should be a snug fit. Once the correct bit has been found drill 4 holes in the outer half of the case for the LEDs one on the two sides, top and front seem to light up a room pretty well.

Drill one hole in the front for the CDS cell. This hole should be spaced away from the LEDs so the light from the LEDs doesn't interfere with it.

Step 8: Glue in the LEDs

Spread a small bead of super glue around each LED and press it into the hole. Gel super glue seems to work the best for this. Make a point to have the positive lead of one LED point towards the negative lead of the next closest LED.

Step 9: Wire LEDs in Series

Use small pieces of wire and needle nose pliers to solder the LEDs in series so that the positive of one connects to the negative of the other. Route the leads around the perimeter of the case to prevent shorts. Then it's a good idea to apply some hot glue to keep the wires from vibrating.

Finally glue in the CDS cell.

Step 10: Attach Wires

Solder a wire to the remaining LED leads. A red one to the positive lead on the first LED and a black one to the negative lead on the last LED in the series. Shrink tubing should be applied over the connections to prevent shorts.

The CDS cell's leads are long enough that they don't require wires to be added on but there is a problem. The problem is that the leads aren't insolated so they could short out on something when the case is put together. to fix this cut two pieces of spaghetti tubing (thin insulating tubing for just such occasions) and slide it over the leads as seen in the pictures.

Step 11: Assemble the PCB

Take your time and watch those color bands when placing the resistors in the circuit. All three differ by only one band but the results would be disastrous if one was put in the wrong place. It's a good idea to double check your work here because in circuits running on 120v when something goes wrong it goes VERY wrong!

Step 12: Solder Wire Onto Prongs

Solder two 1in long solid core hook up wires to the prongs in the back of the case.

Step 13: Double Check EVERYTHING!

At this point you should have:

Two wires soldered to the prongs on the back of the wall wart's case

One completed PCB

Four LEDs glued and wired into the front of the wall wart case with two insulated CDS cell leads sticking out and a positive and a negative wire sticking out from the LED string.

Step 14: Solder It Together

It is time for the final assembly...

All wires get put through the pcb holes from the top and soldered on the bottom.Then the circuit board is rotated as shown in the pictures and the two halves of the case snapped back together. The force of the compressed solid core hook up wires is enough to hold the PCB in place in the bottom of the case as shown. However if gluing it down there with more hot glue makes you feel better go for it.

Step 15: TEST IT!!!!!!!!

OK, the nerve racking part I recommend finding a power strip to plug it into and THEN plug the power strip into the wall. This way if something went wrong in assembly it doesn't go up in flames in your hand!

If all goes well it should just sit there. Turn off the lights or cover the CDS cell with a piece of black electrical tape and the LEDs should light up.

Congratulations you made a night light!

PCB Contest

Participated in the
PCB Contest

Share

    Recommendations

    • Fandom Contest

      Fandom Contest
    • Sensors Contest

      Sensors Contest
    • Pets Challenge

      Pets Challenge

    2 Discussions

    0
    None
    facedeath1966

    5 months ago

    Great project. Enjoyed the circuit explanations. Could easily recalculate for different voltage or frequency. Learned alot here.
    You talk about type X for a fail open cap. Would it be a class Y Cap instead?
    Looking forward to build it.
    Regards

    1 reply
    0
    None
    Iain Pfacedeath1966

    Reply 5 months ago

    I found a good article written by an engineeer at Kemet a well known capacitor manufaturer: http://www.nxtbook.com/nxtbooks/hearst/ep1114/index.php#/20 The article spells it out better than I can because they are the capacitor experts and I am not but I will try to summerize. Both X and Y classed capacitors are designed to be self healing and fail open because if either failed short curcuit bad things would happen. The difference is in just how safe they have to be. If a class X cap fails to self heal or it arcs over in a power surge the worst it could do is short out the line and burn the place down. But it wouldn’t shock the user so it doesn’t have to meet as strict build standards as class Y caps do. Class Y caps are designed to separate a person from the line voltage so a failure to self heal would result in electric shock, but no house fire.

    So basicly both are designed to fail open because class X failing shorted could result in fire while class Y failing shorted could result in somebody getting shocked.

    I hope this helps clear things up a little.