Saturday 17 September 2016

How hot am I?

Not very. Quite cool, really. Yet, to some extent, hot. But how much? I wouldn't want to be too hot. Or too cool,either.

Down in the server farm, I have a few biggish beasts chomping their way through an amp or more each. I have the aircon set to 29 degrees C - that's a lot higher than most server rooms run, I know that because I've frozen my fingers in several. But I reckon that's cool enough for the servers, and it reduces the amount of power needed to drive the aircon.

But I'd like to know if things get too hot.

I have a thing I built about ten years ago, which uses a temperature-reading device (the DS1820), and is read via the serial port. That's also monitoring the outside temperature, so that I know at a glance what the weather is like outside. But I wanted more. And the Raspberry Pi is the answer.

First, I bought some waterproof DS18B20 sensors. You can get them for £1.07 each.
And that was all I needed, but I did also buy a pack of assorted resistors. I used to have a tobacco tin of assorted resistors, but it seems to have vanished in one of my many relocations.

I connected the waterproof DS18B20 sensor to the Pi as suggested by this diagram, added the necessary modules, and asked the Pi what it could see with "ls -l /sys/bus/w1/devices/". It told me the part number for that sensor, so I did "cat /sys/bus/w1/devices/28-00000283c6cd/w1_slave" and it told me some stuff, including the temperature! Easy.

So I wrote a perl program to keep displaying the temperature, like this:

while (true) {
$tempall = `cat /sys/bus/w1/devices/28-041661ae88ff/w1_slave`;
($temp) = $tempall =~ /t=(\d\d\d\d\d)/;
$temp = $temp / 1000;
$stemp = sprintf("%5.1f", $temp );
print $stemp,"\n";
sleep 1;

So now all I need to do is place the thermometers (I got ten of them) in all the places I want to monitor, and tell a Pi to check them in turn, once per minute, and let me know if anything is getting too hot.


No comments:

Post a Comment