Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import RPi.GPIO as GPIO
- import time
- import smtplib, ssl
- port = 465
- password = 'trustthyworthy4now'
- context = ssl.create_default_context()
- GPIO.setmode(GPIO.BCM)
- GPIO.setup(23, GPIO.IN)
- with smtplib.SMTP_SSL("smtp.gmail.com", port) as server:
- server.login("rhubenov.development@gmail.com", password)
- try:
- time.sleep(2)
- while True:
- if GPIO.input(23):
- print("Motion detected")
- server.sendmail('rhubenov.development@gmail.com', 'rrhubenov@gmail.com', 'It works!')
- time.sleep(5)
- time.sleep(0.1)
- except:
- GPIO.cleanup()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement