Quick and dirty RasPi security camera #
RasPi + camera + WiFi adapter + power supply + internet accsess
● Detects when a door is opened
● Notification on phone/tablet via PushBullet
● Records 10 sencond videos (3 of them) and uploads to Dropbox
Install python pushbullet:
pip install pushbullet.py
Install Dropbox-Uploader:
cd ~ git clone https://github.com/andreafabrizi/Dropbox-Uploader/ chmod +x ~/Dropbox-Uploader/dropbox_uploader.sh cd ~/Dropbox-Uploader ./dropbox_uploader.sh
SecCam.py
import RPi.GPIO as GPIO import time import picamera import subprocess from pushbullet import Pushbullet from time import sleep camera = picamera.PiCamera() camera.rotation = 270 pb = Pushbullet("YOUR KEY HERE") localtime = time.asctime( time.localtime(time.time()) ) GPIO.setmode(GPIO.BCM) GPIO.setup(13, GPIO.IN, pull_up_down=GPIO.PUD_UP) while True: input_state = GPIO.input(13) if input_state == False: print('Door activated') push = pb.push_note("Door opened", localtime) print('Start video 1') camera.start_recording('/home/pi/1.video.h264') sleep(10) camera.stop_recording() print('Stop video 1') time.sleep(2) print('Start video 2') camera.start_recording('/home/pi/2.video.h264') sleep(10) camera.stop_recording() print('Stop video 2') time.sleep(2) print('Start video 3') camera.start_recording('/home/pi/3.video.h264') sleep(10) camera.stop_recording() print('Stop video 3') time.sleep(2) subprocess.call("/home/pi/copyVID2DB.sh") print('Videos uploaded to DropBox')
copyVID2DB.sh
#!/bin/sh NOW=$(date +"%m-%d-%Y") /home/pi//Dropbox-Uploader/dropbox_uploader.sh upload /home/pi/1.video.h264 /YourDropBoxFolder/$NOW.1.h264 /home/pi//Dropbox-Uploader/dropbox_uploader.sh upload /home/pi/2.video.h264 /YourDropBoxFolder/$NOW.2.h264 /home/pi//Dropbox-Uploader/dropbox_uploader.sh upload /home/pi/3.video.h264 /YourDropBoxFolder/$NOW.3.h264 rm -rf /home/pi/1.video.h264 rm -rf /home/pi/2.video.h264 rm -rf /home/pi/3.video.h264
If you want it to run at startup put this line in /etc/rc.local:
sudo python /home/pi/SecCam.py &
Now connect wires to PIN 13 and a ground and make them connect when the door is opened.