I am trying to write a script when motion is detected it will send me an email, can anyone help me put this script here
enter import smtplib
smtpUser = '[email protected]'
smtpPass = 'mypassword'
toAdd = '[email protected]'
fromAdd = smtpUser
subject = 'Test'
header = 'To: ' + toAdd + '\n' + 'From: ' + fromAdd + '\n' + 'Subject: ' + subject
body = 'From pi'
print header + '\n' + body
s = smtplib.SMTP('smtp.gmail.com',587)
s.ehlo()
s.starttls()
s.ehlo()
s.login(smtpUser, smtpPass)
s.sendmail(fromAdd, toAdd, header + '\n' + body)
s.quit()
Into this script here if any motion is detected
import RPi.GPIO as GPIO
import time
GPIO.setmode(GPIO.BCM)
GPIO.setwarnings(False)
GPIO.setup(10,GPIO.OUT)
GPIO.setup(21,GPIO.IN)
while True:
input_state = GPIO.input(21)
if input_state == True:
GPIO.output(10,1)
print "motion detected"
time.sleep(2)
GPIO.output(10,0)
time.sleep(2)