Introduction: Night Light Motion & Darkness Sensing - No Micro
This instructable is about preventing you from stubbing your toe when walking through a dark room. You could say it is for your own safety if you get up at night and try to reach the door safely. Of course you could use a bedside lamp or the main lights because you have a switch right next to you, but how confortable is it, to dazzle your eyes with a 60W light bulb when you just woke up?
It´s about a LED-strip you mount underneath your bed that is controlled by two sensors which detect motion and the level of darkness in your room. It will run at low power and brightness to provide a very pleasant light at night. There is also the capability for controlling the brightness-threshold to make it suitable for every environment. No microcontroller is needed to conduct this project. That reduces the number of necessary components and complexity. Furthermore it, it is a quite easy task if you already have some knowledge in electronics hardware circuitry.
Step 1: Function Principle & Components
The basic working principle of this light is that it has two Mosfet in series with a LED. The Mosfets, which need to be logic level type - explanation later on - are turned on by two different subcircuits of which one responds to darkness and the other one to movement. If only one of them is sensed only one transistor is turned on and the other one still blocks the current flow through the LED. This combination is quite essential as you would waste battery power if you activate the light during the day or with no motion at night. The components and the cirucuit were chosen in a way that you are able to optimize parameters for your own location and the conditions there.
Furthermore a housing was 3-D printed to fit in the components, which is not really neccessary for functionality reasons but has a practical purpose.
UPDATE: A new version of the housing was designed after I published this post. The 3D-printed housing now contains also the LEDs which makes it a "whole-in-one" solution. The pictures from the introduction of this post (new model) differ from the ones in step7 "Power supply and housing" (old model).
Bill of materials:
4x 1.5V batteries
1x GL5516 - LDR
1x 1 MOhm fixed resistor (R1)
1x 100 kOhm potentiometer
1x 100 kOhm fixed resistor (R2)
1x TS393CD - dual voltage comparator
1x HC-SR501 - PIR motion sensor
1x 2 kOhm fixed resistor (R6)
2x 220 Ohm fixed resistor (R3&R4)
2x IRLZ34N n-channel Mosfet
4x cable lugs flat
4x cable lugs (opposite part)
Step 2: Sensing Brightness
To sense the brightness of the room I used a light dependent resistor (LDR). I created a voltage divider with a 1MOhm fixed resistor. This is necessary because in darkness the resistance of the LDR reaches similar magnitudes. The voltage drop across the LDR is proportional to the 'darkness'.
Step 3: Setting Up Reference Voltage for Darkness Threshold
The night light shall shine when a certain threshold of darkness is exceeded. The output of the LDR voltage divider needs to be compared to a certain reference. For this purpose a second voltage divider is used. One of its resistances is a potentiometer. That makes the threshold voltage (proportional to darkness) modifiable. The potentiometer (R_pot) has a maximum resistance of 100 kOhm. The fixed resistor (R2) is 100 kOhm as well.
Step 4: Brightness Dependent Switch
The voltages of the two described voltage dividers are fed into the operational amplifier. The LDR signal is connected to the inverting input and the reference signal to the non-inverting input. The OpAmp doesn´t have a feedback loop, which means it will amplify the difference of the two inputs by magnitudes of more than 10E+05 and thus operate as a comparator. If the voltage at the inverting input is higher compared to the other one, it will connect its output pin to the upper rail (Vcc) and hence turn on the Mosfet Q1. The opposite case will produce ground potential at the comparators output pin which turns off the Mosfet. In fact there is a small region where the comparator will output something between GND and Vcc. That happens when both voltages are almost the same value. This region might have the effect to make the LED´s shine less bright.
The chosen TS393 OpAmp is a dual voltge comparator. Other suitable and possibly cheaper ones can be used as well. The TS393 just was a leftover from an old project.
Step 5: Motion Detection
The HC-SR501 passive infrared sensor is a very simple solution here. It has a microcontroller built on it which does the detection in fact. It has two pin for supply (Vcc and GND) and one output pin. The output voltage is 3.3V why in fact I had to use the logic-level Mosfet type. The logic level type ensures that the Mosfet is driven in its saturation region with only 3.3V. The PIR sensor consists of several pyroelectrical elements which respond with a change in voltage to infrared radiation that is transmitted by human bodies, for example. That also means it might detect things like cold heating radiotors that are flooded with hot water. You should check the environmental circumstances and choose the orientation of the sensor accordingly. The angle of observation is limited to 120°. It has two trimmers you can use to increase the sensitivity and the delay time. You can change sensitivity to increase the range of the area you want to observe. The delay trimmer can be used to adjust the time for which the sensor outputs a logic high level.
In the final version of the wiring diagram you can see that between the sensors output and the gate of Q2 there is a resistor in series to limit the current drawn from the sensor (R4=220 Ohm).
Step 6: Electronics Assembly
After understanding each components functionality, the whole circuit can be build up. This should be done on a breadboard first! If you start with assembling it on a circuit board it will be more tricky to change or to optimize the circuit afterwards. In fact you can see from the picture of my circuit board that I did some rework and thus it looks a little messy.
The comparator output needs to be equipped with a pull-up resistor R6 (2 kOhm) - if you are using a different comparator then make sure to check the datasheet. An additional resistor R3 is placed between comparator and Mosfet Q1 for the same reason as described for the PIR. The resistance R5 is dependent on your LED. In this case a short piece of LED stript was used. It has the LEDs as well as the resistor R5 already built in. Thus in my case R5 is not assembled.
Step 7: Power Supply and Housing
UPDATE: The housing shown at the very beginning of this post is a redesign. It was done in order to have a whole-in-one solution. The LEDs shine from the inside through a "transparent" plastic layer. If this is not applicable for you, the first concept of the first prototype is shown here in this step. (If there is interest in the new design, I can attach it as well)
As mentioned earlier, four AAA 1.5V batteries will power the system. In fact it might be more pleasent to you to use one 9V battery and put a voltage regulator in front of the whole circuit. Then you also do not have to 3-D print a battery housing which connects to the batteries by cable lugs.
The housing is a first simple prototype and has some holes for the sensors. In the very first picture you can see the big hole in front for the motion sensor and the left upper hole for the LDR. The LED strip should be outstide of the housing with same distance to it as it might influence the LDR.
Participated in the
Battery Powered Contest
2 years ago
it looks like an interesting project, I'll looking forward to do it on my way but keeping your concept, thanks for the info
Reply 2 years ago
also i cant see the all-in-one design for the enclosure, maybe you could upload it or indicate where it is if you already did it
2 years ago on Step 7
Really cool project! Thanks for updating the housing, new one looks really cool and much smaller! I also prefer the new all in one concept, definitely gonna build one for myself :)
PS: Also a great xmas gift!
Reply 2 years ago
Thanks mate, I appreciate that
Question 2 years ago on Step 6
I cannot find a photo of your circuit board. The text included the statement "...you can see from my circuit board..."
The project sounds great, especially not using a microcontroller! Can you add a photo of your circuit board?
Answer 2 years ago
I added two pictures in the 'electronics assembly' step. If you want a picture from the bottom I can share it as well, but it is a mess :D I made many reworks to optimize and hence desolder / solder many things.
Reply 2 years ago
Thank you! This is easier to understand.
Question 2 years ago
I am not knowledgable in electronics hardware circuitry, but this is too cool of an idea to bypass. This will be my first electronics project attempted. You wouldn't happen to have a 3-D pattern file that you could share, would you? (Old and learning.) Useful ideas are the best! Thanks!
Answer 2 years ago
Sure! I will add it to the article today evening when I get home to my laptop. Make sure to check out the placement of the 4 spikes on which the board sits. It is designed for the mounting holes of the board I used. Maybe you have to adapt it a little.
2 years ago
Nice project; great use of the comparator as well.
2 years ago
Well done. I like the subtleness of the light under the bed.