Coder Social home page Coder Social logo

lookslikematrix / motiondetector Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 117 KB

This is a project for motion detection with the raspberry pi and the motion senscor HC-SR501.

License: MIT License

Python 100.00%
raspberry-pi motion-detection python3 hc-sr501

motiondetector's Introduction

MotionDetector

curcuit This is a project for motion detection with the raspberry pi and the motion senscor HC-SR501.

Installation

If you want to install the motion detector on your raspberry pi you first have to connect your motion detector as in the image above. The HC-SR501 has a jumper for configuration between two modes. I chose the L mode, which means that when motion is detected the signal stays high (1) until there is no more detection.

After connecting your sensor you can turn on the rasperry pi, connect to it and type the following lines.

git clone https://github.com/deckersoftware/MotionDetector.git
cd MotionDetector
python3 main.py

Now your motion detection should be started with default configuration. If you like to end the the program just press Ctrl + C.

To automatically start the script after a reboot, you have to execute the following lines.

sudo ln -s `pwd`/motion_detector.service /etc/systemd/system/motion_detector.service
sudo systemctl enable motion_detector.service
sudo systemctl start motion_detector.service

Configuration

In the config.json file you can set the motion detection with the following parameters. The file is copied from the config.json.sample file at the first start of the program.

Parameter Description Default
motion_input_pin Defines the pin where the motion detector is connected to the raspberry pi 7
motion_detected_duration_in_seconds Defines duration before no_motion_action is executed 30
no_motion_detected_duration_in_seconds Defines duration until motion_action is executed 6
no_motion_action Defines action when there is no motion detected. For example turn of the display vcgencmd display_power 0
motion_action Defines action when there is motion detected. For example turn on the display vcgencmd display_power 1
motion_detection_time Defines the time when the motion detection is activated. For example every day from 5 o'clock till 21 o'clock. {"monday": "5:00 21:00", "tuesday": "5:00 21:00", "wednesday": "5:00 21:00", "thursday": "5:00 21:00", "friday": "5:00 21:00", "saturday": "5:00 21:00", "sunday": "5:00 21:00" }

HC-SR501

The motion detection sensor has two potentiometers. One of them is for the time adjust delay which is configurable between 5 and 300 seconds, the other one is for the sensitivity. I set the first one to 5 seconds which explains the 6 seconds no_motion_detected_duration_in_seconds configuration. When there is still motion after 6 seconds I would like to execute the motion action. Otherwise, nothing should happen.

motiondetector's People

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.