Plug the male-to-female jumper wires into the motion sensor pins. The middle wire will be the signal line, and will connect to Pin 2 on the Arduino. The side connector pins will go into the Arduino's ground (GND) and 5V sockets. These correspond with labels normally found behind the sensor's white dome lens.
Plug a male-to-male connector into a second GND pin on the Arduino. This wire will connect to the negative port on the power relay connector (labeled with a "minus" symbol). For wire installation, pull out the small green connector on the side of the power relay. Doing so will expose screws that open and clamp the wires.
Plug another male-to-male connector into Pin 3 on the Arduino. This wire will connect to the positive port on the power relay connector (labeled with a "plus" symbol).
Power your Arduino. To do so, plug the Arduino power supply into the always ON socket on your power relay, then connect the barrel jack on the other end of the power cord to the Arduino's power input.
- Download the proper program for your computer from Arduino's software page.
- Run the program and follow the on-screen prompts. This will give it permission to modify your system.
- Download this code from my GitHub page.
- Use Ctrl+O to load the code onto the Arduino IDE.
- Connect your Arduino to your computer with the USB cable.
- Use Tools>Board:>Arduino/Genuino Uno to choose the type of Arduino you're using.
- Use Tools>Port to select the port where your board is listed by name.
- Use Ctrl+U to load the code onto your board.
- (Optional) Change the delayValue. This bit of code dictates how long the fan stays on after the sensor notices movement. In my code, it's set to 600000 (600,000 milliseconds, or 10 minutes). Tweaking this number will let you modify the fan's behavior to your liking. If you only want it to run for 5 minutes, change the value to 300000. The world is yours… as long as it involves turning on a fan.
- With your fan unplugged, turn it on and set it to your preferred cooling setting.
- Plug the fan into one of the two "normally OFF" sockets on the power relay. With everything connected, it'll turn on automatically. You can even plug a light or another device into the other normally OFF port to make it motion-activated as well.
- Drill press (or a handheld drill)
- 1-inch spade bit
- Hot glue gun
- 1/2-inch drill bit (optional)
- 1/4-inch drill bit (optional)
- Drill a 1-inch hole for the sensor. This is the only hole that needs to be close to spot-on, as it's where the white semi-dome will protrude.
- Drill holes for the power cable and hookup wires. Use the 1/2-inch bit for the power cable hole and the 1/4-inch bit for the hookup wire pass-throughs. You can also use whatever you have available that's close, or even the spade bit if you're OK with a loose fit.
- Hot glue the Arduino in the center of the enclosure.
- Hot glue the motion sensor to the hole you drilled for it.
- Feed the wires through their respective holes and attach them to the Arduino and the power relay.
- Reattach the enclosure's top cover.