Welcome to It-Slav.Net blog
Peter Andersson
peter@it-slav.net

I've already got a female to worry about. Her name is the Enterprise.
-- Kirk, "The Corbomite Maneuver", stardate 1514.0

It-Slav.net is proud to announce as one of the temperature providers to temperatur.nu

It-slav.net provides temperature measurement for STHLM/Huddinge area in Sweden to the very popular site temperatur.nu


The measurment is done by a 1-wire temperature probe DS18S20.

The script that collects the temperature and stores it in a file that is presented as a webpage, the webpage is polled regularly by temperatur.nu

#!/usr/bin/perl
 #
 # rrd_tempsensor.pl
#use lib qw(/usr/local/rrdtool-1.2.15/lib/perl);
 use RRDs;
 use OW;
# define location of rrdtool databases
 my $rrd = '/root/owfs/script/rrd_db';
 # define location of images
 my $img = '/home/peter/public_html/temps';
# process data for each interface (add/delete as required)
 &ProcessSensor(0, "Temperatur_Huddinge", "op5.mynet",3001,"10.DEF05F010800");
sub ProcessSensor
 {
 # process sensor
 # inputs: $_[0]: sensor number (ie, 0/1/2/etc)
 #         $_[1]: sensor description
 print "number:$_[0] desc:$_[1], server:$_[2] port:$_[3], id: $_[4]\n";
 my $owserver = "$_[2]:$_[3]";
unless(OW::init($owserver)) {
 $status = $ERRORS{CRIT};
 $message = "OWServer not running at $owserver\n";
 exit $status;
 }
# get temperature from sensor
 my $handle = OW::get("$_[4]/temperature");
 #    print "handle=$handle\n";
 $handle =~ s/^\s*(.*?)\s*$/$1/;
 ## Check if input is an integer or decimal
 unless (($handle =~ /^-?(?:\d+(?:\.\d*)?|\.\d+)$/) || ($handle =~ /^[+-]?\d+$/))
 {
 print "Not an integer or a decimal\n";
 return($ERRORS{CRITICAL});
 }
$temp=$handle;
 # remove eol chars
 chomp($temp);
print "sensor $_[0]: $temp degrees C\n";
# check for error code from temp sensor
 if (int $temp eq 85)
 {
 print "failed to read value from sensor $_[0]\n";
 }
 else
 {
 #Create webpage
 open WEBPAGE, ">$img/$_[1]"
 or die "Cannot create $img/$_[1]: $!";
 print WEBPAGE "$temp\n";
 }
 }

Links:

Share

2 Responses to “Temperature measurment for temperatur.nu”

  1. Peter Says:

    Hi Peter, I think you have to change the position of the temp probe, allways a few degree warmer than all our thermometers in Huddinge/Stuvsta.

  2. peter Says:

    I have noticed that asweell. The temp probe is probably to close to the house. I will look into that when the snow is gone 🙂

Leave a Reply


seven − 2 =





Book reviews
FreePBX 2.5
Powerful Telephony Solutions






Asterisk 1.6
Build a feature rich telephony system with Asterisk






Learning NAGIOS 3.0





Cacti 0.8 Network Monitoring,
Monitor your network with ease!