Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/perl -w
- # Reads data from Current Cost and e.on energy monitor devices via serial port.
- # Derived from http://www.jibble.org/currentcost/
- # and http://www.linuxuk.org/2008/12/currentcost-and-ubuntu/
- use strict;
- use Device::SerialPort qw( :PARAM :STAT 0.07 );
- my $PORT = "/dev/ttyUSB0";
- my $ob = Device::SerialPort->new($PORT);
- $ob->baudrate(57600);
- $ob->write_settings;
- open(SERIAL, "+>$PORT");
- while (my $line = <SERIAL>) {
- if ($line =~ m!<tmpr> *([\-\d.]+)</tmpr>.*<watts>0*(\d+)</watts>!) {
- my $temp = $1;
- my $watts = $2;
- #print "$watts, $temp\n";
- system("rrdtool update powertemp.rrd N:$watts:$temp")
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement