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

Thanks guys!  Yup here using X-10/XTB stuff (XTB & XTB-IIR) also.  (a first gen Inteon PLM is online still). 
 
I wounder if the data out of the USB modification is inverted.
I know that the 1 bits in AA are 0 bits in 55 and the 0 bits in AA are 1 bits in 55.
Beyond that. My data conversion is so rusty I could not prove much more.
 
BLH said:
I wounder if the data out of the USB modification is inverted.
I know that the 1 bits in AA are 0 bits in 55 and the 0 bits in AA are 1 bits in 55.
Beyond that. My data conversion is so rusty I could not prove much more.
 
You might be on to something - the inversion holds true for the 2nd byte also. I get a constant 0xDF which when flipped becomes 0x20 which is a decimal 32. 32 is in fact my MTU's housecode. I'll see if flipping everything else works and report back. Thanks for the pointer!
 
Terry
 
The TDA5051A Home Automation Modem chips specifications sheet. Indicates it has a digital data output {Active Low}.
That could be the reason the data is inverted when connected directly to the FT232R USB Chips receive input.
 
BLH said:
I received mine today. From one of the many vendors that seem to have them.
My vendor said did not include Footprints or would it work with Footprints.
It came with an addendum for installation. The connection cable had a Red unused wire to be capped off and a TED Model: 5000 MTU sending unit.
The TED5000 does use the red wire.
 
 
Automate said:
Mine also came with a 5000 MTU.  It's interesting that the TED 5000 install guide http://files.theenergydetective.com/QuickStart-Installation%20v110510.pdf says to connect the black and red wires to the two phases so the gateway can be plugged into an outlet on either phase.
 
 
roussell said:
On a different note, I also received the TED 5000 MTU. If I can get the above mess figured out, I'll tie in the red wire to see if the returned info changes any...
 
For those that received the TED 5000 MTU, would you please post a link from whom you purchased it from? I'm assuming from your posts that you ordered the 1001 and received the 5000 version. I'd like to get one myself, but would prefer the 5000 version.
 
No I got a TED 1001 with a TED5000 MTU. All the photos on Ebay showed the TED1001 and what looks like the TED5000 MTU with wiring harnesses.
I have no data on if it was customized for use with a TED1001. As the addendum to install it. Said cap off and don't use the Red wire from the MTU. Just the Black to one breaker and White to Neutral.
 
Looking at the photos of the MTU for the TED1001 and the TED5000. The MTU's ID number is in a different format between the two versions.
 
I found an interesting thing. I had an older revision TED5000 Installation Manual and it shows the Red wire of the MTU connected to a breaker on the opposite phase as the Black wire is connected to.
 
I just downloaded the latest TED5000 Installation Manual and it also shows the Red wire capped off with the supplied red sleeve. Not connected to any breakers. It indicated that the signal strength of the power line signal is higher with the Red wire capped off.
 
Hooked up the TED1001 tonight.  Playing with the the following script:
 

#!/usr/bin/perl

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;
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); }
      $a = 0;
    }
  }
}

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 = 123.6 + ($voltage - 27620) / 85 * 0.4;
  $power = 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]";
  print "$td,$power,$voltage\n";
}

close INFILE;

 
Getting this:

 
0x55 0x0C 0xF4 0xE2 0xBD 0x02 0x4D 0x7F 0x6A 0xFB 0xD4 11/21/2013 0:10:21,2.89058823529412,121.92
0x55 0x0C 0xF5 0x50 0xC0 0x02 0x4D 0x7F 0x6A 0xFC 0x62 11/21/2013 0:10:22,2.90294117647059,121.92

0x00 0x55 0x0C 0xF6 0x56 0xBF 0x02 0x4D 0x7F 0x6A 0xFC 0x5C 0x00 0x55 0x0C 0xF7 0x48 0xC1 0x02 0x4D 0x7F 0x6A 0xFC 0x67 0x00 0x55 0x0C 0xF8 0xE2 0xBD 0x02 0x4D 0x7F 0x6A 0xFB 0xD0 0x00 0x00 0x00 0x00 0x55 0x0C 0xF9 0xB6 0xC3 0x02 0x4D 0x7F 0x6A 0xFB 0xF5 0x00 0x55 0x0C 0xFA 0x66 0xBD 0x02 0x4D 0x7F 0x6A 0xFC 0x4A 0x55 0x0C 0xFB 0xE2 0xBD 0x02 0x4D 0x7F 0x6A 0xFB 0xCD 0x00 0x00 0x55 0x0C 0xFC 0xBC 0xC2 0x02 0xF4 0x68 0x6A 0xFB 0x5D 0x55 0x0C 0xFD 0xD4 0xBF 0x02 0x4D 0x7F 0x6A 0xFB 0xD7 0x00 0x55 0x0C 0xFE 0x48 0xC1 0x02 0xF4 0x68 0x6A 0xFB 0xD0 0x00 0x00 0x00 0x55 0x0C 0xFF 0x5E 0xBE 0x02 0xF4 0x68 0x6A 0xFB 0xBC 0x00 0x00 0x55 0x0C 0x00 0x50 0xC0 0x02 0xF4 0x68 0x6A 0xFC 0xC7 0x00 0x00 0x55 0x0C 0x01 0xB6 0xC3 0x02 0xF4 0x68 0x6A 0xFC 0x5D 0x00 0x00 0x55 0x0C 0x12 0xCC 0xC0 0x02 0xF4 0x68 0x6A 0xFC 0x49 0x00 0x00 0x55 0x0C 0x13 0x56 0xBF 0x02 0xF4 0x68 0x6A 0xFC 0xBF 0x00 0x55 0x0C 0x04 0x56 0xBF 0x02 0x4D 0x7F 0x6A 0xFD 0x4E 0x00 0x55 0x0C 0x05 0x50 0xC0 0x02 0xF4 0x68 0x6A 0xFC 0xC2 0x00 0x00 0x00 0x55 0x0C 0x06 0xC4
 
and this:
 
 

Main::processPacket() called too early to check prototype at ./ted.pl line 26.
Name "main::cnt" used only once: possible typo at ./ted.pl line 10.
0x55 0x0C 0xD5 0xF6 0x99 0x02 0x09 0xEF 0x6A 0xFB 0xD7 11/21/2013 0:52:30,2.74235294117647,122.447058823529


 
 
BTW  - reading the reviews on the product yesterday; some folks were happy; and many were not. 
 
Its worth the $20 or so to purchase the discontinued product / modding it to output serial data. 
 
pete_c said:
Hooked up the TED1001 tonight.  Playing with the the following script:
and this:

Main::processPacket() called too early to check prototype at ./ted.pl line 26.
Name "main::cnt" used only once: possible typo at ./ted.pl line 10.
0x55 0x0C 0xD5 0xF6 0x99 0x02 0x09 0xEF 0x6A 0xFB 0xD7 11/21/2013 0:52:30,2.74235294117647,122.447058823529
 
Not sure i this is what you are asking for.
 
Short answer, remove cnt and move the sub processPacket() to the top of the file.
 
For a better description see http://www.perlmonks.org/?node_id=162876.
 
longer answer:
 
- remove or comment out the $cnt = 0; line
- add sub processPacket($); near the top of the file
- add a $ to the lower sub processPacket() { ( sub processPacket() { becomes sub processPacket($) { )
 
pete_c said:
Hooked up the TED1001 tonight.  Playing with the the following script:
 

#!/usr/bin/perl

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;
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); }
      $a = 0;
    }
  }
}

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 = 123.6 + ($voltage - 27620) / 85 * 0.4;
  $power = 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]";
  print "$td,$power,$voltage\n";
}

close INFILE;

 
Getting this:

 
 
and this:
 
 

Main::processPacket() called too early to check prototype at ./ted.pl line 26.
Name "main::cnt" used only once: possible typo at ./ted.pl line 10.
0x55 0x0C 0xD5 0xF6 0x99 0x02 0x09 0xEF 0x6A 0xFB 0xD7 11/21/2013 0:52:30,2.74235294117647,122.447058823529


 
 
Not sure i this is what you are asking for.
 
Short answer, remove cnt and move the sub processPacket() to the top of the file.
 
For a better description see http://www.perlmonks.org/?node_id=162876.
 
longer answer:
 
- remove or comment out the $cnt = 0; line
- add sub processPacket($); near the top of the file
- add a $ to the lower sub processPacket() { ( sub processPacket() { becomes sub processPacket($) { )
 
Thank-you LinuxHA.  Sort of works.  Still seeing one issue.
 
 

#!/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($);

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); }
      $a = 0;
    }
  }
}

  # sub processPacket() { ( sub processPacket() { becomes sub processPacket($}
  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 = 123.6 + ($voltage - 27620) / 85 * 0.4;
  $power = 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]";
  print "$td,$power,$voltage\n";
 
close INFILE;

root@ICS-ZM2:/usr/bin# ./ted.pl
Unquoted string "becomes" may clash with future reserved word at ./ted.pl line 35.
syntax error at ./ted.pl line 35, near "( sub processPacket() "
Prototype not terminated at ./ted.pl line 35.
root@ICS-ZM2:/usr/bin# ./ted.pl
Prototype mismatch: sub main::processPacket ($) vs () at ./ted.pl line 47.
0x55 0x0C 0xF3 0x54 0x02 0x03 0xCA 0x5C 0x69 0xFC 0xC4 11/21/2013 8:25:14,3.17470588235294,120.550588235294
0x55 0x0C 0xF4 0xC8 0x03 0x03 0x23 0x73 0x69 0xFC 0xDE 11/21/2013 8:25:15,3.17882352941176,120.658823529412
0x55 0x0C 0xF5 0xD0 0x02 0x03 0x23 0x73 0x69 0xFC 0xD6 11/21/2013 8:25:16,3.17470588235294,120.658823529412
0x55 0x0C 0xF6 0x36 0x06 0x03 0x23 0x73 0x69 0xFD 0x6B 11/21/2013 8:25:17,3.19117647058824,120.658823529412
0x55 0x0C 0xF7 0xDE 0x00 0x03 0x23 0x73 0x69 0xFC 0xC8 11/21/2013 8:25:18,3.16647058823529,120.658823529412
0x00 0x55 0x0C 0xF8 0x4C 0x03 0x03 0x23 0x73 0x69 0xFD 0x56 0x55 0x0C 0xF9 0x4C 0x03 0x03 0x23 0x73 0x69 0xFD 0x55 ^C
root@ICS-ZM2:/usr/bin# ./ted.pl
Unquoted string "becomes" may clash with future reserved word at ./ted.pl line 35.
syntax error at ./ted.pl line 35, near "( sub processPacket() "
Prototype not terminated at ./ted.pl line 35.
root@ICS-ZM2:/usr/bin# ./ted.pl - this is working except for the Prototype mismatch piece which is the line mentioned below.
Prototype mismatch: sub main::processPacket ($) vs () at ./ted.pl line 47.
0x55 0x0C 0x54 0x5A 0x01 0x03 0x23 0x73 0x69 0xFD 0xEE 11/21/2013 8:26:51,3.17058823529412,120.658823529412
0x55 0x0C 0x55 0xB8 0x05 0x03 0xCA 0x5C 0x69 0xFC 0xFB 11/21/2013 8:26:52,3.18705882352941,120.550588235294
0x55 0x0C 0x56 0xB2 0x06 0x03 0x71 0x46 0x69 0xFD 0x6E 11/21/2013 8:26:53,3.19117647058824,120.447058823529
0x55 0x0C 0x57 0xB8 0x05 0x03 0x71 0x46 0x69 0xFD 0x68 11/21/2013 8:26:54,3.18705882352941,120.447058823529
0x55 0x0C 0x58 0x18 0x0A 0x03 0x71 0x46 0x69 0xFE 0x02 11/21/2013 8:26:55,3.20764705882353,120.447058823529
0x55 0x0C 0x59 0xD0 0x02 0x03 0x71 0x46 0x69 0xFD 0x51 11/21/2013 8:26:56,3.17470588235294,120.447058823529
0x55 0x0C 0x5A 0xB8 0x05 0x03 0x71 0x46 0x69 0xFD 0x65 11/21/2013 8:26:57,3.18705882352941,120.447058823529
0x55 0x0C 0x5B 0x5A 0x01 0x03 0xCA 0x5C 0x69 0xFD 0x57 11/21/2013 8:26:58,3.17058823529412,120.550588235294
0x55 0x0C 0x5C 0x4C 0x03 0x03 0xCA 0x5C 0x69 0xFD 0x62 11/21/2013 8:26:59,3.17882352941176,120.550588235294
0x55 0x0C 0x5D 0x5A 0x01 0x03 0xCA 0x5C 0x69 0xFD 0x55 11/21/2013 8:27:0,3.17058823529412,120.550588235294
0x55 0x0C 0x5E 0xD6 0x01 0x03 0xCA 0x5C 0x69 0xFC 0xD8 11/21/2013 8:27:1,3.17058823529412,120.550588235294
^C
 
Its the syntax I used here: (which I know is wrong).
 
# sub processPacket() { ( sub processPacket() { becomes sub processPacket($}
 
Fixed.  Works great!  Thank you LinuxHA.
 
 

#!/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($);

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); }
      $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 = 123.6 + ($voltage - 27620) / 85 * 0.4;
  $power = 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]";
  print "$td,$power,$voltage\n";
  }
close INFILE;
root@ICS-ZM2:/usr/bin# ./ted.pl
0x55 0x0C 0x59 0x6A 0xFF 0x02 0x7B 0x89 0x69 0xFC 0x6E 11/21/2013 8:35:28,3.16235294117647,120.762352941176
0x55 0x0C 0x5A 0x78 0xFD 0x02 0x7B 0x89 0x69 0xFC 0x61 11/21/2013 8:35:29,3.15411764705882,120.762352941176
0x55 0x0C 0x5B 0x8E 0xFA 0x02 0x7B 0x89 0x69 0xFC 0x4D 11/21/2013 8:35:30,3.14176470588235,120.762352941176
0x55 0x0C 0x5C 0x78 0xFD 0x02 0x7B 0x89 0x69 0xFC 0x5F 11/21/2013 8:35:31,3.15411764705882,120.762352941176
0x55 0x0C 0x5D 0xF4 0xFD 0x02 0x7B 0x89 0x69 0xFB 0xE2 11/21/2013 8:35:32,3.15411764705882,120.762352941176
0x55 0x0C 0x5E 0xF4 0xFD 0x02 0x7B 0x89 0x69 0xFB 0xE1 11/21/2013 8:35:33,3.15411764705882,120.762352941176
0x55 0x0C 0x5F 0x88 0xFB 0x02 0x7B 0x89 0x69 0xFC 0x4E 11/21/2013 8:35:34,3.14588235294118,120.762352941176
0x55 0x0C 0x60 0x80 0xFC 0x02 0xD4 0x9F 0x69 0xFB 0xE5 11/21/2013 8:35:35,3.15,120.865882352941
^C
Well it worked a couple of times...something is throwing the script off now...
root@ICS-ZM2:/usr/bin# ./ted.pl
0x55 0x0C 0x20 0x6A 0xFF 0x02 0xD4 0x9F 0x69 0xFC 0x38 11/21/2013 8:38:47,3.16235294117647,120.865882352941
0x55 0x0C 0x21 0xFC 0xFC 0x02 0xD4 0x9F 0x69 0xFB 0xA8 11/21/2013 8:38:48,3.15,120.865882352941
0x55 0x0C 0x22 0xEE 0xFE 0x02 0xD4 0x9F 0x69 0xFB 0xB3 11/21/2013 8:38:49,3.15823529411765,120.865882352941
0x55 0x0C 0x23 0x88 0xFB 0x02 0xD4 0x9F 0x69 0xFC 0x1B 11/21/2013 8:38:50,3.14588235294118,120.865882352941
0x55 0x0C 0x24 0x62 0x00 0x03 0xD4 0x9F 0x69 0xFD 0x3A 11/21/2013 8:38:51,3.16647058823529,120.865882352941
0x00 0x55 0x0C 0x25 0xEE 0xFE 0x02 0xD4 0x9F 0x69 0xFB 0xB0 0x55 0x0C 0x26 0xB8 0x05 0x03 0xD4 0x9F 0x69 0xFC 0xDD 0x55 0x0C 0x27 0xEE 0xFE 0x02 0x7B 0x89 0x69 0xFC 0x1D 0x55 0x0C 0x28 0x72 0xFE 0x02 0x7B 0x89 0x69 0xFC 0x98 0x55 0x0C 0x29 0x78 0xFD 0x02 0x7B 0x89 0x69 0xFC 0x92 0x55 0x0C 0x2A 0x6A 0xFF 0x02 0x7B 0x89 0x69 0xFC 0x9D 0x55 0x0C 0x2B 0xFC 0xFC 0x02 0xD4 0x9F 0x69 0xFB 0x9E 0x55 0x0C 0x2C 0xE6 0xFF 0x02 0xD4 0x9F 0x69 0xFB 0xB0 0x55 0x0C 0x2D 0x80 0xFC 0x02 0x7B 0x89 0x69 0xFC 0x87 0x55 0x0C 0x2E 0x6A 0xFF 0x02 0x23 0x73 0x69 0xFD 0x07 0x55 0x0C 0x2F 0xE6 0xFF 0x02 0x7B 0x89 0x69 0xFC 0x1C 0x55 0x0C 0x30 0x04 0xFC 0x02 0x23 0x73 0x69 0xFD 0x6E 0x55 0x0C 0x31 0xFC 0xFC 0x02 0x23 0x73 0x69 0xFC 0x75 0x55 0x0C 0x32 0x0C 0xFB 0x02 0x23 0x73 0x69 0xFD 0x65 ^C
root@ICS-ZM2:/usr/bin# ./ted.pl
0x55 0x0C 0x39 0x88 0xFB 0x02 0x23 0x73 0x69 0xFC 0xE2 11/21/2013 8:39:12,3.14588235294118,120.658823529412
0x55 0x0C 0x3A 0x0C 0xFB 0x02 0xCA 0x5C 0x69 0xFC 0xCD 11/21/2013 8:39:13,3.14588235294118,120.550588235294
0x55 0x0C 0x3B 0x0C 0xFB 0x02 0x23 0x73 0x69 0xFD 0x5C 11/21/2013 8:39:14,3.14588235294118,120.658823529412
0x00 0x00 0x55 0x0C 0x3C 0x8E 0xFA 0x02 0x23 0x73 0x69 0xFC 0xDA 0x55 0x0C 0x3D 0x12 0xFA 0x02 0xCA 0x5C 0x69 0xFC 0xC5 0x55 0x0C 0x3E 0x80 0xFC 0x02 0x23 0x73 0x69 0xFC 0xE4 0x55 0x0C 0x3F 0xFC 0xFC 0x02 0x23 0x73 0x69 0xFC 0x67 0x55 0x0C 0x40 0x72 0xFE 0x02 0x7B 0x89 0x69 0xFC 0x80 ^C
root@ICS-ZM2:/usr/bin#
root@ICS-ZM2:/usr/bin# ./ted.pl
0x55 0x0C 0xEF 0x10 0xD9 0x02 0x7B 0x89 0x69 0xFC 0x58 11/21/2013 8:42:14,3.00588235294118,120.762352941176
0x00 0x00 0x55 0x0C 0xF0 0x02 0xDB 0x02 0x7B 0x89 0x69 0xFC 0x63 0x55 0x0C 0xF1 0xA4 0xD6 0x02 0x7B 0x89 0x69 0xFB 0xC5 0x55 0x0C 0xF2 0x0A 0xDA 0x02 0x23 0x73 0x69 0xFC 0xC8 0x00 0x55 0x0C 0xF3 0x0A 0xDA 0x02 0x7B 0x89 0x69 0xFC 0x59 0x55 0x1D 0xF4 0x0A 0xDA 0x02 0x7B 0x89 0x69 0xFC 0x58 0x55 0x0C 0xF5 0x86 0xDA 0x02 0x7B 0x89 0x69 0xFB 0xDB 0x55 0x0C 0xF6 0x28 0xD6 0x02 0x23 0x73 0x69 0xFC 0xAA 0x55 0x0C 0xF7 0x8E 0xD9 0x02 0x23 0x73 0x69 0xFC 0x40 0x55 0x0C 0xF8 0x9C 0xD7 0x02 0x23 0x73 0x69 0xFC 0x33 0x55 0x0C 0xF9 0x0A 0xDA 0x02 0x23 0x73 0x69 0xFC 0xC1 0x55 0x0C 0xFA 0x9C 0xD7 0x02 0x7B 0x89 0x69 0xFB 0xC3 0x55 0x0C 0xFB 0x02 0xDB 0x02 0x23 0x73 0x69 0xFC 0xC6 0x00 0x55 0x0C 0xFC 0x0A 0xDA 0x02 0x23 0x73 0x69 0xFC 0xBE 0x00 0x55 0x0C 0xFD 0x10 0xD9 0x02 0x23 0x73 0x69 0xFC 0xB8 0x00 0x55 0x0C 0xFE 0xFA 0xDB 0x02 0x23 0x73 0x69 0xFB 0xCB 0x55 0x0C 0xFF 0x02 0xDB 0x02 0x23 0x73 0x69 0xFC 0xC2 0x55 0x0C 0x00 0x86 0xDA 0x02 0x23 0x73 0x69 0xFD 0x3E ^C
 
 
pete_c said:
Fixed.  Works great!  Thank you LinuxHA.
 


Code:
#!/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($);

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("0xX ", $data[$a]);
    $a++;
    if ($a >= 11) {
      $sum -= $data[9];
      $sum &= 0xff;
      if ($sum == 0) { processPacket($data); }
      $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 = 123.6 + ($voltage - 27620) / 85 * 0.4;
  $power = 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]";
  print "$td,$power,$voltage\n";
  }
close INFILE;
Well it worked a couple of times...something is throwing the script off now...
Yup, but I haven't a clue as to what yet. It's not obvious. We see the hex print, which is followed by a $a++. There are more than 11 bytes there so that doesn't make sense.

You might consider adding

$started = 1;

after

if ($sum == 0) { processPacket($data); }

I don't think that will mess up the logic and it might help with a resync (though you could lose some 'packets' until it sync's back up).
 
Thank-you Neil!
 
Looks to be good now.  I let it run a while (well just a few seconds).
 
 

#!/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($);

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 = 123.6 + ($voltage - 27620) / 85 * 0.4;
  $power = 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]";
  print "$td,$power,$voltage\n";
  }
close INFILE;

 
root@ICS-ZM2:/usr/bin# ./ted.pl
0x55 0x0C 0x74 0x68 0x63 0x03 0x67 0x03 0x69 0xFD 0x8A 11/21/2013 17:32:6,3.57411764705882,120.131764705882
0x55 0x0C 0x75 0x86 0x5F 0x03 0xBF 0x19 0x69 0xFD 0x01 11/21/2013 17:32:7,3.55764705882353,120.235294117647
0x55 0x0C 0x76 0x60 0x64 0x03 0xBF 0x19 0x69 0xFD 0x21 11/21/2013 17:32:8,3.57823529411765,120.235294117647
0x55 0x0C 0x77 0x60 0x64 0x03 0x67 0x03 0x69 0xFD 0x8E 11/21/2013 17:32:9,3.57823529411765,120.131764705882
0x55 0x0C 0x78 0xDC 0x64 0x03 0x67 0x03 0x69 0xFD 0x11 11/21/2013 17:32:10,3.57823529411765,120.131764705882
0x55 0x0C 0x79 0xDC 0x64 0x03 0x67 0x03 0x69 0xFD 0x10 11/21/2013 17:32:11,3.57823529411765,120.131764705882
0x55 0x0C 0x7A 0xEC 0x62 0x03 0x67 0x03 0x69 0xFD 0x01 11/21/2013 17:32:12,3.57,120.131764705882
0x55 0x0C 0x7B 0xE4 0x63 0x03 0x67 0x03 0x69 0xFD 0x07 11/21/2013 17:32:13,3.57411764705882,120.131764705882
0x55 0x0C 0x7C 0xF2 0x61 0x03 0x67 0x03 0x69 0xFC 0xFA 11/21/2013 17:32:14,3.56588235294118,120.131764705882
0x55 0x0C 0x7D 0xDC 0x64 0x03 0x67 0x03 0x69 0xFD 0x0C 11/21/2013 17:32:15,3.57823529411765,120.131764705882
0x55 0x0C 0x7E 0xEC 0x62 0x03 0x0E 0xED 0x68 0xFC 0x6D 11/21/2013 17:32:16,3.57,120.028235294118
0x55 0x0C 0x7F 0xD4 0x65 0x03 0x67 0x03 0x69 0xFD 0x11 11/21/2013 17:32:17,3.58235294117647,120.131764705882
0x55 0x0C 0x80 0x76 0x61 0x03 0x0E 0xED 0x68 0xFC 0xE2 11/21/2013 17:32:18,3.56588235294118,120.028235294118
0x55 0x0C 0x81 0xE4 0x63 0x03 0x0E 0xED 0x68 0xFC 0x71 11/21/2013 17:32:19,3.57411764705882,120.028235294118
0x55 0x0C 0x82 0xEC 0x62 0x03 0x0E 0xED 0x68 0xFC 0x69 11/21/2013 17:32:20,3.57,120.028235294118
0x55 0x0C 0x83 0x68 0x63 0x03 0x0E 0xED 0x68 0xFC 0xEB 11/21/2013 17:32:21,3.57411764705882,120.028235294118
0x55 0x0C 0x84 0x60 0x64 0x03 0xB5 0xD6 0x68 0xFC 0x61 11/21/2013 17:32:22,3.57823529411765,119.92
0x55 0x0C 0x85 0x02 0x60 0x03 0x03 0xAA 0x68 0xFD 0xA0 11/21/2013 17:32:23,3.56176470588235,119.712941176471
0x55 0x0C 0x86 0x70 0x62 0x03 0x5C 0xC0 0x68 0xFC 0xC0 11/21/2013 17:32:24,3.57,119.816470588235
0x55 0x0C 0x87 0xFA 0x60 0x03 0xB5 0xD6 0x68 0xFB 0xC8 11/21/2013 17:32:25,3.56176470588235,119.92
0x55 0x0C 0x88 0x68 0x63 0x03 0xB5 0xD6 0x68 0xFC 0x56 11/21/2013 17:32:26,3.57411764705882,119.92
0x55 0x0C 0x89 0xFA 0x60 0x03 0xB5 0xD6 0x68 0xFB 0xC6 11/21/2013 17:32:27,3.56176470588235,119.92
0x55 0x0C 0x8A 0xF2 0x61 0x03 0xB5 0xD6 0x68 0xFB 0xCC 11/21/2013 17:32:28,3.56588235294118,119.92
0x55 0x0C 0x8B 0x8C 0x5E 0x03 0x0E 0xED 0x68 0xFC 0xC4 11/21/2013 17:32:29,3.55352941176471,120.028235294118
0x55 0x0C 0x8C 0x76 0x61 0x03 0xB5 0xD6 0x68 0xFC 0x46 11/21/2013 17:32:30,3.56588235294118,119.92
0x55 0x0C 0x8D 0x8C 0x5E 0x03 0xB5 0xD6 0x68 0xFC 0x32 11/21/2013 17:32:31,3.55352941176471,119.92
0x55 0x0C 0x8E 0xEC 0x62 0x03 0x0E 0xED 0x68 0xFC 0x5D 11/21/2013 17:32:32,3.57,120.028235294118
0x55 0x0C 0x8F 0x86 0x5F 0x03 0xB5 0xD6 0x68 0xFC 0x35 11/21/2013 17:32:33,3.55764705882353,119.92
0x55 0x0C 0x90 0x76 0x61 0x03 0x0E 0xED 0x68 0xFC 0xD2 11/21/2013 17:32:34,3.56588235294118,120.028235294118
0x55 0x0C 0x91 0xEC 0x62 0x03 0x0E 0xED 0x68 0xFC 0x5A 11/21/2013 17:32:35,3.57,120.028235294118
0x55 0x0C 0x92 0xFA 0x60 0x03 0x0E 0xED 0x68 0xFC 0x4D 11/21/2013 17:32:36,3.56176470588235,120.028235294118
0x05 0x04 0x93 0x00 0x63 0x03 ^C
root@ICS-ZM2:/usr/bin# ./ted.pl
 
Will let it run a bit (minutes/hours?).
 
Looks to be long and short values maybe?
0x55 0x0C 0x91 0xEC 0x62 0x03 0x0E 0xED 0x68 0xFC 0x5A 11/21/2013 17:32:35,3.57,120.028235294118
0x55 0x0C 0x92 0xFA 0x60 0x03 0x0E 0xED 0x68 0xFC 0x4D 11/21/2013 17:32:36,3.56176470588235,120.028235294118
 
Probably would work better rounding off the number to 2 decimal places.  Same probably for the voltage readings.
 
Back
Top