Code: Select all
#!/usr/bin/python import RPi.GPIO as GPIO import os import sys from time import sleep import smtplib from email.mime.multipart import MIMEMultipart from email.mime.text import MIMEText GPIO.setmode(GPIO.BCM) GPIO.setup(13, GPIO.IN) GPIO.setup(6, GPIO.OUT) try: while True: if ( GPIO.input(13) == True ): os.system('clear') print("Motion Seen") GPIO.output(6,GPIO.HIGH) fromaddr = "myemail" toaddr = "toemail" msg = MIMEMultipart() msg['From'] = fromaddr msg['To'] = toaddr msg['Subject'] = "Test Alert" body = 'Motion Detected' msg.attach(MIMEText(body, 'plain')) server = smtplib.SMTP('smtp.gmail.com', 587) server.ehlo server.starttls() server.login("myemail", "mypassword") text = msg.as_string() server.sendmail(fromaddr, toaddr, text) server.quit() sleep(3) sys.exit() else: os.system('clear') # clear the screens text print ("No Motion Detected!") GPIO.output(6,GPIO.LOW) sleep(0.5) except: KeyboardInterrupt GPIO.cleanup() os.system('clear') print('Aborted!')
Thanks for your answer! Actually that's not a bad idea.. to set it up as an access point.. Maybe i can create a local website which i then enter on my phone, and then somehow it shows on the website if motion is detected..pcmanbob wrote: ↑Thu Aug 10, 2017 1:18 pmAs you say you don't have wifi available or a GSM modem for the pi and Bluetooth range is to short, It does not really leave you with much does it as you cant add any other devices to your phone were as you could add them to your pi.
you only answer may be to set your pi up as a wifi access point and then pair your phone with pi wifi. which would allow you to at least communicate between them, but I don't think sending emails with a connection like this would work.
Users browsing this forum: No registered users and 5 guests