Friday, December 30, 2005

digitemp and cacti

So, I write this post on english, because there is rare information about and I like to make it available for non-german speakers too.
I switched completly to linux now and have build a outdoor thermometer using a dallas 1-Wire sensor with a home made serial adapter. Here are schematics and how to build the adapter. There is a debian-package of digitemp, the tool that reads the data from the sensors. It contains three binaries from wich only digitemp_DS9097 works with the RS232 interface. First of all you need to initialize it by doing:

sonium@ubuntu:~$ digitemp_DS9097 -s/dev/ttyS0 -i
DigiTemp v3.3.2 Copyright 1996-2004 by Brian C. Lane
GNU Public License v2.0 - http://www.brianlane.com
Turning off all DS2409 Couplers
.
Searching the 1-Wire LAN
105734DB00080028 : DS1820/DS18S20/DS1920 Temperature Sensor
ROM #0 : 105734DB00080028
Wrote .digitemprc


now you should be able to receive the temperature by using:

sonium@ubuntu:~$ digitemp_DS9097 -r1000 -a
DigiTemp v3.3.2 Copyright 1996-2004 by Brian C. Lane
GNU Public License v2.0 - http://www.brianlane.com
Dec 30 18:22:00 Sensor 0 C: -8.25 F: 17.15


I automated this by crontab:

sudo crontab -u sonium -e

and added the line:

0-59/5 * * * * digitemp_DS9097 -r1000 -a > /var/log/temperature

make shure that there is a file /var/log/temperature that you can access.

On the cacti site I use a script containing:

sleep 1
#make shure that the digitemp has finished
cat /var/log/temperature | grep "C: " | awk '{ print "temp:"$7}'


there should be some about how to embed the script to cacti. Should not be hard to find.

For some strange reason using the cache-file is the only way it works for me. I cannot access digitemp directly with the cacti-script.

So. Hope this might help somone out here.