jervine / rpi-temp-humid-monitor

Raspberry Pi temperature humidity monitor
GNU General Public License v2.0
131 stars 36 forks source link

rpi-temp-humid-monitor

Raspberry Pi temperature humidity monitor

This is my implementation of making a Raspberry Pi powered temperature and humidity monitor. The original instructions that I followed were created by wpnsmith at the instructables website

In this repository are my copies of the th.c code, a thd init script, and two files for creating a Google Chart graph rather than the python based GraphTH.py using matplotlib that wpnsmith used.

The th.c code was modified so that a fourth column in MySQL is used (an auto incrementing id - probably not strictly necessary as the ComputerTime entry is incrementing anyway), as well as having th detect if an incorrect temperature/humidity reading has been made (by checking against the previously recorded value) and silently not adding this to the MySQL database if it is seen to be a big change.

Using a thd init script means that we don't need to modify /etc/rc.local - which is useful for me as this file is used by other projects and can be overwritten at times.

UPDATED - 10 July 2015

Added a python script, readMysql.py, to read the previous values of temperature and humidity from the MySQL database. This is necessary for the single run python script, as we don't have a previous reading to compare against.

UPDATED - 24 June 2015

Fixed a typo in a variable name (humiddiff) that could cause the daemon to crash if an erroneous reading was made.

UPDATED - 23 June 2015

Fixed a bug in the code where the script would crash as I hadn't passed the temperature and humidity difference tolerances allowed to the loop. If an erroneous reading was made, the script would crash.

UPDATED - 19 June 2015

The updateMysql.py script has been updated to provide a method of retrying failed MySQL updates. Primarily this was added so that when the server is booted up, the daemon version of the code can retry a number of times before giving up, as the MySQL server will not necessarily have finished starting up.

An updated thMonitord init script has been added, and the temp-humid-read-loop and temp-humid-read-single scripts have been altered so that they are currently hardcoded to use a configuration file called /etc/thMonitor.conf

UPDATED - 18 June 2015

There are now two python scripts (with logging added rather than printing to stdout)

UPDATED - 17 June 2015

Looking to replace the C code with a python script that takes a configuration file. Added here:

Please note this updated python code was heavily inspired by the work done by Adafruit here:

https://github.com/adafruit/Adafruit-Raspberry-Pi-Python-Code/tree/master/Adafruit_DHT_Driver_Python