A simple night light

In northern Norway it is dark almost all day in the winter, and I had an idea to make a simple night light that would turn automatically when ever it was needed. Perfect for a smooth transition between the pitch dark bedroom and the flood lighted bathroom. A simple motion detector connected to a low power LED should be able to light the hallway sufficiently to avoid any danger related to stumbling around in the dark.

The parts

The night light should be as simple as possible. I considered building my own motion detector, using a micro controller and IR LED and receiver. This, as I found out in so many projects, was overkill and simple solutions already exist. I bought a PIR sensor (Passive Infrared Sensor) from eBay, paying $2 for two of them.

PIR sensor

I also bought 10 1W LEDs for about $2.


I am not sure how much power the PIR can deliver, so I might need a transistor to run current through the LED. The BC337 is rated at 800mA continuously, which should be more than enough for the 1W LED.

BC337 Transistor

The casing is a small plastic box I had lying around.

The encasing

And I needed a battery pack to power the whole thing


Planning the setup

During engineering school I was taught how to use OrCad. This corporate, pay-till-your-fingers-bleed, awful program that had all kinds of backward solutions. A program where Ctrl-z was the shortcut to mess up something important with no shortcut to get it back. Where you had to spend 2 hours drawing a new component because it spat out error messages that might as well have been in Arabic because it gave no sense.

Luckily, the open source community has made a awesome, free, easy to use, alternative. They even have the support and love of CERNKiCad was used extensively  through the bachelor thesis, and I came to love it.

A quick schematic drawing in KiCad gives the project an overview, and simplifies any troubleshooting. If you are a bit rusty it also helps getting the right component in the right place. Those NPN/PNP always gets mixed up!

PIR sensor technical drawing

Testing the setup

Instead of gluing and soldering the whole thing and hoping it works I prefer to test the setup in a breadboard first. Sometimes, especially when you are very sure you know how stuff works, it does not do what you thought it would. A breadboard test is a good way to sort out any brain farts you had while thinking of the solution.

The breadboard testing is a crucial part of any project like this. A missed connection, a short, LED connected backwards... Any small mistake is easy to fix while nothing is soldered or glued in place.
The breadboard testing is a crucial part of any project like this. A missed connection, a short, LED connected backwards… Any small mistake is easy to fix while nothing is soldered or glued in place.

After connecting 4,5V to GND and ground to VCC, realizing that I made that connection mistake and fixing it, it was time to turn on the power supply. The LED turns on when the PIR sensor detects motion, and turns off again shortly after. The current draw at 4,5V was about 110mA with the LED on, and 0mA while off. This of course is raw numbers read of the power supply, but this kind of project doesn’t really need 100% exact measurements.

One problem discovered was the ON-time for the LED. The PIR sensor got two pot-meters that I believe should control sensitivity and time ON. The sensitivity one seems to do the job at any setting. The timer function though seems to be “on for a second” or “on forever”. I will need to test this a bit further, or test with the other PIR sensor in case this one is flawed. Either way, as long as it is motion in from of the sensor the light will stay on.

Next up is assembling the thing, and testing it in the hallway at night.


Leave a Reply

Your email address will not be published. Required fields are marked *