Temperature measurement with Linux
Simply done, no?
My old office had a medium big Server room with about 60 machines in it.
THe AC was pretty much crap and used to die during the weekends which caused havoc on the hardware.
So we installed two new ACs. Main and backup but we didn't want to lay our trust into the hands of this new setup.
We needed a way to check up on the temperature of the server room in general.
What is the best way to go at this? Good question.
Well, one way is to check the temperature of each server. Use the mainboard temp sensors, if available. Hmmm, sure, that
is one way to go at it, Each machine being so different though this could turn into a whole kernel recompile for each box. Not only that though. Where do you say what temp is good for what server? Some run hotter then the others, etc etc etc. So we said lets get an overal room reading.
I did some research and stumbled upon digitemp by Brian C. Lane. Check his site out at digitemp.com
Brian C. Lane's solution is wonderful. He uses single wired sensors and a little circuit board to measure the temp. You can add virtually unlimited amounts of Sensors to the setup. Each sensor has it's unique ID which makes sifting through the data realy easy.
But now enough. Behold the creation. The pics on this page are not actual images from my soldering job (i suck at soldering, so it wasnt nice to look at).
Solution for the Hardware hacking enthusiast.
This solution is dead cheap and is guaranteed to earn you lots of geek points. Trust me. Chicks will love it. You will have mad babes cueing up to get some from you ... yeah, ;) Why? Cause, you did some craftmanship AND you are using LINUX to do the hard work. All works out :)
Now, what do we need. You need Soldering Iron, Solder, a circuit board, components, money (bout 15 Euros), a RS232 Port on a PC running Linux, a steady hand, some time and beer. Well, beer is optional but it always comes in handy. (need to cool a burn from hot solder? there ya go. Beverages are not included in the price). Oh, you'll need a Component Vendor aswell. For you in germany give http://www.reichelt.de a try.
This is how it could look like:
- Professional circuit board
- A cool Fisherman's Friend box
- Two Temp Sensors on various length cabling with nifty connectors.
The top solution is ofcourse a pro job. I wouldn't expect you to do it like that. Yours could look more like the following.
here are the things you'll need to buy:
- 1 x Dallas Semiconductor DS1820 Temperaturesensor
(EXACTLY this piece!!!), about. 4,60 Euro + TAX
- 2 x Schottky Diode (1N5818)
- 1 x Zener Diode 6.2V (1N5234)
- 1 x Zener Diode 3.9V (1N5228)
- 1 x Resistor 1,5 kOhm, 0,25 Watt (Resistance is not futile)
- 1 x RS232C plug thingy to solder onto (I used an old mouse cable. worked like a charm)
- 1 x circuit board
- 1 x little box to smack it all into
Here you have a diagram:
and here the Circuit layout.(YAY) :
Just to tell you what goes where, I present you the chart. Speaks for itself no ?
1 and 7 (you GOTS to combine those two!)
It's abit more difficult finding the right legs on the sensor, so here a small diagram of which are the correct two on the DS1820:
Now all you gots to do is stick em component pins through the holes, bend and solder. Easy said, easy done. Behold the beauty, or not:
now put it all in a box and you are set.
As I said it is possible to attach multiple sensors to the whole thing and since my daddy always told me. MORE IS BETTER *wink*wink*nudge*nudge*I show you how it is done. You connect the DS1820 Sensors parallel. Since each one has a unique ID there won't be a confusion later what data came from who. Brian Lane's digitemp program can be told from which sensor to read. (snippet of the config file)
LOG_FORMAT "%b %d %H:%M:%S Sensor %s C: %.2C F: %.2F"
ROM 0 16 54 147 66 0 0 0 186
ROM 1 16 44 180 66 0 0 0 135
The logfile will look like this with multiple sensors:
gatekeeper:/usr/local/bin/digitemp # cat /var/log/temperature
Jul 21 17:10:03 Sensor 0 C: 21.10 F: 69.99
Jul 21 17:10:06 Sensor 1 C: 20.36 F: 68.65
Jul 21 17:20:03 Sensor 0 C: 20.70 F: 69.26
Jul 21 17:20:06 Sensor 1 C: 20.51 F: 68.91
digitemp Program by Brian Lane
The program exists for Linux and *cough* Win32 and was written Brian Lane. (http://www.brianlane.com/digitemp.php)
Get it here for as low as $0.00 - SPECIAL OFFER:
- Digitemp Version 1.3 for Linux: digitemp-1.3.tar.gz.
There is a Version 2 for a different setup which we are not gonna touch on cause I didn't find any diagrams of how the setup would look like.
I have now found out that the circuitry was never realy put down in design for the public to be found. But DALLAS (now MAXIM) have done Temperature plugs which you can buy from them. If you feel llike it you can check them out.
- Digitemp for Windows95: dtw95bin.zip
- Digitemp for WindowsXP: dtreg17.zip
Start is like this for COM2:
DigiTemp v1.7 [REGISTERED] Copyright 1996-2002 by Brian C.
All Rights Reserved - http://www.brianlane.com
all DS2409 Couplers
Searching the 1-Wire LAN
: DS1820 Temperature Sensor
ROM #0 : 105FA142000000E8
Jul 03 08:55:02
Sensor 0 C: 21.29 F: 70.33
To run it in Linux:
linux # cd /usr/local/bin/digitemp
linux # ./digitemp -a -l/var/log/temperature
DigiTemp v1.3 Copyright 1997-99 by Nexus Computing
Temperature Log File:
linux # tail -f /var/log/temperature
Jul 20 20:58:49 Sensor 0 C: 19.81 F: 67.66
Jul 20 21:34:06 Sensor 0 C: 18.77 F: 65.79
Jul 20 21:40:03 Sensor 0 C: 18.76 F: 65.77
Jul 20 21:50:02 Sensor 0 C: 18.64 F: 65.55
Jul 20 22:00:04 Sensor 0 C: 18.61 F: 65.51
Jul 20 22:10:03 Sensor 0 C: 18.56 F: 65.42
The Logfile can now be parsed with Perl to make nice little graphs using rrdtools. :
or like this
or like this
(red line is the warning level at which an Email and SMS is send out)
- The scripts for the graph use Perl and RRDtools and run under Linux.
Clicky here. (Last change 30.08.2003).
- Create the logfile the following way:
-a -o"%d.%m.%Y %H:%M:%S Sensor %s C: %.2C"
The loglines will look like this:
21.08.2003 00:14:36 Sensor 0 C: 15.75 *
- For the graphs you can use RRDtools directly ofcourse.
- I didn't want to use pre-made solutions for the graphs. I decided to try my own luck an since I was just getting to know shell scripting abit more I rolled my own shell scripts to handle the whole digitemp situation. It consists of following scripts:
- Evaluation Script: The Eval script checks the current temperature and if any of the sensors is showing a Value which is higher then max allowed Temp a warning Email is send out
- CGI Script: The CGI Script lets a user define a Time Range for a desired Temperature Graph (Graph 3)
Since this was my first attempt at shell scripting and at cgi programming it turned out pretty ugly. The cgi script uses three help scripts and AWK/GAWK to parse user input data. The graph itself is done with the program plot. My solution can be downloaded from from HERE. Read the installation manual for more info.
- Sadly Dallas / MAXIM are not making nor shipping the DS1820 anymore but there is a replacement. The DS18S20. It works with the same schematic but you CAN'T use more then three since their needed power is more then RS232 Port can deliver.
- If you are still using the DS1820 you will notice Temperature readings of 85C° at random intervals. This should not worry you UNLESS that temperature is actually going on in your server room. The DS1820 Sensors at times deliver an error code which is 85C° (I do not think the sensors can actually be used to measure temps that high, check their specs for more info). To get around this problem you will have to reduce the speed of temp readings. Use -s2000 in the config file or direct program init. This will lower the frequency of sensor check. Worked for some, I used a different solution.
This said, I hope this helped you. It surely helped me. Now if you get it all done and it works, I guarantee you, you will get laid. If it doesn't work out for you that way, well, obviously the gods are not taking a liking to you. ;-)
October 19, 2004
Would like to thank Brian C. Lane for his work on digitemp and the whole group supporting it's devel.
Also thank Lena Franken and LinuxNetMag for their great info on how the darn thing is actually supposed to look like. :) Oh, yeah, thanx for their graphics and all aswell, i used them in this page.