-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmotion.py
More file actions
executable file
·32 lines (27 loc) · 803 Bytes
/
Copy pathmotion.py
File metadata and controls
executable file
·32 lines (27 loc) · 803 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
from gpiozero import MotionSensor
from picamera import PiCamera
from datetime import datetime
import mailer
camera = PiCamera()
#camera.resolution = (1920,1080)
#camera.resolution = (2592,1944)
camera.resolution = (1296,972)
camera.rotation = 180
camera.framerate = 15
pir = MotionSensor(17)
run = True
try:
mailer.sendMail("karl@bauman.is","Detection started", ":)")
while run:
pir.wait_for_motion()
filename = datetime.now().strftime("%Y-%m-%d_%H.%M.%S.h264")
#filename = datetime.now().strftime("%Y-%m-%d_%H.%M.%S.mjpeg")
camera.start_recording(filename)
#camera.capture(filename)
mailer.sendMail("karl@bauman.is","Movement in Attic", filename)
pir.wait_for_no_motion()
camera.stop_recording()
except KeyboardInterrupt:
print (" Quit")
# Reset GPIO settings
run = False