quand le capteur pir detecte un mouvement prend une photo et l envoi par mail
Code : Tout sélectionner
#!/usr/bin/python
import RPi.GPIO as GPIO
import time
import urllib
import os
GPIO.setmode(GPIO.BCM)
GPIO_PIR1 = 24
#GPIO_PIR2 = 25
print "PIR Module Test (CTRL-C pour quitter)"
GPIO.setup(GPIO_PIR1,GPIO.IN)
#GPIO.setup(GPIO_PIR2,GPIO.IN)
Current_State = 0
Previous_State = 0
try:
print "demarrage pir ..."
while GPIO.input(GPIO_PIR1)==1:
Current_State = 0
print " start"
while True :
Current_State = GPIO.input(GPIO_PIR1)
if Current_State==1 and Previous_State==0:
print " Mouvement !"
test = urllib.urlopen("http://192.168.1.69:8080/json.htm?type=command¶m=switchlight&idx=24&switchcmd=On&level=0") #allume les spots grace a domoticz
os.system("fswebcam -r 640x480 -d /dev/video0 /home/pi/fswebcam test.jpg") #prend une photo avec fswebcam
time.sleep(1)
os.system('sh /home/./dropbox_uploader.sh -s upload /home/pi/photo_pir_garage /photomotion') #prend le dosssier photo_pir_garage vers dropbox
time.sleep(1)
os.system("python /home/pi/pir__photo_mail_test/envoi_photo_gmail.py")
time.sleep(2)
Previous_State=1
elif Current_State==0 and Previous_State==1:
print " Ready"
Previous_State=0
time.sleep(0.01)
except KeyboardInterrupt:
print " Quit"
GPIO.cleanup()je voudrai prendre une photo avec un autre raspberry et l envoyer sur ma boite mail