top of page

Email Controlled Thermostat

Here is the result of my latest quickly cobbled together project. A Video demonstration is on the way but until then...

I have rigged up some code and hardware that responds to specific email commands. A script written in Ruby pings the Gmail mail server looking for new emails. When one arrives it checks for one of two commands currently "Turn on heat" or "Turn off". If it sees an email that contains one of those, it communicates with the Arduino over serial which then controls the thermostat with a servo.

The script wasn't too hard to setup thanks to the fact that Ruby has built in email support. Just make sure your gmail is setup for POP3.

So in my example [fromname] represents the email service we a getting emails from and also sending response emails from. So this is the email account you would want to have set up just for receiving command emails. The [toname] is the email to send response emails to and also the email that will be sending to the emails to this script. These would be replaced by your values.

I don't think any of this code is too complex. It Opens an email port, reads new emails, checks the email message for certain strings and then sends out serial port command characters which the arduino then reads and moves the servo to the appropriate positions for my thermostat.

So with that said Here is some ruby code.... I use the fact that the Windows command line can send serial information out to send characters to the arduino. Thus avoiding all of the nasty serial port communication code.

This is setup specifically for gmail accounts. Gmail requires SSL for POP3 receiving and TLS for SMTP sending of emails. The system calls are what is controlling my Arduino code. I was just using 9600bps serial




The Arduino Code is as follows...



Comments


bottom of page