Created
August 20, 2012 11:02
-
-
Save kgleeson/3403209 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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!<tmpr>\s*(-*[\d.]+)</tmpr>.*<ch1><watts>0*(\d+)</watts></ch1>!) { | |
my $watts = $2; | |
my $temp = $1; | |
exec "rrdtool update /etc/cron.cc/rrd/powertemp.rrd N:$watts:$temp"; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment