Hardware Reference
In-Depth Information
Listing 13-7 continued
#The next 3 lines attach the photo using the filename
#passed in as the second parameter to this program
part = MIMEApplication(open(afilename,”rb”).read())
part.add_header('Content-Disposition', 'attachment', ;
filename=afilename)
msg.attach(part)
#enter the SMTP server URL or IP Address between the quotes
s = smtplib.SMTP_SSL(“”, 465)
s.login(smtp_user,smtp_pass)
s.sendmail(msg['From'], msg['To'], msg.as_string())
s.quit()
def main():
emailphoto(sys.argv[1], sys.argv[2])
if __name__ == “__main__”:
main()
Project 5: How to Send an E-mail
Using a Wireless Remote
In this project you will use a wireless remote to send a signal to the Raspberry Pi to check the
status of the sensors that you have built in the other projects in this chapter and then send
yourself an e-mail report of all the sensors in the house. his is an example of the control
category of home automation. he e-mail will contain the temperature, status of door
switches and motion sensors and a picture of the last motion detected by the webcam. Other
typical uses of a wireless remote in home automation are switching lights on and of (particu-
larly external lights), switching or sounding an alarm system, opening and closing a garage
door and automating blinds and curtains. As you get access to more home-automation sen-
sors and controllers within your home you can use what you learn in this chapter to add
remote control to those devices. Table 13-6 shows what you need.
Search WWH ::




Custom Search