Advertisement
Guest User

sensimilla

a guest
Dec 19th, 2010
818
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 0.50 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.  
  5. use strict;
  6. use Device::SerialPort qw( :PARAM :STAT 0.07 );
  7.  
  8. my $PORT = "/dev/ttyUSB0";
  9.  
  10. my $ob = Device::SerialPort->new($PORT);
  11. $ob->baudrate(57600);
  12. $ob->write_settings;
  13.  
  14. open(SERIAL, "+>$PORT");
  15. while (my $line = <SERIAL>) {
  16.     if ($line =~ m!<tmpr> *([\-\d.]+)</tmpr>.*<watts>0*(\d+)</watts>!) {
  17.         my $temp = $1;
  18.         my $watts = $2;
  19.         print "$watts, $temp\n";
  20.     }
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement