Hackster is hosting Hackster Holidays, Ep. 6: Livestream & Giveaway Drawing. Watch previous episodes or stream live on Monday!Stream Hackster Holidays, Ep. 6 on Monday!
Nikunj Patel
Published © MIT

Raspberry Pi Security Camera System with Notification

An easy way to know if someone is at the door and take picture of that person.

IntermediateFull instructions provided1 hour13,443
Raspberry Pi Security Camera System with Notification

Things used in this project

Hardware components

Raspberry Pi 3 Model B
Raspberry Pi 3 Model B
×1
PIR Motion Sensor (generic)
PIR Motion Sensor (generic)
×1
Resistor 221 ohm
Resistor 221 ohm
×1
LED (generic)
LED (generic)
×1
Camera Module
Raspberry Pi Camera Module
×1
Breadboard (generic)
Breadboard (generic)
×1
Jumper wires (generic)
Jumper wires (generic)
×1

Software apps and online services

Cayenne
myDevices Cayenne

Hand tools and fabrication machines

3D Printer (generic)
3D Printer (generic)

Story

Read more

Schematics

PIR & LED

Connect the PIR & LED to Raspberry Pi

Code

Camea & PIR Motion Sensor Code

Python
This code will active PIR sensor and camera will take picture. Picture will be save in /home/pi/Pictures folder.
from gpiozero import MotionSensor

pir = MotionSensor(17) #pin 11 in raspberry pi

from picamera import PiCamera
from time import sleep # To preview on display time
camera = PiCamera()

i=1
while True:
    pir.wait_for_motion()
    print("You Moved")
    camera.start_preview()
    sleep(5) # To see on the display for 5 sec or use # to just take picture and no preview on dispaly
    camera.capture('/home/pi/Pictures/img%s.png'%i)
    i+=1
    pir.wait_for_no_motion()
    camera.stop_preview()

PIR & LED Code

Python
Active PIR sensor and turn on LED. When LED is on, Cayenne will send you notification.
import RPi.GPIO as GPIO
import time
GPIO.setwarnings(False)
GPIO.setmode(GPIO.BOARD)
GPIO.setup(11, GPIO.IN)         #Read output from PIR motion sensor 
GPIO.setup(3, GPIO.OUT)         #LED output pin
while True:
       i=GPIO.input(11)
       if i==0:                 #When output from motion sensor is LOW
             print "No intruders",i
             GPIO.output(3, 0)  #Turn OFF LED
             time.sleep(0.1)
       elif i==1:               #When output from motion sensor is HIGH
             print "Intruder detected",i
             GPIO.output(3, 1)  #Turn ON LED
             time.sleep(0.1)

Credits

Nikunj Patel

Nikunj Patel

6 projects • 19 followers
Electromechanical Engineer

Comments