I am trying to configure multiply DS18s20 temperature sensors on my rasberry pi.
I have based my setup on following mannual
Fallow the orders step by step
Run detect.pl
Script has detected my 3 sensors and generate sensors.conf
But when Iam trying to run gettemp.pl script i get following error message:
rrdtool updatev /home/pi/MultiTemp/multirPItemp.rrd --template InBox:Outdoor:InBirdBox N:0:0:0
return_value = -1
ERROR: unknown DS name 'InBox'
This is how my sensors.conf look like:
Code: Select all
OutDoor,0.0,10-000802b67ffc
InBirdNest,0.0,10-000802b65cc2
InBox,0.0,10-000802b685ca
Below you can find gettemp.pl code:
Code: Select all
#!/usr/bin/perl
use strict;
use warnings;
#made sure we've got the 1-wire modules loaded
&check_modules;
#load up the device ID file.
&get_device_IDs;
use vars qw(%deviceIDs %deviceCal $path);
my $count = 0;
my $reading = -1;
my $device = -1;
#my @deviceIDs;
my @temp_readings;
my %T_readings = ();
my $templateline = " --template ";
my $updateline = " N:";
my $path = "here is correct path to my rrd database";
my $commandline = "rrdtool updatev " . $path ."multirPItemp.rrd"; #change to match your file locations
for my $key ( keys %deviceIDs ) {
my $ID = $deviceIDs{$key};
$reading = &read_device($ID);
if ($reading == 9999) {
$reading = "U";
}
$T_readings{$key} = $reading + $deviceCal{$key};
$templateline .= $key;
$templateline .= ":";
$updateline .= $T_readings{$key} . ":";
}
#ditch extra ":" that makes rrdtool fail
chop($templateline);
chop($updateline);
$commandline .= $templateline;
$commandline .= $updateline;
print $commandline ."\n";
system ($commandline);
sub check_modules
{
my $mods = `cat /proc/modules`;
if ($mods =~ /w1_gpio/ && $mods =~ /w1_therm/)
{
#print "w1 modules already loaded \n";
}
else
{
print "loading w1 modules \n";
`sudo modprobe wire`;
`sudo modprobe w1-gpio`;
`sudo modprobe w1-therm`;
}
}
sub get_device_IDs
{
# If you've run detect.pl before, sensors.conf should be a CSV file containing a list of indicies and deviceIDs
# Pull them into a hash here for processing later
# open file
open(INFILE, "sensors.conf") or die("Unable to open file");
while(<INFILE>)
{
chomp;
(my $index, my $cal, my $ID) = split(/,/);
$index =~ s/\s*$//g;
$deviceIDs{$index} = $ID;
$deviceCal{$index} = $cal;
}
close(INFILE);
}
sub read_device
{
#takes one parameter - a device ID
#returns the temperature if we have something like valid conditions
#else we return "9999" for undefined
my $deviceID = $_[0];
$deviceID =~ s/\R//g;
my $ret = 9999; # default to return 9999 (fail)
my $sensordata = `cat /sys/bus/w1/devices/${deviceID}/w1_slave 2>&1`;
#print "Read: $sensordata";
if(index($sensordata, 'YES') != -1) {
#fix for negative temps from http://habrahabr.ru/post/163575/
$sensordata =~ /t=(\D*\d+)/i;
#$sensor_temp =~ /t=(\d+)/i;
$sensordata = (($1/1000));
$ret = $sensordata;
} else {
print ("CRC Invalid for device $deviceID.\n");
}
return ($ret);
}Any ideaa what might be wrong ?