Raspberry Pi -
Humidity / Temperature Data Logger / Grapher
Using DHT22 Sensor
revised 02-26-13 d. bodnar
|I have been working with the
Raspberry Pi for a few months and have had a great time
experimenting. See my other page of notes on the Pi
here and the notes on using the Pi as a
temperature logger here.
My latest project is to use the Pi as a data logger that will read humidity and temperature data from one or more DHT22 temperature sensors. This data will be recorded to a file and periodically graphed and posted on the Internet.
GNUPlot will be used to produce the graphs.
Much of the work that I have done is based on the excellent tutorial provided by the folks at Adafruit.
Note that you may have to do an update and an upgrade to use "git" or may need to install "git"
The DHT22 sensors are inexpensive and can be used to gather both humidity and temperature. These devices have four pins. The leftmost pin connects to + 3.3 volts, the next pin is data and the rightmost pin goes to ground. The third pin is not used. A 10K resistor needs to be connected between pins 1 and 2 to pull the data line high.
These sensors cannot be wired in parallel as the DS18B20s can. Each sensor must have its own 3 wire cable (+ 3.3 volts, data and ground) and each data line must connect to its own GPIO pin.
Python is too slow to read the sensors directly. Fortunately an executable "C" program is available that takes care of reading the sensors. It is available for download here: http://learn.adafruit.com/dht-humidity-sensing-on-raspberry-pi-with-gdocs-logging/software-install
My installation did not contain the "git" file that is used in this link but a quick sudo apt-git install git took care of the issue.
Also, the top two lines of the installation must be combined so that it reads:
|Notes on the following were found here: http://www.stuffaboutcode.com/2012/06/raspberry-pi-run-program-at-start-up.html|
|To get the program to auto-start after a power failure put this
script (called StartHumid.sh) into the
### BEGIN INIT INFO
|once created do the following:
Start the program
Stop the program
Register script to be run at start-up
sudo update-rc.d StartHumid.sh defaults