I built this low-power staircase night lamp with two infrared motion sensors so I can install a single device, half way in the staircase, and have it triggered either by someone going up or coming down the stairs. I also made my design very low power (50 uAh avg per day) so a 500 mAh battery can power it for close to a year. It is based on Atmel's Attiny85.
Step 1: What You Need
Here is the list of material you need:
- 2 x HC-SR505 Mini Infrared PIR Motion Sensor
- 2 x diode (IN4148)
- 1K Resistor (or larger if you want more photocell sensitivity)
- 1 LED light 3mm
- Photocell sensor
- JST connector for battery
- 3.7V LiPo battery 500mAh
- 2 x Tiny wires (30 AVG)
Step 2: Modifying the Sensors
The PIR sensors are built to run with a minimum of 4.5v and the LiPo battery only provides between 4.2v (fully charged) down to 3.7v. In order to overcome this problem, we must bypass the sensor’s voltage regulator by soldering a tiny wire (I use 30 AVG) directly on the EG4001 chip, the second pin from the left. This looks more difficult than is it in reality.
Strip a few millimeters from the wire and apply a solder bump on the exposed tip. Next, position the wire on the chip's second pin (as in the picture) and gently apply your soldering iron briefly to melt the solder bump and remove it.
The last step is to cut the VCC (+) pin from the connector.
Step 3: The Circuit
Both PIR sensors are connected to the same ATTINY85 input pin to minimize pin usage and associated code. The PIRs sensor signal is ran through diodes to alleviate any current feedback effect. Without the diodes, part of the signal is absorbed by the other sensor and is so weak it doesn’t trigger the interrupt required by the Attiny to wake-up.
The PIR sensors are turned off when there is ambient light around. During those periods, the circuit only draws about 4uAh. When it's dark, the PIR sensors are turned on and draw 130 uAh when no motion is detected. This means that on average, if there is total darkness around the circuit for 8 hours a day, the circuit will draw an average of 46 uAh while standing by. Your mileage on the battery will vary depending on how many times the LED is on but a 500 mAh battery sould last about a year under normal usage.
The photocell sensor is turned on only when it is required to read its value. Increasing the resistance value will make it more sensitive. Experience with different values to fit your requirement.
Step 4: The Code
In order to program the Attiny85, you must use an external programmer. I personally do this though an Arduino Uno. You can find plenty of tutorials on how to do this on the web.
The code uses a hardware interrupt and a timer interrupt (watchdog) to perform its actions with as little power as possible. Every 4 seconds, the watchdog interrupt fires up so we can check for changes in darkness through the photocell and turn the PIR sensors on/off accordingly.
Step 5: Final Assembly
I made the circuit into a PCB, soldered the components and 3D printed a small box for it, making sure the PIR sensors are pointing in the right direction. That way, motion detection happens more precisely and allows for better area detection.
Hope you like it, let me know if you have questions, comments or see potential improvements.