Motion Sensing Outlet

by Constructed in Circuits > Gadgets

5932 Views, 91 Favorites, 0 Comments

Motion Sensing Outlet

DSC00849.JPG

Hi!

Today i'll be teaching you how to make a motion sensing outlet!

As always I have a video documenting the project in step 2

Its perfect for Halloween, just simply plugin your favorite decoration, and whenever the sensor detects motion, the decoration will spring to life!

Best of all the the project uses a mediatek linkit one! This board is amazing and so simple to use! It really is one of the most powerful boards I have ever used.

I made this project after my first idea fell apart... I had a plan to build a POV RGB LED wand, however it did not turn out well. Oh well, maybe next time.

*One more thing, we are working with a lethal amount of electricity. Please know what you are doing*

Also this proect is only suitable for wall outlets rated 120v. for higher voltages (220+) you will need a stronger relay

Watch the Video!

What You Need

vlcsnap-2015-10-22-19h24m54s254.png
vlcsnap-2015-10-22-19h25m09s100.png
vlcsnap-2015-10-22-19h26m14s5.png
vlcsnap-2015-10-22-19h25m43s202.png
vlcsnap-2015-10-22-19h26m23s105.png
vlcsnap-2015-10-22-19h26m41s1.png

To build this, You will need

  1. A recycled box mine even came with a powercord!
  2. LinkIt One
  3. A relay module
  4. PIR motion sensor
  5. Spare wall outlet

http://goo.gl/DDgePJ (If you dont have a linkit)

http://goo.gl/hC1sv9 (Cheaper price)

http://goo.gl/238eVJ (cheaper price)

For most of the parts I got them at www.gearbest.com

Gearbest is so friendly and the FASTEST shipping time.

They have cheap prices and are my #1 site whenever I need parts for a project.

Please check them out and tell them I sent you.

Cut the Box

vlcsnap-2015-10-22-19h26m51s125.png
vlcsnap-2015-10-22-19h27m02s234.png
vlcsnap-2015-10-22-19h27m08s37.png

Using a wall outlet face plate, trace the outline of the wall outlet onto the box

Dont forget to mark a spot for the PIR motion sensor as well

Next drill out the parts you wont need and file it down so they fit tight.

Test the Circuit

vlcsnap-2015-10-22-19h27m59s36.png
vlcsnap-2015-10-22-19h28m14s188.png
vlcsnap-2015-10-22-19h28m06s114.png

Before you put the whole project in the enclosure, make sure to test that it works first

Hook up

(LIO) (RLY)

+5v VCC

GND GND

D7 IN1

Next look up "simple relay code" I used this guide here

https://www.instructables.com/id/interface-relay-wi...

test that they work!

Put Circuit Together

vlcsnap-2015-10-22-19h28m47s254.png
vlcsnap-2015-10-22-19h28m39s163.png
vlcsnap-2015-10-22-19h29m01s129.png

Now assemble the cicuit

Remember 120v can be lethal. Unplug the power, Be smart.

Im not resposible for your actions, dont get hurt

Wire up the power to the outlet, but take the HOT line, cut it and feed it into t

Final Touches

vlcsnap-2015-10-22-19h27m25s215.png
vlcsnap-2015-10-22-19h27m50s193.png
vlcsnap-2015-10-22-19h29m13s8.png

Now put the circuit back together, wrap in electrical tape to avoid shorts and upload the code

here is the code:

/*******************************************************************************/
/*macro definitions of PIR motion sensor pin and LED pin*/ #define PIR_MOTION_SENSOR 8//Use pin 8 to receive the signal from the module #define LED 7//the Grove - LED is connected to D4 of Arduino

void setup() { pinsInit(); }

void loop() { if(isPeopleDetected())//if it detects the moving people? turnOnLED();

else turnOffLED(); } void pinsInit() { pinMode(PIR_MOTION_SENSOR, INPUT); pinMode(LED,OUTPUT); } void turnOnLED() { digitalWrite(LED,HIGH); } void turnOffLED() { digitalWrite(LED,LOW); } /***************************************************************/ /*Function: Detect whether anyone moves in it's detecting range*/ /*Return:-boolean, ture is someone detected.*/ boolean isPeopleDetected() { int sensorValue = digitalRead(PIR_MOTION_SENSOR); if(sensorValue == HIGH)//if the sensor value is HIGH? { return true;//yes,return ture } else { return false;//no,return false } }

Youre Done!

vlcsnap-2015-10-22-19h29m22s103.png
vlcsnap-2015-10-22-19h29m40s24.png

Youre done!

Whenever the motion detector detects motion, the relay will spring and the outlet will come to life!

Plug in halloween decorations for the best effects!

Please vote and comment for this instructable in the contests! Thank you!

Also dont forget to check the Mediatek linkit one page before you go!

https://www.instructables.com/id/mediatek-linkit-on...

And remember if you need any parts...

www.gearbest.com

Bye!