Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/perl -w
- # Reads data from a Current Cost device via serial port.
- 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!<ch1><watts>0*(\d+)</watts></ch1>.*<tmpr> *([\-\d.]+)</tmpr>!) {
- if ($line =~ m!<tmpr>([\d.]+)</tmpr>.*<ch1><watts>0*(\d+)</watts></ch1>!) {
- my $watts = $2;
- my $temp = $1;
- #print "$watts, $temp\n";
- system ("rrdtool update /home/chloe/bin/powertemp.rrd N:$watts:$temp");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement