{"id":28939227,"url":"https://github.com/varadrane12/motion-activated-security-camera","last_synced_at":"2026-04-11T19:02:29.863Z","repository":{"id":295927894,"uuid":"991434801","full_name":"VaradRane12/Motion-Activated-Security-Camera","owner":"VaradRane12","description":"A Raspberry Pi-based smart surveillance system with motion detection, live streaming, light and siren automation, ESP-NOW sensor integration, and cloud video uploads.","archived":false,"fork":false,"pushed_at":"2025-09-04T18:16:17.000Z","size":4683,"stargazers_count":2,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-01-03T14:14:34.185Z","etag":null,"topics":["automation","aws","computer-vision","esp-now","esp32","esp8266","flask","flask-sqlalchemy","iot","live-streaming","motion-detection","mqtt","raspberry-pi","s3","scheduler","security-camera","siren","surveillance","video-upload"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/VaradRane12.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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,"zenodo":null}},"created_at":"2025-05-27T16:07:35.000Z","updated_at":"2025-10-07T14:39:31.000Z","dependencies_parsed_at":"2025-05-28T04:55:29.099Z","dependency_job_id":"71b186fd-22d1-4f74-bc36-f23e1f50d997","html_url":"https://github.com/VaradRane12/Motion-Activated-Security-Camera","commit_stats":null,"previous_names":["varadrane12/motion-activated-security-camera"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/VaradRane12/Motion-Activated-Security-Camera","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/VaradRane12%2FMotion-Activated-Security-Camera","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/VaradRane12%2FMotion-Activated-Security-Camera/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/VaradRane12%2FMotion-Activated-Security-Camera/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/VaradRane12%2FMotion-Activated-Security-Camera/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/VaradRane12","download_url":"https://codeload.github.com/VaradRane12/Motion-Activated-Security-Camera/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/VaradRane12%2FMotion-Activated-Security-Camera/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31691503,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-11T13:07:20.380Z","status":"ssl_error","status_checked_at":"2026-04-11T13:06:47.903Z","response_time":54,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["automation","aws","computer-vision","esp-now","esp32","esp8266","flask","flask-sqlalchemy","iot","live-streaming","motion-detection","mqtt","raspberry-pi","s3","scheduler","security-camera","siren","surveillance","video-upload"],"created_at":"2025-06-23T00:07:18.129Z","updated_at":"2026-04-11T19:02:29.836Z","avatar_url":"https://github.com/VaradRane12.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Motion‑Activated Security Camera\r\n\r\nA DIY **motion-triggered surveillance system** using **Raspberry Pi** and **Esp-01**. Captures video/images on motion, uploads to AWS or stores locally, and is controlled through a web dashboard using Flask. Secured remote access via **Cloudflare Tunnel**.\r\n\r\n---\r\n\r\n## Features\r\n- Motion-triggered video/image capture\r\n- Flask web interface (accessible remotely)\r\n- AWS S3 integration for cloud storage\r\n- Esp-01-based relay logic for:\r\n  - Light automation\r\n  - Remote doorbell\r\n- Timed light switch control\r\n- Remote doorbell triggering\r\n- Remote pause/resume of motion detection\r\n- Real-time Discord alert logging (motion, doorbell, errors)\r\n\r\n---\r\n\r\n## Project Structure\r\n```bash\r\nMotion-Activated-Security-Camera/\r\n├── flask/                  # Flask backend for UI and API endpoints\r\n├── ESP_CODES/                # Esp-01 firmware code (PIR sensor, light, doorbell)\r\n├── script.py               # Core script: motion detection and camera logic\r\n├── Light_timed_switch.py  # Controls light with a time-based switch\r\n├── requirements.txt        # List of required Python packages\r\n├── DOCUMENTATION/          # Diagrams, configuration, and supporting documents\r\n└── README.md               # Project overview and setup instructions\r\n```\r\n## Requirements\r\n\r\n### Hardware\r\n- Raspberry Pi (with PiCamera2)\r\n- Esp-01 (ESP8266)\r\n- PIR Motion Sensor\r\n- Relay modules\r\n- 2N2222A BJT transistors (for relay switching)\r\n- Buzzer or doorbell unit (optional)\r\n- LED light or bulb\r\n\r\n### Software\r\n- Python 3.11.2+\r\n- Flask\r\n- OpenCV\r\n- picamera2\r\n- boto3\r\n- requests\r\n- RPi.GPIO\r\n- dotenv (for loading env variables)\r\n- gunicorn (optional, production-grade Flask server)\r\n\r\nInstall Python dependencies:\r\n```bash\r\npip3 install -r requirements.txt\r\n```\r\n---\r\n## Setup Instructions\r\n\r\n### Hardware \u0026 Schematics\r\n\r\n- Connected to **Raspberry Pi GPIO**\r\n- **Light \u0026 Doorbell Relay** → Controlled via **Esp-01 GPIOs**\r\n- **Transistor (2N2222A)** is used to drive relays safely\r\n\r\nFull schematic diagram :\r\n![Rasbperrypi setup](Schematic_Home-Automation_2025-06-23/Raspberypi_Motion_Sensor.png)\r\n![DoorBell extender Schematic](Schematic_Home-Automation_2025-06-23/DoorBell_Control.png)\r\n![Light Control Schematic](Schematic_Home-Automation_2025-06-23/Light_and_reed_switch_Control.png)\r\n\r\n## AWS S3 Setup (Cloud Storage)\r\n\r\nThis project supports **automatic upload of captured videos/images to AWS S3** for cloud storage and remote access.  \r\n\r\nFollow these steps to set it up:\r\n\r\n### 1. Create an AWS Account\r\n- Go to [AWS Signup](https://aws.amazon.com/) and create a free account.  \r\n- Log in to the **AWS Management Console**.  \r\n\r\n### 2. Create an S3 Bucket\r\n1. In the AWS console, search for **S3** and open it.  \r\n2. Click **Create bucket**.  \r\n3. Enter a **unique bucket name** (e.g., `my-security-cam-bucket`).  \r\n4. Select your **AWS Region** (e.g., `ap-south-1`).  \r\n5. Keep the default settings and click **Create bucket**.  \r\n\r\n### 4. Create an IAM User (for Programmatic Access)\r\n1. Go to **IAM** in the AWS console.  \r\n2. Click **Users → Add users**.  \r\n3. Enter a username (e.g., `cam-upload-user`).  \r\n4. Enable **Programmatic access**.  \r\n5. Attach policy: **AmazonS3FullAccess** (or create a custom policy for stricter control).  \r\n6. Complete setup and download the `.csv` file with your **Access Key ID** and **Secret Access Key**.  \r\n\r\n### 5. Configure Environment Variables\r\nCreate a `.env` file in your project root and add:  \r\n\r\n```ini\r\nAWS_ACCESS_KEY_ID=your_access_key_id\r\nAWS_SECRET_ACCESS_KEY=your_secret_access_key\r\nBUCKET_NAME=your_bucket_name\r\nREGION_NAME=ap-south-1\r\n```\r\n### 2. Flask Web Server\r\n\r\nRun the Flask server on your Raspberry Pi:\r\n\r\n```bash\r\ncd flask\r\nflask run --host=0.0.0.0 --port=8000\r\n```\r\nOr, for better stability in production:\r\n\r\n```bash\r\ngunicorn -w 2 -b 0.0.0.0:8000 app:app\r\n```\r\nThe web interface will be accessible at:\r\n```bash\r\nhttp://\u003craspberry-pi-ip\u003e:8000\r\n```\r\n### 3. Motion Detection Script\r\n\r\nRun the motion detection script on your Raspberry Pi:\r\n\r\n```bash\r\npython3 script.py\r\n```\r\nThis script will:\r\n\r\n- Monitor motion via PiCamera and/or GPIO input\r\n\r\n- Capture video or image upon detection\r\n\r\n-  Upload media to AWS S3 or store it locally\r\n\r\n-  Log events to a Discord channel using webhooks\r\n\r\n\r\n### 4. Timed Light Control (Optional)\r\n\r\nThis script allows automatic control of a light with a timeout (e.g., turn off after 60 seconds).\r\n\r\nRun the script:\r\n\r\n```bash\r\npython3 Light_timed_switch.py\r\n```\r\n#### \u0026nbsp; Hardware Requirements\r\n\r\n- **Esp-01 ESP8266** – Receives the control signal and drives the relay\r\n- **Relay Module** – Used to switch the AC light ON/OFF\r\n- **BJT (e.g., 2N2222A or BC547)** – Acts as a switch to safely drive the relay from the Esp-01's GPIO\r\n- **External Power Source** – Required if the relay module is not compatible with 3.3V (Esp-01 GPIO voltage)\r\n\r\nNOTE: Ensure proper current limiting resistors between Esp-01 and BJT base, and isolate the relay circuit as needed for safety.\r\n\r\n### 5. Flash Esp-01\r\n\r\nUse **Arduino IDE** or **PlatformIO** to flash the firmware.\r\n\r\n1. Open the code inside the `Esp-01/` directory.\r\n2. Update the following in the source file:\r\n   - **Wi-Fi SSID \u0026 Password**\r\n   - **Flask server IP address** and API endpoints\r\n\r\n---\r\n\r\n#### Esp-01 Handles:\r\n\r\n- **Light Toggle** via Relay Module\r\n- **Doorbell Trigger** via Relay/Buzzer\r\n\r\nMake sure to select the correct board (**Esp-01 1.0 (ESP-12E Module)**) and port in the Arduino IDE before flashing.\r\n\r\n### 6. AWS S3 Setup (Optional)\r\n\r\nTo enable automatic upload of captured videos/images to AWS S3:\r\n\r\n1. Edit the `.env` file:\r\n\r\n```bash\r\nAWS_ACCESS_KEY_ID=your_key\r\nAWS_SECRET_ACCESS_KEY=your_secret\r\nBUCKET_NAME=your_bucket\r\nREGION_NAME=ap-south-1\r\n```\r\n### 7. Discord Logging\r\n\r\nTo enable Discord alerts for system events:\r\n\r\n1. Create a **webhook** in your Discord channel.\r\n2. Add the webhook URL to your `.env` file:\r\n\r\n```ini\r\nDISCORD_WEBHOOK_URL=https://discord.com/api/webhooks/your_webhook\r\n```\r\n### 8. Remote Access via Cloudflare Tunnel\r\n\r\nYou can expose your Flask server securely over HTTPS using a **Cloudflare Tunnel**.\r\n\r\n#### Steps to Set Up:\r\n\r\n1. **Install and authenticate Cloudflare Tunnel**:\r\n\r\n```bash\r\ncloudflared tunnel login\r\n```\r\n2. **Create a tunnel**:\r\n\r\n```bash\r\ncloudflared tunnel create cam-tunnel\r\n```\r\n### Usage Flow\r\n\r\n1. **Flask server** starts and renders the user interface.\r\n2. `script.py` runs in the background and **watches for motion** using the PiCamera and/or GPIO.\r\n\r\n---\r\n\r\n#### When Motion is Detected:\r\n\r\n- **Record video** or **capture image**\r\n- **Upload to AWS S3** (if enabled)\r\n- **Send a log to Discord** with media attached\r\n\r\n---\r\n\r\n#### Web UI Enables:\r\n\r\n- **Pause/Resume** motion detection\r\n- **Trigger Doorbell** manually\r\n- **Toggle or Schedule Light** (via Esp-01)\r\n- **View Camera Feed** (if live feed option is implemented)\r\n\r\n\u003e Designed for quick access and remote control of your home security system.\r\n\r\n## Screenshots/Photos\r\n# Smart Doorbell \u0026 Light Control System\r\n\r\n## Full System View\r\n\u003cimg src=\"photos/Full_doorbell.jpg\" alt=\"Full Doorbell\" width=\"400\"/\u003e\r\n\r\n## Doorbell Module\r\n\u003cimg src=\"photos/doorbell_module.jpg\" alt=\"Doorbell Module\" width=\"400\"/\u003e\r\n\r\n## Light Control System\r\n\u003cimg src=\"photos/light_control.jpg\" alt=\"Light Control\" width=\"400\"/\u003e\r\n\r\n## Internal Module\r\n\u003cimg src=\"photos/module.jpg\" alt=\"Module\" width=\"400\"/\u003e\r\n\r\n## Installed Module\r\n\u003cimg src=\"photos/module_installed.jpg\" alt=\"Module Installed\" width=\"400\"/\u003e\r\n\r\n## Soldering Process\r\n\u003cimg src=\"photos/soldering.jpg\" alt=\"Soldering\" width=\"400\"/\u003e\r\n\r\n## Web Dashboard\r\n\u003cimg src=\"photos/website.png\" alt=\"Website\" width=\"400\"/\u003e\r\n\r\n---\r\n\r\n### License\r\n\r\nThis project is licensed under the **MIT License**.  \r\nFree to use, modify, and distribute for personal or commercial purposes!\r\n\r\n---\r\n\r\n### Contributing\r\n\r\nContributions are welcome!\r\n\r\nTo contribute:\r\n\r\n1. **Fork** the repository\r\n2. Create a new branch:  \r\n   ```bash\r\n   git checkout -b feature/add-thing\r\n   ```\r\n3. Commit your changes and push:\r\n\r\n```bash\r\ngit commit -m \"Add new feature\"\r\n```\r\n```bash\r\ngit push origin feature/add-thing\r\n```\r\n4. Open a Pull Request with a clear and detailed description\r\n\r\n### Credits\r\n\r\nDeveloped with ❤️ by **Varad Rane**  \r\n🔗 GitHub: [@VaradRane12](https://github.com/VaradRane12)\r\n\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvaradrane12%2Fmotion-activated-security-camera","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvaradrane12%2Fmotion-activated-security-camera","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvaradrane12%2Fmotion-activated-security-camera/lists"}