Measuring and plotting temperatures is something fun to use the computer for. There are a number of alternatives available when it comes to different temperature sensors. The ones I have tested are SMT-160's and DS1820's, the SMT-160 interfaced with game- or parallel-ports, and the DS1820's interfaced with a serial port.
At work I have just started to take a closer look at Pt100 sensors. These seem to be an interesting alternative.
This sensor work with pulse width modulation. I.e. the pulse width is a measure of the temperature.
As can be seen in the picture above it is easily adopted to the parallel port, but it may also be connected to the game port. On some old 486 computers I had trouble with the game ports though, they only had two channels available so I could only monitor two temperatures. Due to this I started to use the parallel port instead. The downside of this is that the parallel port is a bit more sensitive than the game port, so one has to be careful not to destroy it.
I wrote two small programs to read the values of five temperature
sensors. One could be used from the prompt to read the
temperature, the other was supposed to run from cron, logging the
temperature data. These can be downloaded as lpt_temp-1.0.tar.gz Unpack with 'tar
xvfz lpt_temp-1.0.tar.gz', change directory to
lpt_temp-1.0 and read the README file
for installation information. Or, if you want to use rpm,
download lpt_temp-1.0-1.src.rpm, run "rpm --rebuild
lpt_temp-1.0-1.src.rpm" and install with rpm as usual.
These sensors are a bit more advanced than the SMT-160. They have serial numbers which works as an address for the sensor. I.e. we can send a command to the sensor which then will return the temperature back to us as a serial word.
This time I have not written the code myself, but used the code written by Brian C. Lane. Take a look at http://www.digitemp.com/
Included are some Perl scripts so that one can use rrdtool,
http://oss.oetiker.ch/rrdtool/, as a logging
and plotting program. I did some small changes to these to
suite my needs. I only changed the naming of the sensors to
sensor# where # is zero to five, i.e. the rrd data
base can handle up to six sensors. If I need more later on I
can change this to whatever I need. My modified files can be
downloaded as digitemp_rrdtool.tar.gz. Feel free to use
and modify them to suite your needs.
The system works the following way. Each fifth minute a cron-job starts digitemp to collect the temperature data. This data is put into the rrdtool data base. The data base is then accessed through cgi-scripts to draw the temperature diagrams.
My line in crontab (using 'crontab -e') looks like
this '*/5 * * * *
/var/www/html/rrd/log-temperature.pl'
Pt100 and Pt1000 are Platinum resistance thermometers with a range of -200 to 850 degrees Celsius (depends on how it is capsuled and manufactured, look at the data sheet for the one you decide to use.) These sensors change their resistance in accordance with the temperature. Pt100 sensors have a resistance of 100 ohms at zero degrees Celsius while Pt1000 sensors have a resistance of 1000 ohms at zero degrees Celsius.
The change in resistance is almost linear, but if you want a more precise value of R, the resistance, given a T, temperature in degrees Celsius, you can use the following formula
R = R0 * (1 + A*T + B*T^2 -100*C*T^3 + C*T^4) where R = resistance of sensor in ohms R0 = resistance at zero degrees Celsius in ohms (100 for Pt100, and 1000 for Pt1000) T = temperature in degrees Celsius A = 3.9083*10^-3 B = -5.775*10^-7 C = -4.183*10^-12 for T < 0 degrees Celsius C = 0 for T >= 0 degrees Celsius
LM35 is another interesting little device. It is fed with 5 volts and deliver a voltage equal to 0.1 V per degree Celsius. Using plus and minus 5 volt, or a special circuit consisting of two diodes and a 18 kohm resistor, one may also measure voltages below zero degrees Celsius. According to the data sheet the sensor works for -55 to +150 degree Celsius.
To be able to use this sensor with a computer one need some kind of A/D-converter. I have not tested it but perhaps an old game port will due.