User avatar
Obel
Posts: 18
Joined: Wed Jun 17, 2015 12:36 pm
Location: UK

Unable to get temp from multiply sensor

Thu Jun 25, 2015 11:58 am

Hi All

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
If i run detect.pl and don`t change sensor.conf i have the same error message

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);
}
I have tried to contact with script author but I belive he is to busy

Any ideaa what might be wrong ?

ame
Posts: 3172
Joined: Sat Aug 18, 2012 1:21 am
Location: New Zealand

Re: Unable to get temp from multiply sensor

Thu Jun 25, 2015 12:17 pm

Obel wrote: 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
I don't know for sure what the problem is, but in your rrdtool command you have these three labels
InBox:Outdoor:InBirdBox

In your configuration file you have these three labels:
OutDoor
InBirdNest
InBox

I would expect them to be the same, with the same spelling.

User avatar
Obel
Posts: 18
Joined: Wed Jun 17, 2015 12:36 pm
Location: UK

Re: Unable to get temp from multiply sensor

Wed Jul 01, 2015 7:52 am

ame wrote:
Obel wrote: 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
I don't know for sure what the problem is, but in your rrdtool command you have these three labels
InBox:Outdoor:InBirdBox

In your configuration file you have these three labels:
OutDoor
InBirdNest
InBox

I would expect them to be the same, with the same spelling.

That was exacly the issue, I didn`t define the names in rddtool database
THX

Return to “Python”