DIY Motion Sensing Ceiling Fan/light ***5$ Energy Saver!!!***

Now when I walk into my room (or my cat :) my lights automatically pop on for me! In this project I'm going to show you how to for under $5 hook up a motion sensor to you ceiling fixture! This is what happens. When the motion sensor senses motion it sends a HIGH signal to microcontroller. The microcontroller then turns on the light and starts a 5 minute countdown. Everytime the motion sensor senses motion it resets the 5 minute timer. So say I walk in my room at 5:30 and immediately walk out. At 5:35 the light will turn off. Later in the day my cat walks in at 6:00, then walks out. Three minutes later, she sees a mouse in my room, so she runs back in at 6:03, but realizing that the mouse if just a play mouse, runs back out. At 6:03 The timer is reset and the light won't go off for another 5 minutes (6:08).
The second mode of this project just keeps the light on as long as the circuit has power. So if you sleeping at night and want the fan to stay on all night you can switch it to that.
Just think, next time you leave the house and forget to turn the light off you can have the satisfaction that the light will automatically turn off in 5 minutes! This whole project can be built for about 5 dollars and takes quite a bit of time but is very worth it in the end! Watch the video, make the project, and vote and share!
Of course you can change how long the light stays on if you want. Change it to 10 minutes if you'd like! Just remember you have to convert however minutes you want the light on into milliseconds!




Step 1: Ingredients

DIY Motion Sensing Ceiling Fan/light ***5$ Energy Saver!!!***

Link to code http://www.mediafire.com/view/xgnd2ba71hqur5d/DIYMotionsensor.ino


I would explain it but I really don't know how to so!
Thanks to lewisb42 for helping me out with the resetting timer.
(http://www.instructables.com/community/Arduino-programming-help-Do-two-things-at-once/)

Electronics:



• Arduino
• ATtiny85
• ATtiny programming shield or 10 uf capacitor
• 8 DIP socket
• PIR motion sensor
• Relay- the kind that comes on a pcb with a protection diode and transistor
• SPDT switch (with an off position)
• IC circuit perf board
• 1/8 or 1/4 inch male and female audio jacks (mono is easier)
• Breadboard and jumper wires
• 10k ohm resistor
• USB cable
• Telephone cable wire
• Electrical wire
• Electrical tape
• Brush on electrical tape
• Cell phone charger



Parts and tools:



• Multimeter
• Project box
• Dremel
• Philips screwdriver
• Hot glue gun
• Heat shrink
• Soldering Iron
• Heat gun
• Wire cutter & strippers

Step 2: Breadboard the Circuit

DIY Motion Sensing Ceiling Fan/light ***5$ Energy Saver!!!***
DIY Motion Sensing Ceiling Fan/light ***5$ Energy Saver!!!***

As always, it's best to test the circuit before you make it permanent.
I attached the schematic to this step so you can see how to make this circuit.

Step 3: Circuit p.1

DIY Motion Sensing Ceiling Fan/light ***5$ Energy Saver!!!***
DIY Motion Sensing Ceiling Fan/light ***5$ Energy Saver!!!***
DIY Motion Sensing Ceiling Fan/light ***5$ Energy Saver!!!***

  • Start by inserting to the perf board the 8 DIP socket. Turning the board over bend the leads over on the socket and solder them to the pads.
  • Cut and strip a 2 inch red and black wire. Solder the red wire to the right side of the circuit and solder the black wire to the left side of the circuit. Make sure you use the correct left and right-from the topside of the board. Also make sure the front of the socket is facing the red and black wires.
  • Solder the other side of the red wire coming from the perf board to the middle lead of a audio jack.
  • Solder the other side of the black wire coming from the per board to the end lead on the far end of the audio jack.

    Step 4: Circuit p.2

    DIY Motion Sensing Ceiling Fan/light ***5$ Energy Saver!!!***
    DIY Motion Sensing Ceiling Fan/light ***5$ Energy Saver!!!***
    DIY Motion Sensing Ceiling Fan/light ***5$ Energy Saver!!!***

    Your circuit so far should have a female audio jack hooked up to two solder pads on the perf board, then an 8 DIP socket soldered down to the middle. Lets add the switch.

    The kind of switch we will be using is an SPDT switch with an off position. Basically it directs current through one of two wires or neither of them. So the switch three positions.

    1. OFF 2. ON (wire 1) 3. ON (wire 2)

    | \ /
    | | | | | |
    | | | | | |


  • Solder the middle lead of the switch to the +5v power pad on the perfboard.
  • Solder the right wire of the switch to pin 8 on the ATtiny85.
  • Solder the left wire of the switch to pin 2 on the ATtiny85.

    Step 5: Circuit p.3 (The last part!!!)

    DIY Motion Sensing Ceiling Fan/light ***5$ Energy Saver!!!***

    There should be three wires coming from the relay and motion sensor. On is +5v, the other is GND, and the third is control. It may be labeled (CT, C or Vout).

    The Motion Sensor

  • Solder the GND and the +5v of the sensor to GND and +5v pads you made on the perf board.
  • Solder Vout to pin 7 on the ATtiny85. The Relay
  • Solder the GND and the +5v of the sensor to GND and +5v pads you made on the perf board.
  • Solder CT to pin 6 of the ATtiny85

    Step 6: Program the ATtiny85

    DIY Motion Sensing Ceiling Fan/light ***5$ Energy Saver!!!***
    DIY Motion Sensing Ceiling Fan/light ***5$ Energy Saver!!!***

  • Find and install the ATtiny85 library
  • Open a new window and copy and paste this code into your Arduino sketch
  • In a new sketch window, open and upload the ArduinoISP (it's under example sketches)
  • Upload the ArduinoISP to your Arduino
  • Press the ATtiny85 into your breadboard. Connect a 10uf capacitor between pins GND (+ lead on cap) and RESET (- lead on cap) on the Arduino.Connect the following pins on the ATtiny85 to the Arduino.

    Arduino ATtiny85

    GND--------- pin 4
    5v ------------ pin 8
    Pin 13 ------ pin 7
    Pin 12 ------ pin 6
    Pin 11 ------ pin 5
    Pin 10 ------ pin 1
  • Select the ATtiny85 as the board (Tools>board>ATtiny85)
    Change the programmer to "Arduino as ISP" (Tools>Programmer>Arduino as ISP)
  • Go to your motion sensor sketch and click upload. You should get to errors (avrdude: please define PAGEL and BS2 signals in the configuration file for part ATtiny85) but that's OK. Now you can stick the ATtiny85 into it's socket and make sure the circuit is working properly.
    If you can't get the ATtiny85 to program get more info here.

    Step 7: Making the Power Cable

    DIY Motion Sensing Ceiling Fan/light ***5$ Energy Saver!!!***
    DIY Motion Sensing Ceiling Fan/light ***5$ Energy Saver!!!***
    DIY Motion Sensing Ceiling Fan/light ***5$ Energy Saver!!!***

    It is time to make the power cable. For this step you will be needing a phone cable, USB cable, and an male audio cable. What we are trying to do is make a long cable to carry 5v to our project. I figured that the easiest way to do that was to use a cell phone charger.

  • Measure about 5 inches down from the USB plug and cut the cable. Strip the wire. Cut away the white and green wires. AGAIN get out your wires strippers and strip the red and black wires.
  • Strip both ends of a telephone cable.
  • On one end of the telephone cable connect the red and green wires to the red and black wires of the USB cable.
  • On the other end of the telephone cable connect the red and green wires of the phone cable to the red and black wires of the audio jack. Now when you plug in the USB cable you should be getting 5v at the Audio jack.
    Plug the male mono jack into the female audio jack and make sure the circuit is getting power.

    Step 8: Trimming

    DIY Motion Sensing Ceiling Fan/light ***5$ Energy Saver!!!***
    DIY Motion Sensing Ceiling Fan/light ***5$ Energy Saver!!!***

    The perf board won't fit in the project box so it will take a little cutting with the dremel to get it to fit. Take a sharpie and mark off a section. Happy cutting!

    If your relay won't fit in the box you may want to trim it down too.

    Step 9: Fitting the Fresnel Lens, Switch, and Audio Jack

    DIY Motion Sensing Ceiling Fan/light ***5$ Energy Saver!!!***
    DIY Motion Sensing Ceiling Fan/light ***5$ Energy Saver!!!***
    DIY Motion Sensing Ceiling Fan/light ***5$ Energy Saver!!!***
    DIY Motion Sensing Ceiling Fan/light ***5$ Energy Saver!!!***
    DIY Motion Sensing Ceiling Fan/light ***5$ Energy Saver!!!***

  • Remove the Fresnel lens from the motion sensor if possible.
  • Unscrew the light switch cover.
  • Use a sharpie to draw out a square that the Fresnel lens can fit into.
  • Cut! Be careful, the plastic melts easily.
  • Drill out the holes that the screws go through. The idea is to make a hole big enough for the female audio jack to go through and big enough for the switch to go through
  • Glue down the audio jack and the motion sensor. Insert the switch through the hole and screw it down.

    Step 10: Protecting the Relay

    DIY Motion Sensing Ceiling Fan/light ***5$ Energy Saver!!!***

    Now I got some brush-on electrical tape and I brushed it over all the contacts on the back of the relay. This. would help eliminate any risk of shorting out the 120v AC wires.

    Step 11: Readying the Wall

    DIY Motion Sensing Ceiling Fan/light ***5$ Energy Saver!!!***
    DIY Motion Sensing Ceiling Fan/light ***5$ Energy Saver!!!***

  • Now it's out to your basement or garage. Find the circuit breaker that is controls your light switch and turn it off. Double check to make sure the power is off.
  • Unscrew the light switch from the box and pull it out.
  • Cut the wires going to the switch.
  • Strip the ends of the wires that were going to the light switch. Keep it short.
  • Wrap electrical tape around the ends of the two wires.
  • Stick a wire through the left hole of the project box and then connect it to the middle terminal on the relay [C].
  • Stick the other wire through the right hole of the project box and then connect it to the right terminal [NC] (normally closed).

    Step 12: Fitting the Project to the Wall

    DIY Motion Sensing Ceiling Fan/light ***5$ Energy Saver!!!***

    Now it's time to sew everything back up. First press the project box into the wall and then try to get the outlet cover to fit flat on the wall without any pressure. I would up just cutting the project box in half. I wasn't counting on all the wires they jammed in the wall box. Wrapping the circuit and relay in electrical tape might have been better. Anyhoo you do what works best for you.
    Squeeze hot glue around the edges of the light switch cover and press it onto the wall. Make sure to wipe away any excess glue.

    Step 13: Creating the Sticker

    DIY Motion Sensing Ceiling Fan/light ***5$ Energy Saver!!!***
    DIY Motion Sensing Ceiling Fan/light ***5$ Energy Saver!!!***
    DIY Motion Sensing Ceiling Fan/light ***5$ Energy Saver!!!***
    DIY Motion Sensing Ceiling Fan/light ***5$ Energy Saver!!!***
    DIY Motion Sensing Ceiling Fan/light ***5$ Energy Saver!!!***
    DIY Motion Sensing Ceiling Fan/light ***5$ Energy Saver!!!***
    DIY Motion Sensing Ceiling Fan/light ***5$ Energy Saver!!!***
    DIY Motion Sensing Ceiling Fan/light ***5$ Energy Saver!!!***
    DIY Motion Sensing Ceiling Fan/light ***5$ Energy Saver!!!***
    DIY Motion Sensing Ceiling Fan/light ***5$ Energy Saver!!!***
    DIY Motion Sensing Ceiling Fan/light ***5$ Energy Saver!!!***
    Show All 11 Items

    I didn't like the way the outlet cover looked because of my horrible cutting job, so I made a label. I'm just going to upload some of the pictures of the steps I took to make the sticker.

  • Design your label. Be creative. I put a QR code on my that take your smart phone to my profile.
  • Cut the label out.
  • Press out holes for the audio jack and the switch.
  • Gently press the label on the outlet cover.
  • Guestimate where you need to cut a hole for the Fresnel lense and cut out the hole.
  • Press the label on the wall.

    Step 14: Plug up & Enjoy!

    Plug your cellphone charger into the wall. Then plug the USB end of the power cable into the phone charger and then plug the male audio jack into the female jack on the cover. Tape or tack the wire out of the way so that nobody will trip on it.

    Now impress your friends by having them walk into your room before you do so that they can experience the awesomeness of your project!

    Depending on the person you may want to change the time the light stays on on sensor mode. All you have to do is reprogram the ATtiny85. Where you see 300000 milliseconds in the code change it to whatever you want.

    Step 15: Conclusion

    This was my first attempt at making a good video for my instructable. I hope I did a good job. Any tips on making the video better?

    Thank you for watching the video and viewing this instructable. If you like this i'ble please give it votes for the contests and don't forget to subscribe for more!


    ~EE

  •  
     

    Tag cloud

    make build easy simple arduino making homemade solar laser printed portable cheap mini building custom cardboard wooden create super lego turn paracord chocolate your paper light intel