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

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

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
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)
Windows Workstation (XP, 2000, etc.)
ActiveState Perl (Free)
MRTG (Perl Script)(Free)
Apache (Web server) (Free)

Step 1: Get 1-wire Up and Talking

Picture of Get 1-wire Up and Talking

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.

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.

Step 2: Get MRTG Up and Running

Picture of Get MRTG Up and Running

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)

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)

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..

Step 3: Conclusion

Picture of Conclusion

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..


tradergordo (author)2007-02-21

Excellent. I would love to try this as well, I've got two wireless weather stations and 3 thermometers in my house but nothing to interface with the PC. I'm also interested in trying to determine if its worth it to run an attic vent fan in the summer (if the attic is well insulated, maybe I'm just wasting electricity trying to cool a space that does not even impact the temps in the rest of the house). What conclusions did you come to in that regard? Thanks, Gordo

Sneak85 (author)tradergordo2010-11-17

Actually how warm it is in your attic does effect the temperature in the rest of your house. The more insulation you does help with this.t Just a note you can check out this website for more info. Or to some it up, it basically says if you have a light colored roof (opposed to the typical black or dark asphalt shingles) you can lower the temperature of your roof by almost 100F Since more light is reflected you reduce the amount of heat absorbed into your structure, reduce the heat island effect, and can reduce your cooling needs.

xorshift (author)tradergordo2007-02-23

My attic gets over 128 degrees f, so I imagine a ridge vent would help, and no ongoing cost post installation, either way you go you may have to look at increasing your soffit vents to equalize out the input/output.. I probably won't get it installed until later in the year though..

Derin (author)2009-04-29

You could also wire it up to the A/C and set it to try to keep the temperature constant.

ketas (author)2008-03-07

But what about RRDtool? I know it can run under win32 as well. MRTG isn't really for temperature logging and graphing (Maybe MRTG 3 will be).

I, personally, run it under FreeBSD.
Take a look:

It's currently undocumented, but I'm happy to share everything :)

MrJeffreyGee (author)2008-01-22

In one of your mouseover image descriptions, you say "usb adaptors may not work correctly". Could you please clarify on that a little more? Have you/anyone tried using the DS9490R USB adaptor instead of the DS9097#?

xorshift (author)MrJeffreyGee2008-01-28

It's has been a little while since I built the exe for this, I believe the problem was getting the command line executable working, but this may have just been my personal problem, the usb interface is supported by many other apps, check out
owfs for easy support through Linux, at least that is the direction I'm headed..

Gooserider (author)2007-02-27

looks real useful, but my app involves a slightly different temp range. I want to monitor flue temperatures on a wood stove, that can get to slightly over 1,000*F.... Is there a substitute part that would give the temp range of a "Type K" thermocouple? (~1250*C or 2250*F max temps, don't need to go under room temp)

tr0g (author)Gooserider2007-07-15


What you want is a MAXIM MAX6675. It takes the input directly from a Type-K thermocouple and puts out an SPI 12-bit readout up to 1024 degrees c. Sparkfun sells them. It complicates things a bit, as you need the TC and the max chip. But it's better than trying to screw around with the temp tables, etc, to get the conversion from the raw TC voltage.

xorshift (author)Gooserider2007-05-03

I couldn't find sensors that support nearly that range, but if you found a thermocouple that changed a voltage per temp. , you could use a 1wire analog/digital converter, read in the voltage and then calculate/graph the temperature

Toxicboy (author)2007-05-03

Great post and I followed most of it to the point where I read in your mrtg.cfg: ### TEMP 1 wire #Target[TEMP0]: `g:\webroot\wwwroot\dynamic\rsH_1wiretemp.exe "COM1" 6A0008010FCEFF10,9F0008010FAB7B10,TEMP0` Target[TEMP0]: `perl g:\webroot\wwwroot\dynamic\ "COM1" Outside,Attic,TEMP0` What does the look like and why did u comment out rsh_call1wiretemp.exe. Why are you using the perl script. COuld be my lack of Perl knowledge here, but I am really curious to implement this how you did. Thanks for the work.

xorshift (author)Toxicboy2007-05-03

Sorry, you can ignore the perl script, it was just a frontend to the exe so I could reference sensors by their name, not their serial number, I can post it as well, but the exe is all you really need, it does the serial work to talk to the sensor and format it in the correct mrtg format I will edit and repost the mrtg cfg file

fjace (author)2007-02-22

Do these sensors work in liquids? I need to monitor the temperature of a bunch of fish tanks. Great instructable.

xorshift (author)fjace2007-02-23

you'd want to seal them, I've seen some use epoxy filled straws, and others with silicone, for an aquarium I'd choose the latter, and rinse well...

Professor Hognutz (author)2007-02-22

Is there anything MRTG won't do?

jarv34 (author)2007-02-21

very cool, i've been wanting to do something similar in my house. It would be neat to try to make this work wirelessly so you could have multiple sensors around the house (maybe cheap wireless tx/rx from sparkfun?) or have it communicate over the power lines like an x10 device. I did a quick a look for one and didn't find anything similar. Great job!

About This Instructable




More by xorshift:$30 Historical Temperature Sensor System using PC,1-wire, Perl, MRTG
Add instructable to: