3.7 / 5 ( 24 votes )

The story

I have a small server room, with some rack servers, NAS’s, VMware ESXi’s and other fun stuff, but I had one problems.. in the summer it got really hot, and I had to open the window to let fresh air in, and the old out to lower the temperature again, but I never knew when it was too hot, so i had to drive by the server room once or twice a day to manually feel if it was too hot..

This was a problem, because sometimes I was not home, or sometimes I forgot, or just had no time to drive by to check the temp.

Having a temperature sensor in the room, from a freezer or something like that didn’t help me much, since I still had to drive by to check it manually.

So I had to make something I was able to get the room temperature from, over the internet/lan, and thats when I decided to make my network thermometer.

I looked for weeks on the internet for a good guide about this, but none of them worked. so I decided to write my own to help others with the same problem out.

This post will be about

How to make your own network thermometer, using open source software and a cheap USB temperature sensor!



What you will need

A raspberry Pi, or other small Linux computer that uses a small amount of power (this can be a laptop or normal computer too)

network cable to connect the Raspberry, laptop or computer to the network, the link is a 5 meter which is enough in most cases, there are other length on the same page if you need more.

USB temperature sensor, I used a “TEMPer v1.4“

If you are planning on using a Raspberry Pi for the project, you will need these additional items:

Powered USB hub

Power supply for the RPI (Raspberry PI)

SD card 4+GB, and min class4 – That fits in the RPI

Case for the raspberry (Optional, but highly recommended)

How to put it all together

I will be making it using a Raspberry PI in this guide, but it should work with a normal computer or laptop too.

I use Raspbian on it, which is Debian Linux optimized for speed on the Raspberry Pi.

Step 1 – Install the OS on your raspberry

To install Raspian on your raspberry you have to do the following. (If you already have a running Raspberry, then you can skip to step 2):

Download the zip file containing the dd image from Raspberrypi.org (A little under 500MB)

Extract the zip file to your hard drive, giving you the dd image “2013-07-26-wheezy-raspbian.img”

Write this image to the target SD card.

Linux Replacing sdX with the location of the SD card, run: dd bs=1M if=/path/to/2013-07-26-wheezy-raspbian.img of=/dev/sdX Windows Download and install Win32DiskImager Select the 2013-07-26-wheezy-raspbian.img image file, select your SD card drive letter, and click Write

Eject the card from your computer, insert into the Raspberry Pi, and power it on.

If your keyboard, mouse, or other USB device doesn’t appear to be working properly, try using it through a POWERED USB hub. The Raspberry Pi’s USB ports are limited to 140mA. This limitation has been fixed in newer boards; however, you may still run into power issues.

The default username is ‘pi’ with a password ‘raspberry’

Once you started up the device and is logged in, you will notice that there are no desktop. It’s all console based.

This entire guide will be done in the console only, and you should already know how to write commands and navigate around in the console to make this a lot more easy.

Step 2 – Install dependencies

When you have booted your Raspberry up, and it’s running you can change the password and other stuff you like, but I am going to skip this part for now and do it later. You can find guides to all the things like changing the keyboard layout, changing the timezone or language if you just google it. Maybe I will make small guides for each and every one, but for now I will skip it since it does not matter in this guide or device.

Now you need to install some dependencies that is needed to make the temperature reading software run.

Since i use Raspbian in this guide, the program used to install software from the repositories is called “apt-get”. Run the following command to install all the needed software (they are space seperated):

apt-get install libusb-dev libusb-1.0-0-dev

And press yes to everything it asks.

When done, you have to set some system variables, running the two following commands:

export LIBUSB_LIBDIR=/usr/lib/arm-linux-gnueabihf export LIBUSB_INCDIR=/usr/include/libusb-1.0

Step 3 – compile the program and get the temperature

You now have to download, compile and try out the software you have to use for reading the temperature of your TEMPer device. follow the step below.

Download the zip from here: temperv14

This can be done using the following command on your Raspberry: wget http://dev-random.net/wp-content/uploads/2016/01/temperv14.zip Extract the zip file on your Raspberry, to do this you first have to install the Unzip program on your Raspberry using the following command apt-get install unzip When installed, you can unzip the archive using the following command unzip temperv14.zip Change directory to the new unzipped folder using the command cd temperv14/ Now compile the program using the following command: make It should output something like what you see in the picture below

Test the newly compiled program using this command ./temperv14 If you have your TEMPer device connected, it should output a timestamp and a temperature, if not it will output an error that the device was not found. Move the newly compiled program to a special directory so that can be accessed from everywhere in your system using the command mv temperv14 /usr/bin/ Now if your type “temperv14” anywhere in your system, it will run the program and output the temperature!

If you want to output only the temperature in Celsius (handy for implementing this in programs or monitoring systems like Nagios), you can run the command

temperv14 -c

Or for the temperature in Fahrenheit only

temperv14 -f

Step 4 – Manually adjust the thermometer

Roland (In comments) made a version that accepts arguments for subtraction and addition, so this step is no longer needed.

Package has been reuploaded with new source

Some TEMPer devices show the temperature a little off, like mine for example, it show 6 degrees Celsius too much, every single time!! This was an issue for me since it was not the correct temperature I got from the device.

I was just about to send it back, but then I decided I did not want to wait the 2-3 weeks for a new to arrive, so I just made the program subtract 6 degrees every time before outputting the temperature.

I made a static variable in the code of the program that you can change. so you should do the following

Find a manual temperature sensor, like from a fridge, and put it in the same room, right besides the TEMPer device, leave it there for an hour until it shows the correct temperature. Run the command, and note how many degrees the output is at. Compare it to the degrees on the manual thermometer. If it’s more, then do the following Edit the file temperv14.c with Nano or Vi Change line number 80 from “static int substract = 0” to the number of degrees in CELSIUS the TEMPer device is showing too much. Save it, and repeat step 2 starting from substep number 4 (Where you run “make”)

Done

Done, that’s it.. you now are able to monitor your temperature remote using SSH, or by implementing this to Nagios or other Monitoring software just by running the command “temperv14” on the device.

You should know, that I had problems with my TEMPer device, when I did not attach it to a powered USB hub. when attached directly to the Raspberry it got hot, and showed way too much when running the command. so I recommend attaching it to a powered USB hub that is attached to the Raspberry’s USB ports if this happens to you as well, it fixed the heating issue for me.

