M’Day: Low Power Motion Sensor Arduino Night Light…
A few years back I made a motion sensitive night light as a Mother’s day gift and while it worked pretty well it really chewed out the batteries. And as with all devices that eat batteries it eventually fell out of use. The standby current was around 4 mA due to the common LM324 opamp that was used to amplify the PIR motion sensor signal. The original enclosure was CNC milled from a bit of re-purposed apple which had a former life as a guitar body I built as a child. Apple happens to be my favorite wood, it’s rich and creamy and the project just needed some new electronic guts:
The new variant sports a TLC1079 micropower quad opamp from TI that draws just 150 microwatts per channel. It also received an upgrade from a Tiny13 to a Mega328p allowing for a custom Arduino bootloader spec’d for operation at 1MHz. The upload speed was set at 62500 baud as this worked out best with the internal 8Mhz RC oscillator divided by 8. As can be seen in the schematic below, the entire circuit forgoes a regulator and runs directly from battery. It also includes a CDS to sense the light, a pair of RGB LEDs switched with 3 P-channel FETs and a 6 pin port to connect a USB to serial converter. Note the DC blocking 4.7uF capacitor, non-polarized ceramic or polypropylene works best, all other parts are standard fare. Click to view a larger image:
After the circuit was prototyped on a breadboard Arduino, it was moved to a piece of predrilled strip board for quick assembly. Not shown are the P-channel FETS which are on the original RGB LED board under copious amounts of hot glue for diffusional purposes. The LED PCB was originally made with the toner transfer method but strip board would have sufficed just as well. The Red PCB holding the PIR sensor had a previous life as a TriggerTrap motion sensor, there are a few components under the dome as well. Here is the circuit board with a bit of heatshrink keeping all the arms and legs inside:It’s been bench tested from 5 volts down to 2.7 volts and at a nominal battery voltage of 4.5 volts, it draws just 0.08 mA in sleep mode. This equates to over 3 years of standby from a triple set of AA batteries. Motion detection is quite good at over 5 meters and it’s more than what’s required to keep Mom from tripping up if she gets up for a night time stroll.
Programming was done in the Arduino IDE and the n0m1 sleep library was used to shut down the microcontroller for power saving. The device wakes from slumber when either of the external interrupts are triggered, the light sensor triggers interrupt 1 and the motion sensor triggers interrupt 0. The code itself is very simple, the light sensor sets the mode and if the mode is nighttime, the motion sensor triggers the RGB LEDs to cycle through a color gradient using the Hue to RGB conversion code. As can be seen in the following video, it takes about 10 triggers to get all the way through the gradient as each trigger shows just one primary color and a bit of secondary color:
The Arduino sketch, schematic, custom bootloader and boards entry are neatly wrapped up in the following RAR: n0m1.com Arduino PIR Night Light
And the n0m1 sleep library can be found here: https://github.com/n0m1/Sleep_n0m1
Happy Mother’s Day Mom!