Advertisement
Guest User

cc128-3

a guest
Dec 19th, 2011
354
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. #!/usr/bin/perl -w
  2.  
  3. # Reads data from Current Cost and e.on energy monitor devices via serial port.
  4. # Derived from http://www.jibble.org/currentcost/
  5. # and http://www.linuxuk.org/2008/12/currentcost-and-ubuntu/
  6.  
  7. use strict;
  8. use Device::SerialPort qw( :PARAM :STAT 0.07 );
  9.  
  10. my $PORT = "/dev/ttyUSB0";
  11.  
  12. my $ob = Device::SerialPort->new($PORT);
  13. $ob->baudrate(57600);
  14. $ob->write_settings;
  15.  
  16. open(SERIAL, "+>$PORT");
  17. while (my $line = <SERIAL>) {
  18. if ($line =~ m!<tmpr> *([\-\d.]+)</tmpr>.*<watts>0*(\d+)</watts>!) {
  19. my $temp = $1;
  20. my $watts = $2;
  21. #print "$watts, $temp\n";
  22. system("rrdtool update powertemp.rrd N:$watts:$temp")
  23. }
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement