RTL AMR - Scripts

For those of you using the RTLAMR system to pull utility data, I developed a simple perl and bash script to gather the data on 5 minute intervals. Hope it might help someone.

 

root@raspi2:~# cat econ.pl 

#!/usr/bin/perl

use LWP::Simple;

my $key = "";

my $server = "";

my $data = `rtlamr -filterid=$ARGV[0] -format=csv -quiet -single 2> /dev/null`;

print "data = $data\n";

my ($time,$i1,$i2,$id,$type,$tp,$te,$value,$crc) = split(/,/,$data);

my $url = "http://$server/emoncms/input/post.json?node=1&json={$ARGV[1]:$value}&apikey=$key";

my $content = get $url;

print "url = $url\n";

print "content = $content\n";

 

root@raspi2:~# cat econ_poll.sh 

#!/bin/bash

while :

do

   /usr/bin/perl /root/econ.pl ######## water

   /usr/bin/perl /root/econ.pl ######## gas

   sleep 300

done