├── 3d-prints ├── base-top.stl ├── lid-lens.stl ├── base-bottom.stl ├── lid-back-cover.stl ├── breadboard-base-top.stl ├── neck-thread-support.stl └── breadboard-base-bottom.stl ├── images ├── arm-wave-near.jpeg ├── pi-smart-cam-featured.jpg ├── email-notification-min.png ├── open-nest-cam-promo-3-min.JPG └── open-nest-cam-ports-back-min.JPG ├── schematics ├── make-pi-camera-nest.drawio.png ├── pi-cam-stream-block-diagram.png ├── pi-camera-breadboard-button.fzz ├── pi-stream-cam-block-diagram.png ├── pi-camera-breadboard-button_bb.png ├── pi-camera-breadboard-pir-sensor.fzz └── pi-camera-breadboard-pir-sensor_bb.png ├── code ├── .gitignore ├── examples │ ├── video-usb-enabled │ │ ├── camera.py │ │ ├── main.py │ │ └── templates │ │ │ └── index.html │ └── pi-camera-stream-pir-sensor │ │ ├── camera.py │ │ ├── arduino_comms.py │ │ ├── email_notification.py │ │ ├── main.py │ │ └── templates │ │ └── index.html ├── LICENSE └── arduino │ └── pir-motion-sensor │ └── pir-motion-sensor.ino ├── .gitignore └── README.md /3d-prints/base-top.stl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EbenKouao/pi-smart-cam/HEAD/3d-prints/base-top.stl -------------------------------------------------------------------------------- /3d-prints/lid-lens.stl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EbenKouao/pi-smart-cam/HEAD/3d-prints/lid-lens.stl -------------------------------------------------------------------------------- /3d-prints/base-bottom.stl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EbenKouao/pi-smart-cam/HEAD/3d-prints/base-bottom.stl -------------------------------------------------------------------------------- /images/arm-wave-near.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EbenKouao/pi-smart-cam/HEAD/images/arm-wave-near.jpeg -------------------------------------------------------------------------------- /3d-prints/lid-back-cover.stl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EbenKouao/pi-smart-cam/HEAD/3d-prints/lid-back-cover.stl -------------------------------------------------------------------------------- /images/pi-smart-cam-featured.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EbenKouao/pi-smart-cam/HEAD/images/pi-smart-cam-featured.jpg -------------------------------------------------------------------------------- /3d-prints/breadboard-base-top.stl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EbenKouao/pi-smart-cam/HEAD/3d-prints/breadboard-base-top.stl -------------------------------------------------------------------------------- /3d-prints/neck-thread-support.stl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EbenKouao/pi-smart-cam/HEAD/3d-prints/neck-thread-support.stl -------------------------------------------------------------------------------- /images/email-notification-min.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EbenKouao/pi-smart-cam/HEAD/images/email-notification-min.png -------------------------------------------------------------------------------- /3d-prints/breadboard-base-bottom.stl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EbenKouao/pi-smart-cam/HEAD/3d-prints/breadboard-base-bottom.stl -------------------------------------------------------------------------------- /images/open-nest-cam-promo-3-min.JPG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EbenKouao/pi-smart-cam/HEAD/images/open-nest-cam-promo-3-min.JPG -------------------------------------------------------------------------------- /images/open-nest-cam-ports-back-min.JPG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EbenKouao/pi-smart-cam/HEAD/images/open-nest-cam-ports-back-min.JPG -------------------------------------------------------------------------------- /schematics/make-pi-camera-nest.drawio.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EbenKouao/pi-smart-cam/HEAD/schematics/make-pi-camera-nest.drawio.png -------------------------------------------------------------------------------- /schematics/pi-cam-stream-block-diagram.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EbenKouao/pi-smart-cam/HEAD/schematics/pi-cam-stream-block-diagram.png -------------------------------------------------------------------------------- /schematics/pi-camera-breadboard-button.fzz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EbenKouao/pi-smart-cam/HEAD/schematics/pi-camera-breadboard-button.fzz -------------------------------------------------------------------------------- /schematics/pi-stream-cam-block-diagram.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EbenKouao/pi-smart-cam/HEAD/schematics/pi-stream-cam-block-diagram.png -------------------------------------------------------------------------------- /schematics/pi-camera-breadboard-button_bb.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EbenKouao/pi-smart-cam/HEAD/schematics/pi-camera-breadboard-button_bb.png -------------------------------------------------------------------------------- /schematics/pi-camera-breadboard-pir-sensor.fzz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EbenKouao/pi-smart-cam/HEAD/schematics/pi-camera-breadboard-pir-sensor.fzz -------------------------------------------------------------------------------- /schematics/pi-camera-breadboard-pir-sensor_bb.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EbenKouao/pi-smart-cam/HEAD/schematics/pi-camera-breadboard-pir-sensor_bb.png -------------------------------------------------------------------------------- /code/.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | 3 | # misc 4 | .DS_Store 5 | *.pem 6 | 7 | # local env files 8 | env 9 | .env/ 10 | .env 11 | .env.local 12 | .env.development.local 13 | .env.test.local 14 | .env.production.local 15 | dev.env 16 | 17 | #logs 18 | *.log 19 | 20 | 21 | #_pycache 22 | __pycache__/ 23 | 24 | -------------------------------------------------------------------------------- /code/examples/video-usb-enabled/camera.py: -------------------------------------------------------------------------------- 1 | #Modified by smartbuilds.io 2 | #Date: 01.05.22 3 | 4 | import cv2 5 | import numpy as np 6 | import os 7 | ds_factor=1 8 | 9 | process_this_frame = True 10 | 11 | class VideoCamera(object): 12 | def __init__(self): 13 | self.video = cv2.VideoCapture(0) #Use this for USB cameras / non pi camera module 14 | 15 | def __del__(self): 16 | self.video.release() 17 | 18 | def get_frame(self): 19 | success, image = self.video.read() 20 | image=cv2.resize(image,None,fx=ds_factor,fy=ds_factor,interpolation=cv2.INTER_AREA) 21 | process_this_frame = True 22 | 23 | process_this_frame = not process_this_frame 24 | 25 | ret, jpeg = cv2.imencode('.jpg', image) 26 | return jpeg.tobytes() 27 | 28 | -------------------------------------------------------------------------------- /code/examples/pi-camera-stream-pir-sensor/camera.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | #Modified by smartbuilds.io 4 | #Date: 07.05.22 5 | #Desc: 6 | 7 | import cv2 8 | from imutils.video.pivideostream import PiVideoStream 9 | import imutils 10 | import time 11 | import numpy as np 12 | 13 | class VideoCamera(object): 14 | def __init__(self, flip = False): 15 | self.vs = PiVideoStream().start() 16 | self.flip = flip 17 | time.sleep(2.0) 18 | 19 | def __del__(self): 20 | self.vs.stop() 21 | 22 | def flip_if_needed(self, frame): 23 | if self.flip: 24 | return np.flip(frame, 0) 25 | return frame 26 | 27 | def get_frame(self): 28 | frame = self.flip_if_needed(self.vs.read()) 29 | ret, jpeg = cv2.imencode('.jpg', frame) 30 | return jpeg.tobytes() -------------------------------------------------------------------------------- /code/examples/video-usb-enabled/main.py: -------------------------------------------------------------------------------- 1 | # Use ths example if you are using a USB Camera (instead of a pi cam) 2 | 3 | from flask import Flask, render_template, Response, request 4 | from camera import VideoCamera 5 | import time 6 | 7 | app = Flask(__name__) 8 | 9 | @app.route('/', methods=['GET', 'POST']) 10 | def index(): 11 | return render_template('index.html') #you can customize index.html here 12 | 13 | def gen(camera): 14 | while True: 15 | frame = camera.get_frame() 16 | yield (b'--frame\r\n' 17 | b'Content-Type: image/jpeg\r\n\r\n' + frame + b'\r\n\r\n') 18 | 19 | @app.route('/video_stream') 20 | def video_feed(): 21 | return Response(gen(VideoCamera()), 22 | mimetype='multipart/x-mixed-replace; boundary=frame') 23 | 24 | if __name__ == '__main__': 25 | app.run(host='0.0.0.0', port=5001, debug=True, threaded=True) 26 | # app.run(debug=True) 27 | -------------------------------------------------------------------------------- /code/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) SmartBuilds.io, Inc. and its affiliates. 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /code/examples/pi-camera-stream-pir-sensor/arduino_comms.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | #Description: Arduino -> Pi Comms for reading PIR Sensor Values 3 | 4 | import serial 5 | import time 6 | from email_notification import sendMessage 7 | import sys 8 | from camera import VideoCamera 9 | 10 | def take_picture(pi_email, pi_app_password, pi_port, pi_host, frame): 11 | try: 12 | sendMessage(pi_email, pi_app_password, pi_port, pi_host, frame) 13 | except: 14 | print("Error Sending Notification: ", sys.exc_info()[0]) 15 | 16 | def arduino_pi_comms(ser, sensitivity_timer, current_time, pi_email, pi_app_password, pi_port, pi_host, frame): 17 | while True: 18 | if ser.in_waiting > 0: 19 | line = ser.readline().decode('utf-8').rstrip() 20 | 21 | # Change sensitivity_time to 10 seconds (default 30 seconds) to execute a motion trigger 22 | print("Motion Detected | Sensitivity Timeout", sensitivity_timer, "|", "Time since last motion trigger",time.time()- current_time) 23 | 24 | 25 | if(line == "1"): #if pir sensor value = 1/high 26 | detected = True 27 | 28 | # only send email notification if motion is detected after X seconds 29 | if(int(time.time() - current_time) > sensitivity_timer): 30 | 31 | current_time = time.time() 32 | print("Arduino Output:", line) # print output from Arduino Comms 33 | if(detected == True): 34 | detected = False 35 | take_picture(pi_email, pi_app_password, pi_port, pi_host, frame) 36 | 37 | 38 | # local testing 39 | # arduino_pi_comms(ser, sensitivity_timer, current_time, pi_email, pi_app_password, pi_port, pi_host) -------------------------------------------------------------------------------- /code/examples/pi-camera-stream-pir-sensor/email_notification.py: -------------------------------------------------------------------------------- 1 | """ 2 | Improve Password Security (Application) 3 | ============================================= 4 | Use .env variables. 5 | Access to less secure apps is turned on 6 | - Use a dedicated email address 7 | - Enable 2FA and use App Password to avoid storing your password in plain text. 8 | https://support.google.com/accounts/answer/185833?hl=en 9 | 10 | Note: Check the Spam folder (as it may automatically route alerts there) 11 | """ 12 | 13 | import email 14 | import smtplib 15 | from email.mime.multipart import MIMEMultipart 16 | from email.mime.text import MIMEText 17 | from email.mime.image import MIMEImage 18 | 19 | # Send Email Function to target email address 20 | def sendMessage(pi_email, pi_app_password, pi_port, pi_host, image): 21 | # Receiver (Email to send camera activity to) 22 | notification_recipient = "" 23 | 24 | try: 25 | msgRoot = MIMEMultipart('related') 26 | msgRoot['Subject'] = 'Pi Smart Cam: New Activity Detected' 27 | msgRoot['From'] = pi_email 28 | msgRoot['To'] = notification_recipient 29 | msgRoot.preamble = 'New Activity Detected' 30 | 31 | msgAlternative = MIMEMultipart('alternative') 32 | msgRoot.attach(msgAlternative) 33 | msgText = MIMEText('Motion Captured:') 34 | msgAlternative.attach(msgText) 35 | 36 | msgText = MIMEText('', 'html') 37 | msgAlternative.attach(msgText) 38 | 39 | msgImage = MIMEImage(image) 40 | msgImage.add_header('Content-ID', '') 41 | msgRoot.attach(msgImage) 42 | 43 | server = smtplib.SMTP_SSL(pi_host, pi_port) 44 | server.login(pi_email, pi_app_password) 45 | print("Sending Notification.") 46 | server.sendmail(pi_email, notification_recipient, msgRoot.as_string()) 47 | server.quit() 48 | print("Notification Sent.") 49 | 50 | except: 51 | print("Notification not sent: Invalid email credentials") 52 | return "Invalid email credentials" 53 | 54 | -------------------------------------------------------------------------------- /code/arduino/pir-motion-sensor/pir-motion-sensor.ino: -------------------------------------------------------------------------------- 1 | /* Creator: @Smartbuilds.io 2 | * Date: 01.05.22 3 | * 4 | * Arduino PIR Camera Sensor 5 | * Description: Arduino reads input/sensor value and communicates to the Raspberry Pi 6 | */ 7 | 8 | int pirSensor = 8; // Arduino Digital Pin 8 9 | 10 | const int buttonPin = 2; // the number of the pushbutton pin 11 | const int ledPin = 5; // the number of the LED pin 12 | int buttonState = 0; // button state 0 LOW, 1 HIGH 13 | 14 | int pinStateCurrent = LOW; // current state of pin 15 | int pinStatePrevious = LOW; // previous state of pin 16 | 17 | void setup() { 18 | 19 | // Initial PIR Sensor 20 | pinMode(pirSensor, INPUT); 21 | Serial.begin(9600); 22 | 23 | // initialize the LED pin as an output: 24 | pinMode(ledPin, OUTPUT); 25 | 26 | // initialize the pushbutton pin as an input: 27 | pinMode(buttonPin, INPUT); 28 | digitalWrite(ledPin, LOW); 29 | 30 | } 31 | 32 | void loop() { 33 | 34 | pinStatePrevious = pinStateCurrent; // store previous state of motion sensor 35 | pinStateCurrent = digitalRead(pirSensor); 36 | 37 | if (pinStatePrevious == LOW && pinStateCurrent == HIGH){ 38 | 39 | Serial.write("1"); // Send message to the Raspberry pi - Motion Detected 40 | digitalWrite(ledPin, LOW); 41 | 42 | }else if (pinStatePrevious == HIGH && pinStateCurrent == LOW) { 43 | 44 | Serial.println("0"); // Motion stopped - Send message to the Raspberry pi 45 | digitalWrite(ledPin, HIGH); 46 | 47 | } 48 | 49 | } 50 | 51 | // Create your own Button/Ring Button - When Pressed sends comms to the Pi to trigger an action 52 | 53 | // read the state of the pushbutton value: 54 | // buttonState = digitalRead(buttonPin); 55 | 56 | // check if the pushbutton is pressd i.e. the buttonState is HIGH: 57 | // if (buttonState == HIGH) { 58 | // // turn LED on: 59 | // Serial.write("ring-ring/"); // Send message to the Raspberry Pi 60 | // digitalWrite(ledPin, HIGH); 61 | // delay(3000); 62 | // } else { 63 | // // turn LED off: 64 | // digitalWrite(ledPin, LOW); 65 | // } 66 | 67 | //} 68 | -------------------------------------------------------------------------------- /code/examples/pi-camera-stream-pir-sensor/main.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | """ 3 | Modified by smartbuilds.io 4 | Date: 26.07.22 5 | 6 | # main.py 7 | Desc: This web application serves a motion JPEG stream and sends an image 8 | notification to your email on motion detected via a PIR sensor 9 | 10 | # install the necessary packages 11 | """ 12 | from flask import Flask, render_template, Response, request 13 | from camera import VideoCamera 14 | from arduino_comms import arduino_pi_comms 15 | import time 16 | import threading 17 | import os 18 | import sys 19 | import serial 20 | 21 | current_time = time.time() #initialise current time on run 22 | 23 | # How long before ACK motion and sending notification 24 | sensitivity_timer = 30 25 | 26 | # View email_notification for setup 27 | pi_email = "" 28 | pi_app_password = "" 29 | pi_port = 465 30 | pi_host = "smtp.gmail.com" 31 | 32 | pi_camera = VideoCamera(flip=False) # flip pi camera if upside down. 33 | 34 | app = Flask(__name__) 35 | 36 | @app.route('/') 37 | def index(): 38 | return render_template('index.html') #you can customze index.html here 39 | 40 | def gen(camera): 41 | while True: 42 | frame = camera.get_frame() 43 | yield (b'--frame\r\n' 44 | b'Content-Type: image/jpeg\r\n\r\n' + frame + b'\r\n\r\n') 45 | 46 | def gen_capture(camera): 47 | frame = camera.get_frame() 48 | return frame 49 | 50 | @app.route('/video_feed') 51 | def video_feed(): 52 | return Response(gen(pi_camera), 53 | mimetype='multipart/x-mixed-replace; boundary=frame') 54 | 55 | if __name__ == '__main__': 56 | # device USB name e.g. /dev/ttyACM0 or /dev/ttyUSB0 if connected 57 | try: 58 | ser = serial.Serial('/dev/ttyUSB0', 9600, timeout=1) 59 | ser.reset_input_buffer() 60 | 61 | if ser: 62 | # Create a thread for parallel processing/ multithreading (camera stream and PIR Sensor trigger) 63 | arduino_comms_thread = threading.Thread(target=arduino_pi_comms, args=(ser, sensitivity_timer, current_time, pi_email, pi_app_password, pi_port, pi_host, gen_capture(pi_camera))) 64 | arduino_comms_thread.daemon = True 65 | arduino_comms_thread.start() 66 | except: 67 | print("Arduino not recognised") 68 | 69 | app.run(host='0.0.0.0', debug=False) 70 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /dist 2 | 3 | /.idea 4 | *.tsbuildinfo 5 | 6 | .DS_Store 7 | 8 | # Logs 9 | logs 10 | *.log 11 | npm-debug.log* 12 | yarn-debug.log* 13 | yarn-error.log* 14 | 15 | node_modules/ 16 | .env* 17 | !.env*.default 18 | .vscode/* 19 | !.vscode/settings.json.default 20 | yalc.lock 21 | 22 | # Logs 23 | logs 24 | *.log 25 | npm-debug.log* 26 | yarn-debug.log* 27 | yarn-error.log* 28 | lerna-debug.log* 29 | .pnpm-debug.log* 30 | 31 | # Diagnostic reports (https://nodejs.org/api/report.html) 32 | report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json 33 | 34 | # Runtime data 35 | pids 36 | *.pid 37 | *.seed 38 | *.pid.lock 39 | 40 | # Directory for instrumented libs generated by jscoverage/JSCover 41 | lib-cov 42 | 43 | # Coverage directory used by tools like istanbul 44 | coverage 45 | *.lcov 46 | 47 | # nyc test coverage 48 | .nyc_output 49 | 50 | # Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) 51 | .grunt 52 | 53 | # Bower dependency directory (https://bower.io/) 54 | bower_components 55 | 56 | # node-waf configuration 57 | .lock-wscript 58 | 59 | # Compiled binary addons (https://nodejs.org/api/addons.html) 60 | build/Release 61 | 62 | # Dependency directories 63 | node_modules/ 64 | jspm_packages/ 65 | 66 | # Snowpack dependency directory (https://snowpack.dev/) 67 | web_modules/ 68 | 69 | # TypeScript cache 70 | *.tsbuildinfo 71 | 72 | # Optional npm cache directory 73 | .npm 74 | 75 | # Optional eslint cache 76 | .eslintcache 77 | 78 | # Microbundle cache 79 | .rpt2_cache/ 80 | .rts2_cache_cjs/ 81 | .rts2_cache_es/ 82 | .rts2_cache_umd/ 83 | 84 | # Optional REPL history 85 | .node_repl_history 86 | 87 | # Output of 'npm pack' 88 | *.tgz 89 | 90 | # Yarn Integrity file 91 | .yarn-integrity 92 | 93 | # dotenv environment variables file 94 | .env 95 | .env.test 96 | .env.production 97 | 98 | # parcel-bundler cache (https://parceljs.org/) 99 | .cache 100 | .parcel-cache 101 | 102 | # Gatsby files 103 | .cache/ 104 | # Comment in the public line in if your project uses Gatsby and not Next.js 105 | # https://nextjs.org/blog/next-9-1#public-directory-support 106 | # public 107 | 108 | # vuepress build output 109 | .vuepress/dist 110 | 111 | # Serverless directories 112 | .serverless/ 113 | 114 | # FuseBox cache 115 | .fusebox/ 116 | 117 | # DynamoDB Local files 118 | .dynamodb/ 119 | 120 | # TernJS port file 121 | .tern-port 122 | 123 | # Stores VSCode versions used for testing VSCode extensions 124 | .vscode-test 125 | 126 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Pi Smart Camera 2 | 3 | The Pi Smart Cam is an open-source DIY Camera designed for you to view live footage from your phone or any device. The following features 4 | 5 | Features: 6 | - PIR Sensor – For Motion Detection even in the Dark 7 | - Message Notification – Receive an email on the latest Motion Detected 8 | - Web Application - Camera App Client 9 | 10 | ## Requirements: 11 | - **This project builds on top of the [Pi Camera Stream Flask Repo](https://github.com/EbenKouao/pi-camera-stream-flask).** It's highly recommended to install and setup the following dependencies. 12 | 13 | ## Preconditions 14 | * Raspberry Pi 4, 4GB+ is recommended for optimal performance. However you can use a Pi 3 or older, you may see a increase in latency. 15 | * Raspberry Pi 4 Camera Module or Pi HQ Camera Module (Newer version) - USB Camera also Supported 16 | * Python 3 recommended. 17 | 18 | 19 | ## Pi Smart Cam 20 | 21 | ![Pi Stream Cam](./images/pi-smart-cam-featured.jpg) 22 | 23 | 24 | | ![Pi Stream Cam](./images/open-nest-cam-promo-3-min.JPG) | ![Pi Stream Cam](./images/open-nest-cam-ports-back-min.JPG) | 25 | | -------------------------------------------------------- | ----------------------------------------------------------- | 26 | | Pi Setup | Pi - Live Stream | 27 | 28 | ![Pi Stream Cam Livestream ](./images/arm-wave-near.jpeg) 29 | Livestream Front Door 30 | 31 | ## Step 1 - Setup Pi Camera Stream 32 | 33 | ![Pi Stream Cam](./schematics/pi-camera-breadboard-pir-sensor_bb.png) 34 | 35 | Run Camera with PIR Sensor: `python3 ~/pi-smart-cam/code/examples/pi-camera-stream-pir-sensor/main.py` 36 | 37 | These Examples provide the building blocks to Build your own Pi Camera (Contribute to the Repo to build more examples!) 38 | - pi-camera-stream-pir-sensor - Pi Camera Stream with PIR Sensor (and email notification) 39 | - video-usb-enabled - Pi Camera Stream, additional USB enabled Camera Support 40 | 41 | 42 | ## Step 2 – PIR Wiring & Electronics 43 | ### Part List: 44 | 45 | - Pi Electronics: 46 | - Raspberry Pi 4 47 | - Camera Module (HQ Pi Camera) 48 | 49 | - Arduino Electronics: Ring Bell and IR Sensor 50 | - PIR Sensor (HC-SR501) 51 | - Breadboard 52 | - Jumper Wires 53 | - Resistors: 330 Ohm 54 | - Arduino Nano 55 | - LED 56 | - 220F Capacitor 57 | 58 | ## Step 3 - 3D Prints Assembly (Opional) 59 | 60 | [.stl files for 3d Printing.](/3d-prints/) 61 | Contribute your 3D Builds to the Repo. 62 | 63 | 64 | ## Step 4 – Activate Email Notification (Optional) 65 | 66 | ![Pi Smart Cam Email Notification](./images/email-notification-min.png) 67 | 68 | ``` 69 | pi_email = "" 70 | pi_app_password = "" 71 | pi_port = 465 72 | pi_host = "smtp.gmail.com" 73 | notification_recipient = "" 74 | ``` 75 | 76 | Note: If you use want to send email notifications via Gmail, enable 2FA and use App Passwords instead of storing the password as plain text. Consider using environment variables. 77 | 78 | ## Step 5 – Autostart your Pi Stream 79 | 80 | Optional: A good idea is to make the the camera stream auto start at boot-up of your pi. You will now not need to re-run the script every time you want to create the stream. You can do this by going editing the /etc/profile to: 81 | 82 | ``` 83 | sudo nano /etc/profile 84 | ``` 85 | 86 | Go the end of the and add the following (from above): 87 | 88 | ``` 89 | python3 ~/pi-smart-cam/code/examples/pi-camera-stream-pir-sensor/main.py 90 | ``` 91 | 92 | Configure your Pi to Boot in CLI (Run Pi Camera Stream on Boot-Up) 93 | 94 | `sudo raspi-config` 95 | 96 | System Options -> Boot/ Auto Login -> Console AutoLogin -> Reboot 97 | 98 | 99 | This would cause the following terminal command to auto-start each time the Raspberry Pi boots up. This in effect creates a headless setup - which would be accessed via SSH. 100 | Note: make sure SSH is enabled. 101 | 102 | 103 | 104 | -------------------------------------------------------------------------------- /code/examples/video-usb-enabled/templates/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 124 | 125 | 126 | Pi Smart Cam 127 | 128 | 129 | 130 | 131 | 132 |
133 | 134 | 135 | 136 |
137 | 138 | 141 | 142 | 143 | 154 | 155 | 156 | 157 | 158 | 159 | 174 | 175 | 176 | 177 | 178 | -------------------------------------------------------------------------------- /code/examples/pi-camera-stream-pir-sensor/templates/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 124 | 125 | 126 | Pi Smart Cam - Motion Detection 127 | 128 | 129 | 130 | 131 | 132 |
133 | 134 | 135 | 136 |
137 | 138 | 141 | 142 | 143 | 154 | 155 | 156 | 157 | 158 | 159 | 174 | 175 | 176 | 177 | 178 | --------------------------------------------------------------------------------