Very Cheap TED 1001 House Power Monitors (and possible hacking)

But a question for anyone who might be able to answer, i  have being trying to figure out a  way to kill the above script if it  does not process  5 sets of  of data..,, because i see some times it loose sync,  and it very easy to reset to sync just restart the program.  I have a special script that automatically restarts ted if it not running ( you can pull the usb cable out unplug the ted what have you as soon as it detected again it is running) , and I use cron to kill it every  minute, but some times you can loose up to minute of data.. it  would be nice if the script itself could kill itself if 5 data sets fail. then it simple  reset itself.. and it would automatically re-sync..
 
any ideas how to  do that,, my perl  is not that great.. pretty much none existent :)
 
okay slept on it and it came to me in the middle of the night. Now it error corrects if the data sets become out of sync on the second failed set. now it produce graphs with out any data holes..  i t even seams to keep reading in conditions the ted device fails to read.. ( it just re sync more often in those conditions)
script name
 
ted1a.pl

#!/usr/bin/perl -w -s

system("stty -F /dev/ttyUSB0 1200 cs8 raw");

open INFILE, "/dev/ttyUSB0"
or die "\nCannot open /dev/ttyUSB0!\n";


@data = ();
$buf = "";
$begin = 0;
$started = 0;
sub processPacket($);

while (read(INFILE, $buf, 1)) {
$d = ord($buf) ^ 0xff;
if ($d == 0x55 && $started == 0) {
$started = 1;
$a = 0;

}
if ($started == 1) {
$data[$a] = $d;
$sum += $data[$a];
# printf("0x%02X ", $data[$a]);
$a++;
if ($a >= 11) {
$sum -= $data[9];
$sum &= 0xff;
if ($sum == 0) { processPacket($data); }
$started=1;
$a = 0;
}

}
if ( $begin <= 22) {
$cnt = ($begin + 1);
$begin = $cnt;}
print "$begin bit ";
if ($begin >= 23) {close INFILE;}
}

# Working sub process packet stuff
sub processPacket($) {
local($data) = @_;
# your personal setup info
# $dir= ted data folder - $ted = name of ted rrd file
$dir = '/home/user/';
$ted = 'ted';
$ted1 = 'ted1';
$ted2 = 'ted2';

$mtu = $data[1];
# the $mtu equals your mtu number put in a Decimal to Hexadecimal Converter )
if ($begin <= 22) {
$begin = 1;
if ($mtu == 0xCE ) {
# If the power reading is way off, uncomment the other power line
$p = (($data[5]^0xff)<<8) + ($data[4]^0xff);
# print "$p ";
$pa = ($data[5]<<8) + $data[4];
# print "$pa ";
if ($p <= 5000) {
$voltage = ($data[8] << 8) | $data[7];
$voltage = sprintf("%.3f",123.6 + ($voltage - 27620) / 85 * 0.2);
$p = sprintf("%.3f",(1.19 + 0.84 * (($p - 288.0) / 204.0)));
@tda = localtime(time);
$td = ($tda[4]+1)."/$tda[3]/".(1900+$tda[5])." $tda[2]:$tda[1]:$tda[0]";
print "$td, Hydro $p, Voltage $voltage\n";
system("rrdtool updatev $dir/$ted.rrd N:$p:$voltage");
$begin = 0;
}
if ($pa <= 5000) {
# $power = ($data[5]<<8) + $data[4];
$voltage = ($data[8] << 8) | $data[7];
$voltage = sprintf("%.3f",123.6 + ($voltage - 27620) / 85 * 0.2);
$pa = sprintf("%.3f",(0 - (1.19 + 0.84 * (($pa - 288.0) / 204.0))));
@tda = localtime(time);
$td = ($tda[4]+1)."/$tda[3]/".(1900+$tda[5])." $tda[2]:$tda[1]:$tda[0]";
print "$td, Hydro $pa, Voltage $voltage\n";
system("rrdtool updatev $dir/$ted.rrd N:$pa:$voltage");
$begin = 0;
}
}

if ($mtu == 0xA0 ) {
# If the power reading is way off, uncomment the other power line
$w = (($data[5]^0xff)<<8) + ($data[4]^0xff);
# print "$w ";
$wa = ($data[5]<<8) + $data[4];
# print "$wa ";
if ($w <= 5000) {
$voltage1 = ($data[8] << 8) | $data[7];
$voltage1 = sprintf("%.3f",123.6 + ($voltage1 - 27620) / 85 * 0.2);
$w = sprintf("%.3f",(1.19 + 0.84 * (($w - 288.0) / 204.0)));
@tda = localtime(time);
$td = ($tda[4]+1)."/$tda[3]/".(1900+$tda[5])." $tda[2]:$tda[1]:$tda[0]";
print "$td, Wind $w, Voltage $voltage1\n";
system("rrdtool updatev $dir/$ted2.rrd N:$w:$voltage1");
$begin = 0;
}
if ($wa <= 5000) {
# $power = ($data[5]<<8) + $data[4];
$voltage1 = ($data[8] << 8) | $data[7];
$voltage1 = sprintf("%.3f",123.6 + ($voltage1 - 27620) / 85 * 0.2);
$wa = sprintf("%.3f",(0 - (1.19 + 0.84 * (($wa - 288.0) / 204.0))));
@tda = localtime(time);
$td = ($tda[4]+1)."/$tda[3]/".(1900+$tda[5])." $tda[2]:$tda[1]:$tda[0]";
print "$td, Wind $wa, Voltage $voltage1\n";
system("rrdtool updatev $dir/$ted2.rrd N:$wa:$voltage1");
$begin = 0;
}
}
if ($mtu == 0xB1 ) {
# If the power reading is way off, uncomment the other power line
$s = (($data[5]^0xff)<<8) + ($data[4]^0xff);
# print "$s ";
$sa = ($data[5]<<8) + $data[4];
# print "$sa ";
if ($s <= 5000) {
$voltage2 = ($data[8] << 8) | $data[7];
$voltage2 = sprintf("%.3f",123.6 + ($voltage2 - 27620) / 85 * 0.2);
$s = sprintf("%.3f",(1.19 + 0.84 * (($s - 288.0) / 204.0)));
@tda = localtime(time);
$td = ($tda[4]+1)."/$tda[3]/".(1900+$tda[5])." $tda[2]:$tda[1]:$tda[0]";
print "$td, Solar $s, Voltage $voltage2\n";
system("rrdtool updatev $dir/$ted1.rrd N:$s:$voltage2");
$begin = 0;
}
if ($sa <= 5000) {
# $power = ($data[5]<<8) + $data[4];
$voltage2 = ($data[8] << 8) | $data[7];
$voltage2 = sprintf("%.3f",123.6 + ($voltage2 - 27620) / 85 * 0.2);
$sa = sprintf("%.3f",(0 - (1.19 + 0.84 * (($sa - 288.0) / 204.0))));
@tda = localtime(time);
$td = ($tda[4]+1)."/$tda[3]/".(1900+$tda[5])." $tda[2]:$tda[1]:$tda[0]";
print "$td, Solar $sa, Voltage $voltage2\n";
system("rrdtool updatev /$dir/$ted1.rrd N:$sa:$voltage2");
$begin = 0;
}
}

}
else {close INFILE;}
}

close INFILE;

but it is important  that you use this program to start your data collection ( just place tedStart.pl and ted1a.pl in /bin of your root directory and  set to run at boot  in your rc.local or similar
 
tedStart.pl

#!/usr/bin/perl -W -s

for( ; ; )
{
printf "killing ted process.\n";
system("pkill -f ted1a.pl");
printf "Starting Ted data collection.\n";
sleep(1);
system("ted1a.pl")
}

to create your  rrd files  just rename ted.rrd  > ted1.rrd etc  this one keeps 3 months of data

rrdtool create ted.rrd --step 3 DS:kw:GAUGE:5:0:U DS:volt:GAUGE:5:0:U RRA:MIN:0.5:12:2592000 RRA:AVERAGE:0.5:1:2592000 RRA:MAX:0.5:1:2594000

for graph creation just adjust  time scale

#!/bin/bash

now=$(date +%s)
now_formatted=$(date +%s | awk '{printf "%s\n", strftime("%c",$1)}' | sed -e 's/:/\\:/g')

/usr/bin/rrdtool graph 10min.png \
-w 543 -h 267 -a PNG \
--slope-mode \
--start -600 --end now \
--title "Power: For the Last 10 minutes" \
--vertical-label "KILOWATTS (KW)" \
DEF:kw=ted.rrd:kw:AVERAGE \
VDEF:Last=kw,LAST \
VDEF:First=kw,FIRST \
VDEF:Min=kw,MINIMUM \
VDEF:peak=kw,MAXIMUM \
VDEF:Average=kw,AVERAGE \
CDEF:kWh=kw,10,/,10,* \
CDEF:Cost=kWh,.0665,* \
LINE1:kw#005199FF:"POWER " \
AREA:kw#00519933:"" \
GPRINT:Last:"%6.4lf%sKW" \
COMMENT:"\\n" \
HRULE:Average#9595FF:"Average" \
GPRINT:kw:AVERAGE:"%6.4lf%sKW" \
COMMENT:"\\n" \
HRULE:peak#ff0000:"Peak " \
GPRINT:kw:MAX:"%6.3lf%sKW" \
COMMENT:"\\n" \
HRULE:Min#58FAF4:"Min " \
GPRINT:kw:MIN:"%6.4lf%sKW" \
COMMENT:"\\n" \
GPRINT:kWh:AVERAGE:" total %6.2lfkWh\\n" \
GPRINT:Cost:AVERAGE:" cost %6.2lf $\\n" \
GPRINT:Cost:AVERAGE:"$(printf \\" cost %11s\\" $%.2lf | sed 's/\$/\$ /g')\\n" \
COMMENT:" \\n" \
GPRINT:First:"Showing from %c\\n":strftime \
GPRINT:Last:" to %c\\n":strftime \
COMMENT:" Created at $now_formatted"

if you want to compare this week to last week
Code:
#!/bin/bash

now=$(date +%s)
now_formatted=$(date +%s | awk '{printf "%s\n", strftime("%c",$1)}' | sed -e 's/:/\\:/g')

# create power graph for last week
/usr/bin/rrdtool graph power-week.png \
--start end-7d --width 543 --height 267 --end $now-1min --slope-mode \
--vertical-label "KiloWatts" --lower-limit 0 \
--alt-autoscale-max \
--title "Power: Last week vs. week before" \
--watermark "(©) $(date +%Y) Alyn R. Tiedtke" \
--font WATERMARK:8 \
DEF:kw=ted.rrd:kw:AVERAGE \
DEF:Power2=ted.rrd:kw:AVERAGE:end=$now-7d1min:start=end-7d \
VDEF:Last=kw,LAST \
VDEF:First=kw,FIRST \
VDEF:Min=kw,MINIMUM \
VDEF:Peak=kw,MAXIMUM \
VDEF:Average=kw,AVERAGE \
CDEF:kWh=kw,10,/,168,* \
CDEF:Cost=kWh,.0665,* \
SHIFT:Power2:604800 \
LINE1:Power2#00CF00FF:"Last Week\\n" \
HRULE:Min#58FAF4:"Min    " \
GPRINT:kw:MIN:"%6.4lf%sKW" \
COMMENT:"\\n" \
LINE1:kw#005199FF:"Power  " \
AREA:kw#00519933:"" \
GPRINT:Last:"%6.4lf%sKW" \
COMMENT:"\\n" \
HRULE:Average#9595FF:"Average" \
GPRINT:kw:AVERAGE:"%6.4lf%sKW" \
COMMENT:"\\n" \
HRULE:Peak#ff0000:"Peak   " \
GPRINT:kw:MAX:"%6.3lf%sKW" \
COMMENT:"\\n" \
GPRINT:kWh:AVERAGE:"  total    %6.4lfkWh\\n" \
GPRINT:Cost:AVERAGE:"  cost     %6.2lf $\\n" \
GPRINT:Cost:AVERAGE:"$(printf \\" cost %11s\\" $%.2lf | sed 's/\$/\$ /g')\\n" \
COMMENT:" \\n" \
GPRINT:First:"Showing from %c\\n":strftime \
GPRINT:Last:"          to %c\\n":strftime \
COMMENT:"  Created at $now_formatted"
 
if any one interested or wants  I uploaded a  complete copy of my software package for the ted 1001 at http://id-discussions.com/forum/showthread.php?p=464581#post464581. ( as I do not know how to upload a file here or atleast a file  that is 550kbs
 
 the  file is designed of Ubuntu ( but gave instructions for Opensuse in the readme ) the one I uploaded does  up to three MTU but gave instruction for how to add more mtu capability. 
the  graphical interface displays the live kw usage and voltage,  gives graphical report of 10minutes, 60 minute, 8hrs 24 hours,  one week  and one week comparison after I collect data for a few weeks i will probably build a  one month and one month comparison . ( as extra I included 1month, 3 months 6 months and 1 year graphing scripts  already)
it gives your current usage   and costs . plus projected  cost and usage  based on your current average for  last 8  hrs  displaying projected cost for the next 24 hours.  24 hrs and the projected cost and usage for the next month.  1 week and the projected cost and usage for the next month,   it also  graphically  compares last week usage to current week usage .. so now it is basically  a more functional ted 5000. as I can  walk around the house with a table or  smart phone  and see  everything  only in a prettier graphical interface  with alot more accuracy as it reports to the nearest watt instead of 10 watts as the device is suppose to have an accuracy of +/- 2%
 
I run everything from a  very small acer netbook  that sits on the table  with the lid close  with a ted sitting on top of it, it uses very little power at  about 15 watts in total.
 
But I am thinking I will buy some ubuntu mFi Mpower  devices  and use the ted software later on to trigger certain events under certain  conditions
 
 
I tried this on Raspbian and I get alot of weird output. Is this normal? What are all the NaN results about?
 

sudo perl /bin/ted1a.pl
1 bit 2 bit 3 bit 4 bit 5 bit 6 bit 7 bit 8 bit 9 bit 10 bit 6/16/2014 21:44:41, Hydro -1.169, Voltage 118.542
return_value = 0
[1402980192]RRA[MIN][12]DS[kw] = NaN
[1402980192]RRA[MIN][12]DS[volt] = 6.0524380109e+01
[1402980264]RRA[MIN][12]DS[kw] = NaN
[1402980264]RRA[MIN][12]DS[volt] = NaN
[1402980300]RRA[MIN][12]DS[kw] = NaN
[1402980300]RRA[MIN][12]DS[volt] = NaN
[1402980189]RRA[AVERAGE][1]DS[kw] = NaN
[1402980189]RRA[AVERAGE][1]DS[volt] = NaN
[1402980195]RRA[AVERAGE][1]DS[kw] = NaN
[1402980195]RRA[AVERAGE][1]DS[volt] = NaN
[1402980198]RRA[AVERAGE][1]DS[kw] = NaN
[1402980198]RRA[AVERAGE][1]DS[volt] = NaN
[1402980201]RRA[AVERAGE][1]DS[kw] = NaN
[1402980201]RRA[AVERAGE][1]DS[volt] = NaN
[1402980204]RRA[AVERAGE][1]DS[kw] = NaN
[1402980204]RRA[AVERAGE][1]DS[volt] = NaN
[1402980207]RRA[AVERAGE][1]DS[kw] = NaN
[1402980207]RRA[AVERAGE][1]DS[volt] = NaN
[1402980210]RRA[AVERAGE][1]DS[kw] = NaN
[1402980210]RRA[AVERAGE][1]DS[volt] = NaN
[1402980213]RRA[AVERAGE][1]DS[kw] = NaN
[1402980213]RRA[AVERAGE][1]DS[volt] = NaN
[1402980216]RRA[AVERAGE][1]DS[kw] = NaN
[1402980216]RRA[AVERAGE][1]DS[volt] = NaN
[1402980219]RRA[AVERAGE][1]DS[kw] = NaN
[1402980219]RRA[AVERAGE][1]DS[volt] = NaN
[1402980222]RRA[AVERAGE][1]DS[kw] = NaN
[1402980222]RRA[AVERAGE][1]DS[volt] = NaN
[1402980225]RRA[AVERAGE][1]DS[kw] = NaN
[1402980225]RRA[AVERAGE][1]DS[volt] = NaN
[1402980228]RRA[AVERAGE][1]DS[kw] = NaN
[1402980228]RRA[AVERAGE][1]DS[volt] = NaN
[1402980231]RRA[AVERAGE][1]DS[kw] = NaN
[1402980231]RRA[AVERAGE][1]DS[volt] = NaN
[1402980234]RRA[AVERAGE][1]DS[kw] = NaN
[1402980234]RRA[AVERAGE][1]DS[volt] = NaN
[1402980237]RRA[AVERAGE][1]DS[kw] = NaN
[1402980237]RRA[AVERAGE][1]DS[volt] = NaN
[1402980240]RRA[AVERAGE][1]DS[kw] = NaN
[1402980240]RRA[AVERAGE][1]DS[volt] = NaN
[1402980243]RRA[AVERAGE][1]DS[kw] = NaN
[1402980243]RRA[AVERAGE][1]DS[volt] = NaN
[1402980246]RRA[AVERAGE][1]DS[kw] = NaN
[1402980246]RRA[AVERAGE][1]DS[volt] = NaN
[1402980249]RRA[AVERAGE][1]DS[kw] = NaN
[1402980249]RRA[AVERAGE][1]DS[volt] = NaN
[1402980252]RRA[AVERAGE][1]DS[kw] = NaN
[1402980252]RRA[AVERAGE][1]DS[volt] = NaN
[1402980255]RRA[AVERAGE][1]DS[kw] = NaN
[1402980255]RRA[AVERAGE][1]DS[volt] = NaN
[1402980258]RRA[AVERAGE][1]DS[kw] = NaN
[1402980258]RRA[AVERAGE][1]DS[volt] = NaN
[1402980261]RRA[AVERAGE][1]DS[kw] = NaN
[1402980261]RRA[AVERAGE][1]DS[volt] = NaN
[1402980264]RRA[AVERAGE][1]DS[kw] = NaN
[1402980264]RRA[AVERAGE][1]DS[volt] = NaN
[1402980267]RRA[AVERAGE][1]DS[kw] = NaN
[1402980267]RRA[AVERAGE][1]DS[volt] = NaN
[1402980270]RRA[AVERAGE][1]DS[kw] = NaN
[1402980270]RRA[AVERAGE][1]DS[volt] = NaN
[1402980273]RRA[AVERAGE][1]DS[kw] = NaN
[1402980273]RRA[AVERAGE][1]DS[volt] = NaN
[1402980276]RRA[AVERAGE][1]DS[kw] = NaN
[1402980276]RRA[AVERAGE][1]DS[volt] = NaN
[1402980279]RRA[AVERAGE][1]DS[kw] = NaN
[1402980279]RRA[AVERAGE][1]DS[volt] = NaN
[1402980282]RRA[AVERAGE][1]DS[kw] = NaN
[1402980282]RRA[AVERAGE][1]DS[volt] = NaN
[1402980285]RRA[AVERAGE][1]DS[kw] = NaN
[1402980285]RRA[AVERAGE][1]DS[volt] = NaN
[1402980189]RRA[MAX][1]DS[kw] = NaN
[1402980189]RRA[MAX][1]DS[volt] = NaN
[1402980195]RRA[MAX][1]DS[kw] = NaN
[1402980195]RRA[MAX][1]DS[volt] = NaN
[1402980198]RRA[MAX][1]DS[kw] = NaN
[1402980198]RRA[MAX][1]DS[volt] = NaN
[1402980201]RRA[MAX][1]DS[kw] = NaN
[1402980201]RRA[MAX][1]DS[volt] = NaN
[1402980204]RRA[MAX][1]DS[kw] = NaN
[1402980204]RRA[MAX][1]DS[volt] = NaN
[1402980207]RRA[MAX][1]DS[kw] = NaN
[1402980207]RRA[MAX][1]DS[volt] = NaN
[1402980210]RRA[MAX][1]DS[kw] = NaN
[1402980210]RRA[MAX][1]DS[volt] = NaN
[1402980213]RRA[MAX][1]DS[kw] = NaN
[1402980213]RRA[MAX][1]DS[volt] = NaN
[1402980216]RRA[MAX][1]DS[kw] = NaN
[1402980216]RRA[MAX][1]DS[volt] = NaN
[1402980219]RRA[MAX][1]DS[kw] = NaN
[1402980219]RRA[MAX][1]DS[volt] = NaN
[1402980222]RRA[MAX][1]DS[kw] = NaN
[1402980222]RRA[MAX][1]DS[volt] = NaN
[1402980225]RRA[MAX][1]DS[kw] = NaN
[1402980225]RRA[MAX][1]DS[volt] = NaN
[1402980228]RRA[MAX][1]DS[kw] = NaN
[1402980228]RRA[MAX][1]DS[volt] = NaN
[1402980231]RRA[MAX][1]DS[kw] = NaN
[1402980231]RRA[MAX][1]DS[volt] = NaN
[1402980234]RRA[MAX][1]DS[kw] = NaN
[1402980234]RRA[MAX][1]DS[volt] = NaN
[1402980237]RRA[MAX][1]DS[kw] = NaN
[1402980237]RRA[MAX][1]DS[volt] = NaN
[1402980240]RRA[MAX][1]DS[kw] = NaN
[1402980240]RRA[MAX][1]DS[volt] = NaN
[1402980243]RRA[MAX][1]DS[kw] = NaN
[1402980243]RRA[MAX][1]DS[volt] = NaN
[1402980246]RRA[MAX][1]DS[kw] = NaN
[1402980246]RRA[MAX][1]DS[volt] = NaN
[1402980249]RRA[MAX][1]DS[kw] = NaN
[1402980249]RRA[MAX][1]DS[volt] = NaN
[1402980252]RRA[MAX][1]DS[kw] = NaN
[1402980252]RRA[MAX][1]DS[volt] = NaN
[1402980255]RRA[MAX][1]DS[kw] = NaN
[1402980255]RRA[MAX][1]DS[volt] = NaN
[1402980258]RRA[MAX][1]DS[kw] = NaN
[1402980258]RRA[MAX][1]DS[volt] = NaN
[1402980261]RRA[MAX][1]DS[kw] = NaN
[1402980261]RRA[MAX][1]DS[volt] = NaN
[1402980264]RRA[MAX][1]DS[kw] = NaN
[1402980264]RRA[MAX][1]DS[volt] = NaN
[1402980267]RRA[MAX][1]DS[kw] = NaN
[1402980267]RRA[MAX][1]DS[volt] = NaN
[1402980270]RRA[MAX][1]DS[kw] = NaN
[1402980270]RRA[MAX][1]DS[volt] = NaN
[1402980273]RRA[MAX][1]DS[kw] = NaN
[1402980273]RRA[MAX][1]DS[volt] = NaN
[1402980276]RRA[MAX][1]DS[kw] = NaN
[1402980276]RRA[MAX][1]DS[volt] = NaN
[1402980279]RRA[MAX][1]DS[kw] = NaN
[1402980279]RRA[MAX][1]DS[volt] = NaN
[1402980282]RRA[MAX][1]DS[kw] = NaN
[1402980282]RRA[MAX][1]DS[volt] = NaN
[1402980285]RRA[MAX][1]DS[kw] = NaN
[1402980285]RRA[MAX][1]DS[volt] = NaN
1 bit 2 bit 3 bit 4 bit 5 bit 6 bit 7 bit 8 bit 9 bit 10 bit 11 bit 6/16/2014 21:44:42, Hydro -1.186, Voltage 118.542
return_value = 0
1 bit 2 bit 3 bit 4 bit 5 bit 6 bit 7 bit 8 bit 9 bit 10 bit 11 bit 6/16/2014 21:44:43, Hydro -1.174, Voltage 118.542
return_value = 0
1 bit 2 bit 3 bit 4 bit 5 bit 6 bit 7 bit 8 bit 9 bit 10 bit 11 bit 6/16/2014 21:44:44, Hydro -1.174, Voltage 118.542
return_value = 0
1 bit 2 bit 3 bit 4 bit 5 bit 6 bit 7 bit 8 bit 9 bit 10 bit 11 bit 6/16/2014 21:44:45, Hydro -1.186, Voltage 118.542
return_value = 0
[1402980285]RRA[AVERAGE][1]DS[kw] = NaN
[1402980285]RRA[AVERAGE][1]DS[volt] = 1.1841887438e+02
[1402980285]RRA[MAX][1]DS[kw] = NaN
[1402980285]RRA[MAX][1]DS[volt] = 1.1841887438e+02
1 bit 2 bit 3 bit 4 bit 5 bit 6 bit 7 bit 8 bit 9 bit 10 bit 11 bit 6/16/2014 21:44:46, Hydro -1.169, Voltage 118.542
return_value = 0
1 bit 2 bit 3 bit 4 bit 5 bit 6 bit 7 bit 8 bit 9 bit 10 bit 11 bit 6/16/2014 21:44:47, Hydro -1.186, Voltage 118.542
return_value = 0
1 bit 2 bit 3 bit 4 bit 5 bit 6 bit 7 bit 8 bit 9 bit 10 bit 11 bit 6/16/2014 21:44:48, Hydro -1.169, Voltage 118.542
return_value = 0
[1402980288]RRA[AVERAGE][1]DS[kw] = NaN
[1402980288]RRA[AVERAGE][1]DS[volt] = 1.1854200000e+02
[1402980288]RRA[MAX][1]DS[kw] = NaN
[1402980288]RRA[MAX][1]DS[volt] = 1.1854200000e+02
1 bit 2 bit 3 bit 4 bit 5 bit 6 bit 7 bit 8 bit 9 bit 10 bit 11 bit 6/16/2014 21:44:49, Hydro -1.182, Voltage 118.542
return_value = 0
1 bit 2 bit 3 bit 4 bit 5 bit 6 bit 7 bit 8 bit 9 bit 10 bit 11 bit 6/16/2014 21:44:50, Hydro -1.174, Voltage 118.542
return_value = 0
1 bit 2 bit 3 bit 4 bit 5 bit 6 bit 7 bit 8 bit 9 bit 10 bit 11 bit 6/16/2014 21:44:51, Hydro -1.174, Voltage 118.542
return_value = 0
[1402980291]RRA[AVERAGE][1]DS[kw] = NaN
[1402980291]RRA[AVERAGE][1]DS[volt] = 1.1854200000e+02
[1402980291]RRA[MAX][1]DS[kw] = NaN
[1402980291]RRA[MAX][1]DS[volt] = 1.1854200000e+02
1 bit 2 bit 3 bit 4 bit 5 bit 6 bit 7 bit 8 bit 9 bit 10 bit 11 bit 6/16/2014 21:44:52, Hydro -1.182, Voltage 118.542
return_value = 0
1 bit 2 bit 3 bit 4 bit 5 bit 6 bit 7 bit 8 bit 9 bit 10 bit 11 bit 6/16/2014 21:44:53, Hydro -1.174, Voltage 118.542
return_value = 0
1 bit 2 bit 3 bit 4 bit 5 bit 6 bit 7 bit 8 bit 9 bit 10 bit 11 bit 6/16/2014 21:44:54, Hydro -1.186, Voltage 118.542
return_value = 0
[1402980294]RRA[AVERAGE][1]DS[kw] = NaN
[1402980294]RRA[AVERAGE][1]DS[volt] = 1.1854200000e+02
[1402980294]RRA[MAX][1]DS[kw] = NaN
[1402980294]RRA[MAX][1]DS[volt] = 1.1854200000e+02

 
 
@sash
 
Thank you for the link to PFSense and graphing for automation. 
 
I have my cheap modified ted around but disconnected it a while ago.  Sensors are still in the panel. 
 
That said I have been playing a bit with the NTP GPS / PPS stuff.  PFSense is very impressive.  Building a new box with maybe 8 NICs on it.
 
Built  another little linux box (seagate dockstar - pogoplug) weather station which also utilizes the RRD graphing.  (still currently using Wintel Cumulus)
 
@infojoe
 
I have a rasberry pi sitting next to the Ted device running Homeseer.  I'll try to give the application a try on it.
 
I haven't paid attention lately to it and I do not recall if it has perl on it.
 
Seems to freeze up on me quite a bit and or gets out of sink and just starts spitting out the raw hex data. I think I would like to skip the RRDTOOL stuff and just have the data logged as a CSV file on a USB key plugged into the pi so I can just import it into excel. I tried it using cutecom and it works to just log the raw data, but it doesn't seem to write anything until you quit the program which means it is likely just saving it to RAM which is no good if the power goes out before I can save the file. Any ideas? I'm a linux newbie so all this script stuff is dutch to me.
 
Well; here haven't done any RRD stuff on the Raspberry Pi.    The CPU is running around 700Mhz.  That said I have done RRD stuff on the PogoPlug; but that is running at 1.2Ghz (well I think?).
 
I did move from a 4Gb to a 16Gb SD card on the Raspberry Pi.  I pushed it such that the web interface went to a crawl by concurrent running other applications on it (well there is Mono running on it too).
 
No ideas right cuz I just looked at the link above. 
 
Here's the script I am using at the moment and it seems to be working well without freezing. It just writes the data to the apache /var/www folder so I can access it via my web browser. I am worried about it burning out my SD card though. I tried to get it to save to USB key, but the script would lock up. I guess the USB key is too slow.
 
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
#!/usr/bin/perl -W -s

system("stty -F /dev/ttyUSB0 1200 cs8 raw");

open INFILE, "/dev/ttyUSB0"
   or die "\nCannot open /dev/ttyUSB0!\n";


@data = ();
$buf = "";
# $cnt = 0;
$started = 0;
sub processPacket($);
my $file = '/var/www/teddata/data.txt';
# put path to capture file in the line above

while (read(INFILE, $buf, 1)) {
  $d = ord($buf) ^ 0xff;
  if ($d == 0x55 && $started == 0) {
    $started = 1;
    $a = 0;
  }
  if ($started == 1) {
    $data[$a] = $d;
    $sum += $data[$a];
    # printf("0x%02X ", $data[$a]);
    $a++;
    if ($a >= 11) {
      $sum -= $data[9];
      $sum &= 0xff;
      if ($sum == 0) { processPacket($data); }
      $started=1;
      $a = 0;
    }
  }
}

  # Working sub process packet stuff
  sub processPacket($) {
  local($data) = @_;
  #  If the power reading is way off, uncomment the other power line
  $power = (($data[5]^0xff)<<8) + ($data[4]^0xff);
  $power = ($data[5]<<8) + $data[4];
  $voltage = ($data[8] << 8) | $data[7];
  $voltage = sprintf("%.3f",123.6 + ($voltage - 27620) / 85 * 0.38);
  $power = sprintf("%.3f",(1.19 + 0.84 * (($power - 288.0) / 204.0)));
  @tda = localtime(time);
  $td = ($tda[4]+1)."/$tda[3]/".(1900+$tda[5])." $tda[2]:$tda[1]:$tda[0]";
  open (MYFILE, ">>$file") or die "Can't write to file '$file' [$!]\n";
  print MYFILE "$td, $power, $voltage\n";
  print "$td, $power, $voltage\n";
  close (MYFILE);
  }
 
Haven't tried it yet.  That said my sprinkler software is using a ZIF PATA SSD card to USB and backing up every night to a USB SSD stick (Kingspec).
 
Its pretty quick.
 
Hello All,
 
Just wondering if anyone has successfully got a TED 1001 to post to PlotWatt? I just purchased one (my Fiance Baulked at the price of a TED 5000) and hope to post readings to that site.
 
I was wondering if I could somehow use the logic in this thread (i.e. from the various scripts people have devised) and basically use them in a new script which would execute the CURL commands listed here as part of their API:
 
https://plotwatt.com/docs/api
 
curl -X POST -d "<MyMeter#-Static>,1.5,1310172167,123,1.45,1310172227" http://<MyAPIKey-Static>:mad:plotwatt.com/api/v2/push_readings
 
In other words, if I could call this supposed new script file (that would essentially formulate the appropriate curl command as above to be used when executed) and then I could add it to my system as a cronjob. I have a PFSense router which is always on, so I figured that may be a good place to get everything up and running.
 
I'm not going to lie, unfortunately i'm not that great at scripting :) I was wondering if someone might have some suggestions on how I might go about doing this? Or, has anyone actually ever built such a setup for a TED 1001 > PlotWatt setup before and could point me in the right direction?
 
Thanks in advance
 
Its my understanding these scripts work on a TED connected via USB directly to the computer. 
 
How hard would it be to change the scripts to pull the data from the serial port of a WRT54G running DD-WRT, or adapt a Raspberry Pi to pull the data instead and upload it to a web server?
 
I'm a noob when it comes to anything to do with any language outside of MS Windows.
 
kwilcox said:
I have a circuit dedicated for TED components. It has a 20A X10 XPF noise filter right in the panel. A set of MTUs that monitor home utility usage connect to it there. From the panel the circuit runs to the computer room where the Footprints gateway resides. Then it goes into the attic where a second set of MTUs monitor our solar array.

I've not had an issue with X10, Insteon, or UPB with this isolation strategy.
 
That's basically what I did with my old TED to get it running. The filter is like a firewall, blocking the X-10s and noise from CLFs and Etc. From jamming the MTU transmissions.
My clean TED line runs up to the display (1001 RDU).
 
No collision Avoidance?
Maybe a little bit..
I have two heat pumps that I want to monitor..
Nowadays, my only problem is that I now have two TEDs on that same clean circuit. In the setup, Setup asked if there is another TED. I tell one unit, that it's got company.
But not the other, since that doesn't help matters.
They run fine, the MTUs taking turns, but once in a while there is come clock drift.?. And both RDUs suffer 100% signal loss.
I'll go downstairs, and the LED on the two MTUs are in sync.. :(  (Turn it off and on, and everything is fine for a few weeks).
 
I wonder if there is a way to couple the Xtal clocks between the MTUs to keep them synced up??
Is there a circuit diagram around somewhere?
 
Thanks,
Rich
 
I'm still running both of my RDUs on a clean (flitered) 120AC line. Every once in a while they lockup when their signals get synced up..
 
I'm still looking for a wiring diagram of the MTU, so I can hack the timing of the transmitters.
 
Back
Top