For some time now I've been wanting to dip my toes into home automation. I decided to start with a simple project. Unfortunately I didn't take any photos during the process, but I used a protoboard to test my ideas first, and only soldered it together when everything was working.
The project consists of an Arduino connected to both a PIR sensor and a LED strip driven by a MOSFET. I could have skipped the Arduino altogether and used just the PIR and its adjustable delay, but the maximum is 18 seconds, meaning someone has to move in front of it every 18 seconds to keep the lights from going off. Besides, I wanted the lights to come on and off gradually.
My initial idea was to also connect a radio module and start a MySensors network, but I was having some trouble making the sensor communicate with the gateway, so I gave up and kept the project simple.
Step 1: Materials
I provide here a list of materials (excluding the obvious, like wire, solder, soldering iron, etc) with the links where I purchased them.
- Arduino Pro Mini 328 5V. I tried using the 3.3V at first, and thought it would handle the 12V raw input, but I burned the poor onboard voltage regulator.
- Warm White 12V LED strip (60 led/m, SMD2835, waterproof)
- PIR motion sensor
- IRFZ44N mosfet for driving the 12V LED strip using a 5V output from the Arduino. Any good N-mosfet with these voltages in range that accomodates your expected current will do, it doesn't have to be this particular one, but I've used these before for driving LED strips, so I trust them. They're listed to handle 55V and 49A, more than enough for this particular project.
- 12V Power Adapter. I went with the 2A model, but you should estimate the current you'll be needing. The LED strip I chose is listed as 2.88W/m, which seems a little too low for 60 large LEDs, so I played it safe.
- DC Power Socket
- Project box. Anything that fits your project is good.
- JST connector for the LED strip. You may solder the wires directly, but I thought it was better to use a connector in case I need to replace the strip.
Step 2: Assembly
The PIR sensor is connected to pin 2 on the arduino, and the output to the mosfet is connected on pin 3. You may choose any other pins and change the code accordingly, but the output pin must be PWM-capable. The Arduino's ground should be connected to the power plug's ground - pick any of the arduino's GND pins. Note that the positive wire from the power plug must be connected to the arduino's RAW pin, so that it passes through the voltage regulator. DO NOT CONNECT A 12V POWER SOURCE DIRECTLY TO VCC, you will fry your Arduino.
On N-Channel MOSFETs, the Gate is pin 1, the Drain is pin 2 and the Source is pin 3. The source (pin 3) should be connected to the 12V ground, the gate (pin 1) to the Arduino and the drain to the LED strip's negative pin. The strip's positive should be connected directly from the power plug.
I used two connectors for the LED strip because I split it in two, one for each side of the stove. You may use just one connector or many, and power as many parts as you want in parallel, as long as you provide the required current from the power adapter. The LED strips generally have printed marks showing where they can be cut (and it's generally into sections of 3 LEDs). Just make sure you're not connecting anything on a reverse polarity, and you're good to go.
Once everything is in place, you need to cut a hole in the project box to fit the PIR sensor. I chose to position it diagonally, so it wouldn't get much movement from my living room, but the little bugger's really sensitive. You can adjust the sensitivity, though, by slightly turning one of the two trimpots (the other is for the timeout of the signal and should be left alone). Clockwise makes it more sensitive.
I also cut two slots for the LED strip wires, you should cut as many as you need. Installing the project box depends on the model, mine has a hole for a screw on the back, so I screwed it to the bottom of the cabinet and positioned the PIR sensor facing forward. The LED strips were supposed to have an adhesive back, but either the adhesive was not good enough, or the cabinet had so much grease on the surface that it prevented the strip from sticking (yuck!). So I bought some cable clips (the kind used to nail coaxial cable down) and this held the strip in place.
Step 3: Next Steps
In the future, I intend to build a MySensors network in the house, and I'll try to add this project to it. And another thing I want to do is to add low power capabilities so that the circuit doesn't use much current in standby.