Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/perl
- $mods = `cat /proc/modules`;
- if ($mods =~ /w1_gpio/ && $mods =~ /w1_therm/)
- {
- print "w1 modules already loaded \n";
- }
- else
- {
- print "loading w1 modules \n";
- $mod_gpio = `sudo modprobe w1-gpio`;
- $mod_them = `sudo modprobe w1-therm`;
- }
- $sensor_temp = `cat /sys/bus/w1/devices/10-*/w1_slave 2>&1`;
- if ($sensor_temp !~ /No such file or directory/)
- {
- if ($sensor_temp !~ /NO/)
- {
- $sensor_temp =~ /t=(\d+)/i;
- $tempreature = (($1/1000)-6); # My sensor seems to read about 6 degrees high, so quick fudge to fix value
- $rrd_out = `/usr/bin/rrdtool update /home/pi/temperature/rPItemp.rrd N:$tempreature`;
- print "rPI temp = $tempreature\n";
- exit;
- }
- die "Error locating sensor file or sensor CRC was invalid";
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement