{"id":15172832,"url":"https://github.com/easytecrepository/motion-detector","last_synced_at":"2026-01-24T07:36:33.198Z","repository":{"id":205269000,"uuid":"713833432","full_name":"EasyTecRepository/motion-detector","owner":"EasyTecRepository","description":"Here you can find a simple script, that detects motions, activates a buzzer, and sends you a discord notification","archived":false,"fork":false,"pushed_at":"2023-11-11T10:54:01.000Z","size":433,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-12-29T09:42:28.944Z","etag":null,"topics":["motion-detection","raspberry-pi","raspberry-pi-3"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/EasyTecRepository.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-11-03T10:30:05.000Z","updated_at":"2024-04-25T09:09:09.000Z","dependencies_parsed_at":null,"dependency_job_id":"a8099b85-8923-4064-a12c-3acf1174adce","html_url":"https://github.com/EasyTecRepository/motion-detector","commit_stats":{"total_commits":14,"total_committers":1,"mean_commits":14.0,"dds":0.0,"last_synced_commit":"48e9b064b0b1278ece99369d3ebfa5b7030ad747"},"previous_names":["easytecrepository/motion-detector"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EasyTecRepository%2Fmotion-detector","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EasyTecRepository%2Fmotion-detector/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EasyTecRepository%2Fmotion-detector/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EasyTecRepository%2Fmotion-detector/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/EasyTecRepository","download_url":"https://codeload.github.com/EasyTecRepository/motion-detector/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239686157,"owners_count":19680471,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["motion-detection","raspberry-pi","raspberry-pi-3"],"created_at":"2024-09-27T10:20:43.190Z","updated_at":"2025-12-16T10:30:26.511Z","avatar_url":"https://github.com/EasyTecRepository.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# motion-detector \nHere you can find a simple script, that **detects motions**, **activates a buzzer**, and sends you a **discord notification**\n\nI have also uploaded a video about this project to YouTube. [Check it out](https://youtu.be/H0sQH5YJK64?si=ACYnVe2sIFxESubc) (german video)\n\n# What is needed?\n- RaspberryPi (I use a RaspPi 3b+, but I think it doesn't matter)\n- Breadboard or other solutions (maybe you soldering it yourself)\n  - Jumper cable (if needed)\n- Ultrasonic sensor HC-SR04\n- Buzzer\n- resistors (1x 330Ω; 1x 10kΩ)\n\n# connection diagram\nFirst of all, the hardware must be connected.\nIf you like, you can also use a different PIN assignment, **but don't forget that you have to adjust it in the script!**\n![Connection Diagram](https://github.com/EasyTecRepository/motion-detector/blob/main/pictures/pi_motion_detection_Steckplatine.png)\n\n# Setup\nYou must edit a few variables in my script.\n\n| Variables                    | Description                                                                                                |\n| ---------------------------- | ---------------------------------------------------------------------------------------------------------- |\n|webhook_url                   | This is your webhook URL (You can get them in the channel settings on your Discord server)                 |\n|picture_url                   | This is your picture URL (No matter, the link must be a file! - You can use my [default URL](#picture_url) |\n|username                      | This is the username you want. This is the name of the bot that sends Discord notifications.               |\n|sleep_after_alert             | Set sleep time after successful alert                                                                      |\n|SENSOR_TRIGGER                | This is the Pin where you have connected the \"trigger\"-cable of the sensor                                 |\n|SENSOR_ECHO                   | This is the Pin where you have connected the \"echo\"-cable of the sensor                                    |\n|PIN_output_BUZ                | This is the Pin where you have connected the positive (+) buzzer-cable of the buzzer                       |\n|def_distance                  | This defines your distance, after the alert triggers                                                       |\n\nFurthermore, you must install Python3 and Python3-pip, if not already done.\n```\nsudo apt-get update \u0026\u0026 sudo apt-get install python3 python3-pip\n```\nAfter that, we need to install the library discord_webhook.\n```\nsudo pip3 install discord_webhook\n```\n\nNow, we're ready to create this script on the Raspberry Pi.\nFirst, we create a file, no matter in which folder.\nThe name of your script doesn't matter.\n```\nnano motion_detection.py\n```\nAfterward, you paste the [script from this repository](https://github.com/EasyTecRepository/motion-detector/blob/main/main.py) into your editor.\nAfter you have changed all the above-mentioned variables you can save the script with:\n- control+O \u0026 control+X (macOS)\n- STRG+O \u0026 STRG+X (Windows)\n\nFinally, you can run the following command:\n```\npython3 motion_detection.py\n```\n\n# automation \n\u003e [!WARNING]\n\u003e These instructions show how it should work. I could not get it to work. I have not yet tested other services such as cronjob. Maybe this works...\n\nIf you want the script to start when your Raspberry Pi starts:\nI use autostart ([Based on this Tutorial](https://tutorials-raspberrypi.de/raspberry-pi-autostart-programm-skript/)). Here is how it works:\nFirst, we need to create another script.\nIn my case, the name is motion_detector.\nThis will be the name of your service.\nThe name of this script doesn't matter.\n```\nsudo nano /etc/init.d/motion_detector\n```\nHere you must paste this:\n```\n#! /bin/sh\n### BEGIN INIT INFO\n# Provides: motion detection script\n# Short-Description: start motion detection script\n### END INIT INFO\n \ncase \"$1\" in\n    start)\n        echo \"start motion detection...\"\n        # start program\n        python3 /home/your_user/motion_detection.py \u003e /home/your_user/motion_detection.log 2\u003e\u00261 \u0026\n        ;;\n    stop)\n        echo \"stop motion detection...\"\n        # stop all Python3-commands\n        pkill -f \"/home/your_user/motion_detection.py\"\n        ;;\n    *)\n        echo \"Usage: /etc/init.d/motion_detector {start|stop}\"\n        exit 1\n        ;;\nesac\n \nexit 0\n```\nHere you must edit a few things.\nPlease be save, that your path of the Python script is correct.\nIn my example is the path ```/home/your_user/motion_detection.py```.\nIf you're not sure, what the right path is, go in he folder where your Python script is and type in: ```pwd```\nThis command outputs the complete path in which you are located. Now you only need to append the name of your script and you have the complete path.\nKeep in mind that if you **stop this service**, **all Python3 scripts will be terminated**.\n\nAfter that, we give the script more rights.\n```\nsudo chmod 755 /etc/init.d/motion_detector\n```\nNote that this path must be the same as the one you specified earlier.\n\nNow you can add this service to autostart.\n```\nsudo update-rc.d motion_detector defaults\n```\nHere too, use the same name as the service!\n\nIf you don't want autostart anymore, run this:\n```\nsudo update-rc.d -f motion_detector remove\n```\nAnd when you want to start/stop your script manually, you can do this:\n```\nsudo /etc/init.d/motion_detector start\n```\n```\nsudo /etc/init.d/motion_detector stop\n```\n\n# picture_url\nThis is an extra thing because you have the choice to select my default URL.\n```\nhttps://img.icons8.com/ios-glyphs/60/FF0000/motion-detector.png\n```\nCopyright of this Icon: [Motion Detector](https://icons8.com/icon/77544/motion-detector) icon by [Icons8](https://icons8.com)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feasytecrepository%2Fmotion-detector","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Feasytecrepository%2Fmotion-detector","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feasytecrepository%2Fmotion-detector/lists"}