$30 Historical Temperature Sensor System Using PC,1-wire, Perl, MRTG

by xorshift in Circuits > Sensors

28190 Views, 59 Favorites, 0 Comments

$30 Historical Temperature Sensor System Using PC,1-wire, Perl, MRTG

tempprobesceen2.PNG
tempprobesceen3.PNG
temp2008.bmp
tempprobesceen1.PNG
PICT4133.JPG
PICT4134.JPG
1wireschematic.jpg
I wanted a cost effective way to record temperatures in different areas (computer rooms specifically) and present the data using graphs. Currently the temperatures are updated every 5 minutes, and can be accessed via a web page, but this could easily be modified to perform alerts based on thresholds.

For the initial system, I decided to monitor temperatures throughout my home (basement, 1st floor, Attic, and outside) I chose to use windows, as most of my clients have a windows system readily available.

The system is based on 1-wire devices, these things are amazing, and small. Basically using 2 wires, from the serial port adaptor (USB also avail) they receive power, and will acknowledge temperature requests based on their unique serial number being sent down the 1-wire bus.{{{
'''''''
}}}

What you will need
Hardware:
https://shop.maxim-ic.com
DS9097# IBACC Commercial (0 deg C to +70 deg C) Qty 1 Price $ 21.59
DS18S20 TO92 Military (-55 deg C to +125 deg C) Qty 2+ Price $ 2.57
CAT 5 cabling, crimpers, and RJ45 ends, RJ45 Coupler(preferred but not required)
Software
Windows Workstation (XP, 2000, etc.)
ActiveState Perl (Free) http://www.activestate.com/products/activeperl/
MRTG (Perl Script)(Free) http://oss.oetiker.ch/mrtg/
Apache (Web server) (Free) http://httpd.apache.org/

Get 1-wire Up and Talking

PICT4134.JPG
rj45cab.jpg
PICT4133.JPG
1wire_viewer.JPG
1-wire is bus network, and should be wired in a daisy chain manner, not hub and spoke, in other words devices should all be connected in a row, not all fed back to the serial port adaptor indivdually. (But you can do this with 1-wire hubs)

Wire up sensors, connect serial port adaptor, make sure pin out is correct, and reverse 1-wire and gnd.

open the following website, and run the 1-wire viewer,
it will show you all the 1-wire devices connected after you configure the correct interface type and serial port.

http://www.maxim-ic.com/products/ibutton/software/1wire/OneWireViewer.cfm

If you don't see any listed you may have it wired incorrectly, either way don't proceed until you see your devices listed like the screenshot.

Get MRTG Up and Running

tempprobesceen1.PNG
tempprobesceen2.PNG
tempprobesceen3.PNG
run using your parameters rsH_1wiretemp.exe, make sure you close the 1-wire viewer first, otherwise the serial port will be locked.. you should send 2 serial numbers to poll, the output of this exe is formatted for MRTG.

Confirm you see 2 valid temperatures, put your finger on one and watch the temp rise as you poll it again and again..

the exe I included (and included temp.c source) is straight from the Dallas developer kit(free) , I just modified it and compiled it using Microsoft Visual Studio so it would output the values in an MRTG format.

Now that it is working..

Install Perl first, then MRTG, then Apache. Search the web for excellent guides on getting MRTG up and running, its a great tool for monitoring routers,switches, and just about everything else. The only thing to remember is that the vanilla mrtg install can only graph 2 values per graph, an in and out, (you can graph multiple if you switch to rrd or other tools,but this is the simplest way to get started)

ActiveState Perl (Free) http://www.activestate.com/products/activeperl/

Then download latest stable releas of MRTG, (read docs!)
basically you unzip, go into mrtg/bin you will need to create a mrtg.cfg, I did not include a full mrtg.cfg file, only the section for 1 pair of sensors, so basically create the cfg and cut and paste the section I included, keep in mind you have to change you serial numbers based on your sensors!
MRTG (Perl Script)(Free) http://oss.oetiker.ch/mrtg/

Normally you run the cfgmaker script, but because this is a custom monitor, we will need to cut and paste the mrtg.cfg portion I included on the first page. After that run indexmaker, and it will create a simple little index page. Point Apache at your MRTG folder so you can access the pages from anywhere..

Ideally MRTG should be installed as a service, so you don't have to login to the box to have it running, look for guides to do this..

Conclusion

tempprobesceen3.PNG
tempprobesceen2.PNG
Hopefully this sheds some light on the components and process I use, and may be useful in pointing people with similar needs in the direction I chose.

I also decided to graph my attic temperature as I was debating on installing a ridge vent. It's interesting to compare the attic versus the outside temperature, as the temperature is strongly related to sun exposure. Sudden rainstorms show a sharp drop in attic temp, while outside temperature will vary only slightly.

Some insulation studies seem to graph only the difference between outside and indoor temperatures, this could easily be done using variables in the mrtg section config.

In addition to using misterhouse and x10 to manage my home, I can pull up a webpage showing temps all around my house on my web phone. I also integrated my alarm system so I can graph motion in the house with MRTG as well, A definite geek feature..