Advertisement
Guest User

Untitled

a guest
Nov 17th, 2019
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 0.77 KB | None | 0 0
  1. #!/usr/bin/perl
  2. $mods = `cat /proc/modules`;
  3. if ($mods =~ /w1_gpio/ && $mods =~ /w1_therm/)
  4. {
  5.  print "w1 modules already loaded \n";
  6. }
  7. else
  8. {
  9. print "loading w1 modules \n";
  10. $mod_gpio = `sudo modprobe w1-gpio`;
  11. $mod_them = `sudo modprobe w1-therm`;
  12. }
  13.  
  14. $sensor_temp = `cat /sys/bus/w1/devices/10-*/w1_slave 2>&1`;
  15. if ($sensor_temp !~ /No such file or directory/)
  16. {
  17. if ($sensor_temp !~ /NO/)
  18. {
  19.         $sensor_temp =~ /t=(\d+)/i;
  20.         $tempreature = (($1/1000)-6); # My sensor seems to read about 6 degrees high, so quick fudge to fix value
  21.         $rrd_out = `/usr/bin/rrdtool update  /home/pi/temperature/rPItemp.rrd N:$tempreature`;
  22.  
  23.  
  24.         print "rPI temp = $tempreature\n";
  25.         exit;
  26. }
  27. die "Error locating sensor file or sensor CRC was invalid";
  28.  
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement