Sunday, 12 October 2014

Switching appliances ON and OFF remotely by e-mail with the Raspberry Pi and Mains Switch Widget #1

Having designed the Mains Switch Widget, my next challenge was to turn appliances ON and OFF from outside the house. I investigated Twitter and texts as a means of doing this but finally settled on using e-mails to control the appliances. This multi part post outlines the various steps along the way.

First of all I set up a gmail account just for the house. As we live in number 11, The Groves, the e-mail address I chose was elevengroves@gmail.com.

IMAP seems to be a good way to look at and analyse received e-mail. I found the  post here http://www.voidynullness.net/blog/2013/07/25/gmail-email-with-python-via-imap/ very useful.

I also wanted to send a confirmation e-mail back to verify that the command has been actioned. The posts here were very useful in working out the best way to do this.

http://www.raspberrypi-spy.co.uk/2012/05/send-text-and-html-email-using-python/

http://stackoverflow.com/questions/10147455/trying-to-send-email-gmail-as-mail-provider-using-python

Using the information in these posts and with a working knowledge of Python I have managed to get a system working as follows.

1.     Networked Raspberry Pi at my house, connected to a mains Switch Widget with a lamp plugged into it and switched ON.

2.     Program recognises commands 'APP1ON' and 'APP1OFF' when sent in the subject field to e-mail addresss elevengroves@gmail.com

3.    Confirmation e-mail sent back to say that command has been actioned.

 I plan to publish the debugged code for this on the next part of this post. In the meantime the system is on trial.

To keep upto date with our blog posts, subscibe using the link provided on the www.sf-innovations.co.uk website.



No comments:

Post a comment