Raspberry pi sending temperature readings to email

To send temperatures to an email address I based my script on Matthew Kirk’s.  In his work Matthew describes the devices and the connections to the rpi via the GPIO connectors.

Link to Temperature Sensor

1. I have created a script that collects the temperature every 10min.  Twice a day it sends it to an email specified in mailpy2.py.
2. The modified script also adds the file temp_start to /etc/init.d/  so that the script starts when the rpi is connected.

The contents of temp_start are:
sudo python /home/pi/temp4.py

To move the file to the init.d folder and to make it executable:

sudo mv /temp_start /etc/init.d/

sudo chmod +x /etc/init.d/temp_start

sudo update-rc.d temp_start defaults

##temp4.py is shown at the end.

3. Make sure to change your email address and password in mailpy2.py.  Script is shown at the end.
4. Change the UK time:
sudo dpkg-reconfigure tzdataScripts:

mailpy2.py

temp4.py

5. Sample contents of the email received:

Wed Mar  6 13:49:48 2013 79.25
Wed Mar  6 13:56:53 2013 79.10825
Wed Mar  6 13:59:49 2013 79.10825
Wed Mar  6 14:06:54 2013 78.96875
Wed Mar  6 14:09:50 2013 78.827
Wed Mar  6 14:16:55 2013 79.10825
Wed Mar  6 14:19:51 2013 79.3895
Wed Mar  6 14:26:56 2013 79.3895
Wed Mar  6 14:29:52 2013 79.25
Wed Mar  6 14:36:57 2013 79.25
Wed Mar  6 14:39:53 2013 79.3895
Wed Mar  6 14:46:57 2013 78.96875
Wed Mar  6 14:49:54 2013 79.10825
Wed Mar  6 14:56:58 2013 79.25
Wed Mar  6 14:59:55 2013 79.25
Wed Mar  6 15:06:59 2013 78.96875 …

Advertisements

One Response to “Raspberry pi sending temperature readings to email”

  1. Martin Says:

    Hi,

    Really appreciate the scripts given on this page. I am successfully logging temperatures to a file. However, I can’t seem to get the email script to work. When i run it directly in Terminal, it shows no errors but i get no email. I have changed the email details. Any help would be appreciated.

    Martin

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


%d bloggers like this: