Archive for March, 2013

Raspberry pi sending temperature readings to email

March 7, 2013

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 …