Techlab power usage to Facebook

This project was thought up as way to keep an eye of my power usage and let the world know when I am working.

The system uses the following

Setup

  1. Connect Wattsup Pro to whatever equpment you want to monitor
  2. Connect the supplied USB cable to your PC
  3. Setup new account
    1. Gmail
    2. Posterous
      • Configure account with new Gmail account
      • Configure Autopost feature to update Profile
        • Facebook
        • Twitter
        • Etc.
  4. Install Wattsup Linux Utility
  5. Write Perl/Shell Scripts to do the following
    1. Poll Wattsup via the USB Port to test
    2. Email results to post@posterous.com
  6. Configure Crontab Job to run scripts every day at noon

 

Scripts

:::::::::::::: historylog.sh ::::::::::::::

#!/bin/sh cat
‘/home/vitech/logs/currentusage.txt’ >> /home/vitech/logs/usage.txt

 

:::::::::::::: watts2fb.sh ::::::::::::::

#!/bin/sh

/home/vitech/scripts/watts2fb.pl > /home/vitech/logs/snapshottusage.txt

/home/vitech/scripts/smtp-cli –verbose –from=XXX@gmail.com –to post@XX.posterous.com –data /home/vitech/logs/snapshottusage.txt

 

:::::::::::::: wattslog.sh ::::::::::::::

#!/bin/sh date > /home/vitech/logs/currentusage.txt

/usr/local/bin/wattsup -c 1 ttyUSB0 watts >> /home/vitech/logs/currentusage.txt /home/vitech/scripts/historylog.sh

 

:::::::::::::: watts2fb.pl ::::::::::::::

#!/usr/bin/perl

open FILE, “/home/vitech/logs/currentusage.txt” or die $!;

$i=0;

while ()

{ @line = split (/ /,$_); chomp $line[5];

if ( $i == 0 )

{

$tstamp=$line[1]. ‘ ‘ . $line[2] . ‘ ‘. $line[5]. ‘ ‘ . $line[3] ;

}

if ( $i == 1 )

{

$watts = $line[0];

}

$i++;

}

$send = $tstamp . ‘ ‘ . $watts;

print “Subject : Watts used $wattsn”;

print “@line watts”;

 

 

Leave a Reply

Your email address will not be published. Required fields are marked *