• Home
  • pcDuino
  • WiKi
  • Store
  • Distributors
  • Home
  • pcDuino
  • WiKi
  • Store
  • Distributors
HomeArduinoArduino EsploraEnergy Saver – Motion Activation
Previous Next

Energy Saver – Motion Activation

Posted by: Olva , September 21, 2016

Energy Saver – Motion Activation

Motion Sensor Tower

Energy Saver

Now that we have an energized city, the electricity bills are coming in. Let’s figure out a way to turn off the lights when we are not in the room.

Goal:

  • Turn off the city lights if we don’t detect anybody for 5 minutes.

Challenges:

  • Detect motion to turn on lights
  • Turn off city lights after 5 minutes of inactivity

Components:

  • Raspberry Pi (or any NodeJS host)
  • Arduino (I used the Mega 2560 but any will do)
  • HC-SR501 motion sensor
    • motion sensor
  • 1.8v LED
  • resistor

Schematic:

 

This is a pretty simple circuit. We just need to plug the motion sensor into a digital input pin and supply it 5v of power. We will then connect an LED and resistor to an output pin to indicate when motion has been detected.

PIR Motion Sensor 220 ohm resistor LED

PIR Motion Sensor
220 ohm resistor
LED

Code:

Initialize the board, the LED and motion detector. Then we just define a sensor listener that will be activated by the motion detector. An LED is connected to an output pin so we could get instant feedback when motion has been detected.

 

Basic Flow

  • Set initial energy delay timer for 5 minutes.
    • Turn off devices if no motion detected.
  • Listen for motion detection .
    • Reset timer.
    • Turn on LED for 2 seconds.
    • Turn on lights (and other optional devices).

 

Filename

energysave.js

Now save and run your file.

Note: If this is your first project, you will need to initialize the folder and add the johhny-five module.
Run the following two commands before launching your new app.
npm init
npm install johnny-five --save
Now run the code
node energysave.js
You should now see the following on your console and the LED should turn on when you make any motion. The city lights, disco lights and anything else you want to turn on should also be working now.
root@thethingbox:~/IoL# node energysave.js1442865455303Device(s)/dev/ttyACM0 1442865455386Connected/dev/ttyACM01442865458332ReplInitialized >> sleep timer reset sleep timer resetsleep timer reset sleep timer reset

 Construction:

I basically just stuck the motion sensor to a vertical strut beam, using tacky tape. I then attached the LED to the top of an antenna and used a twist tie to lock it in place.

Probably not the most polished build, but it was quick and easy. The exposed electronics kind of makes sense on a radio tower.

20151016_162758  20151016_162752

Energy efficiency!

the original post is from http://www.internetoflego.com/energy-saver-motion-activation/

Share!
Tweet

Olva

About the author

Leave a Reply Cancel reply

You must be logged in to post a comment.

Category

  • Home
  • pcDuino
  • WiKi
  • Store
  • Distributors