{"id":15290597,"url":"https://github.com/bndw/security-camera","last_synced_at":"2025-04-15T16:37:42.728Z","repository":{"id":64297354,"uuid":"157303651","full_name":"bndw/security-camera","owner":"bndw","description":"🔦 Motion detecting security camera using a raspberry pi, webcam, and slack","archived":false,"fork":false,"pushed_at":"2020-12-30T17:29:27.000Z","size":1303,"stargazers_count":118,"open_issues_count":0,"forks_count":15,"subscribers_count":6,"default_branch":"master","last_synced_at":"2024-05-02T01:07:49.953Z","etag":null,"topics":["cctv","diy","motion-detection","raspberry-pi","s3","security-camera","slack","webcam"],"latest_commit_sha":null,"homepage":"","language":"Go","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/bndw.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-11-13T01:47:57.000Z","updated_at":"2023-12-09T19:09:26.000Z","dependencies_parsed_at":"2023-01-15T08:45:44.058Z","dependency_job_id":null,"html_url":"https://github.com/bndw/security-camera","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bndw%2Fsecurity-camera","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bndw%2Fsecurity-camera/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bndw%2Fsecurity-camera/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bndw%2Fsecurity-camera/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bndw","download_url":"https://codeload.github.com/bndw/security-camera/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249109588,"owners_count":21214174,"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":["cctv","diy","motion-detection","raspberry-pi","s3","security-camera","slack","webcam"],"created_at":"2024-09-30T16:08:44.307Z","updated_at":"2025-04-15T16:37:42.709Z","avatar_url":"https://github.com/bndw.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Security camera\n\n[![Build Status](https://travis-ci.org/bndw/security-camera.svg?branch=master)](https://travis-ci.org/bndw/security-camera)\n\nThis is a guide to creating a simple motion sensing security camera using a Raspberry Pi, USB \nwebcam, Amazon S3, Slack. Anytime motion is detected images will be captured, uploaded to S3\nand sent to a Slack channel.\n\n![example](./resources/example.png)\n\n- [Prerequisites](#prerequisites)\n  - [Raspberry pi](#raspberry-pi)\n  - [USB Webcam](#usb-webcam)\n  - [Golang](#golang)\n- [Device Setup](#device-setup)\n  - [Install dependencies](#install-dependencies)\n  - [Configure motion](#configure-motion)\n- [S3 setup](#s3-setup)\n- [Slack setup](#slack-setup)\n- [Uploading images](#uploading-images)\n\n\n# Prerequisites\n\n## Raspberry Pi\n\n[RaspberryPi 3](https://www.raspberrypi.org/products/raspberry-pi-3-model-b/) is used for this build.\nThey include builtin Wi-Fi, making them well suited for this usecase.\n\nConfigure the Raspberry Pi as follows:\n- [Raspbian Stretch Lite](https://www.raspberrypi.org/downloads/raspbian/) is the OS this guide was tested with\n- Setup ssh access to the pi\n- Connect the pi to your wireless network\n\nSetting up ssh access and configuring the wireless is outside of the scope of this guide.\nI've found [this guide](https://medium.com/@danidudas/install-raspbian-jessie-lite-and-setup-wi-fi-without-access-to-command-line-or-using-the-network-97f065af722e) to \nbe helpful for that.\n\n## USB Webcam\n\nA USB webcam is used for this project. Any USB camera should do, I'm using a [Logitech C920 Webcam](https://www.amazon.com/gp/product/B006JH8T3S).\n\n# Device Setup\n\n## Install dependencies\n\n```\nssh pi@raspberrypi.local\n\n# usb camera support and motion\nsudo apt-get update -y \u0026\u0026 sudo apt-get install -y fswebcam motion\n```\n\nTest the camera with `fswebcam`\n```\nfswebcam image.jpg\n```\n```\n--- Opening /dev/video0...\nTrying source module v4l2...\n/dev/video0 opened.\nNo input was specified, using the first.\nAdjusting resolution from 384x288 to 352x288.\n--- Capturing frame...\nCaptured frame in 0.00 seconds.\n--- Processing captured image...\nWriting JPEG image to 'image.jpg'.\n```\n\nNow we know our webcam is at `/dev/video0`. If you look at `image.jpg` you'll see the picture it took.\n\n## Configure motion\n\n[Motion](https://motion-project.github.io/) is used to monitor the camera.\n\nEdit the following settings in the motion configuration file at `/etc/motion/motion.conf`\n\n```\n# Make sure the proper camera device is set\nvideodevice /dev/video0\n\n# Tell motion to run as a background service\ndaemon on\n```\n\nEdit `/etc/default/motion` and set `start_motion_daemon=yes`\n```\nstart_motion_daemon=yes\n```\n\nAnd restart the system\n```\nreboot\n```\n\nOnce it comes back up open another ssh connection.\n\nConfirm motion is running\n```\nsystemctl status motion\n```\n\nAt this point motion is running as a background service and will be automatically\nstarted after a reboot. The next section will guide you through uploading the images\nto AWS S3 and notifying a Slack channel.\n\n# S3 Setup\n\n1. Create an S3 bucket, noting the name and region\n2. Create an IAM user, noting the AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY\n3. Create and attach an IAM policy to the user, allowing them to upload to the S3 bucket\n  ```\n  {\n      \"Version\": \"2012-10-17\",\n      \"Statement\": [\n          {\n              \"Sid\": \"securitycamera\",\n              \"Effect\": \"Allow\",\n              \"Action\": [\n                  \"s3:PutObject\",\n                  \"s3:PutObjectAcl\"\n              ],\n              \"Resource\": \"arn:aws:s3:::YOUR-BUCKET-NAME/*\"\n          }\n      ]\n  }\n  ```\n\n# Slack Setup\n\n1. Create a [Slack incoming webhook](https://api.slack.com/incoming-webhooks)\n2. Note the Webhook URL, e.g. https://hooks.slack.com/services/xxx/yyy/zzzzz\n\n# Uploading images\n\nWhen motion is detected a new image is created and the `on_picture_save` script is invoked. This calls the `uploader` which uploads the image to S3. Download the [latest release](https://github.com/bndw/security-camera/releases/latest) of the uploader and save it in `./root/usr/local/bin/uploader`.\n\nOr, build from source if you have Go 1.13 or later:\n```\nmake build\n```\n\nNext, upload both programs to the pi\n```\nscp ./root/usr/local/bin/* pi@raspberrypi.local:/tmp/\n```\n\nSSH to the pi to complete configuration\n```\nssh pi@raspberrypi.local\n\n# Copy the scripts into the PATH\nsudo mv /tmp/{uploader,on_picture_save} /usr/local/bin/\n```\n\nEdit `/usr/local/bin/on_picture_save` and add your AWS and Slack secrets:\n```\n# /usr/local/bin/on_picture_save\n\nSLACK_WEBHOOK_URL=https://hooks.slack.com/services/your/slack/webhook\nS3_BUCKET_NAME=my-bucket-name\nS3_BUCKET_REGION=us-west-2\nAWS_ACCESS_KEY=xxx\nAWS_SECRET_KEY=xxxxx\n```\n\nOpen the motion config again and configure it to call the `on_picture_save` script everytime it creates an image.\n```\n# /etc/motion/motion.conf\non_picture_save /usr/local/bin/on_picture_save %f\n```\n\nRestart motion\n```\nsystemctl restart motion\n```\n\nYou should be good to go. Check out the motion detection settings in `/etc/motion/motion.conf` for customizing thresholds, etc.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbndw%2Fsecurity-camera","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbndw%2Fsecurity-camera","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbndw%2Fsecurity-camera/lists"}