Thursday, January 14, 2010

Twitter update your energy usage using a TED 5000

The Energy Detective 5000 has an API that can be polled for data using this simple perl script that I wrote.

If you are running Debian Linux you will need to install a few dependencies:
sudo apt-get install libxml-simple-perl libwww-curl-perl

And you can automate the execution of this script with an hourly cron job:
Run: crontab -e
and then add this line (assuming you put my script in ~/bin/:
0 * * * * ~/bin/twitterpower.pl


#!/usr/bin/perl

# Written by Jason Garland @ http://blog.jasongarland.com/

my $twitter_user="jgarland79power";
my $twitter_password="super_secret_password";

my $ted_ip="192.168.3.132";

# use module
use XML::Simple;
#use Data::Dumper;
use WWW::Curl::Easy;

sub write_callback {
my ($chunk,$variable)=@_;
# store each chunk/line separately
# This should be faster than using $$varable .= $chunk;
push @{$variable}, $chunk;
return length($chunk);
}

my $curl = WWW::Curl::Easy->new();

my @body;
$curl->setopt(CURLOPT_WRITEFUNCTION, \&write_callback);
$curl->setopt(CURLOPT_FILE, \@body);
$curl->setopt(CURLOPT_URL, "http://$ted_ip/api/LiveData.xml");
$curl->perform;
my $body=join("",@body);

# create object
$xml = new XML::Simple;

# parse XML
$data = $xml->XMLin($body);

my $PowerTDY=$data->{Power}->{Total}->{PowerTDY};

$status="used $PowerTDY watt hours of #electricity since midnight today. Find out more here: http://a1.ly/7";

print $status,"\n";
$curl->setopt(CURLOPT_URL, "http://twitter.com/statuses/update.json" );
$curl->setopt(CURLOPT_POST, 1 );
$curl->setopt(CURLOPT_POSTFIELDS, "status=$status" );
$curl->setopt(CURLOPT_USERPWD, "$twitter_user:$twitter_password" );
$curl->perform;

Labels:

Friday, July 20, 2007

Use a GPS with your iPhone

Here is a little trick to allow you to use a GPS feed with Google Maps on your iPhone.

The Google Maps app on the iPhone is similar to the Google Maps for Mobile. A while back I discovered that you would input a URL for a KML feed into Google Maps mobile so when I got my iPhone I gave it a try on there too AND IT WORKED!

Simply type in the URL for a KML feed into the search box on the Google Maps app on your iPhone.

So how do we get our current GPS cords into the iPhone? You use a separate device like the Motorola i415 that you can pick up at Walmart for ~ $30 and load up the mologogo.com application on it. The phone can then transmit your coordinates to a web server where you can generate a KML feed for your iPhone.

You can find sample scripts on how to build the KML feed here: http://mologogo.wikispaces.com/

Here is the feed for mine: http://gps.jasongarland.com/earth1.kml

Type it into the search box on your iPhone and you will see my current location. (Assuming I have the Mologogo app running)

NO STALKERS PLEASE! This means don't attempt to go to any of the locations on this map to try and find me. If you want to talk to me you can send me a message on this blog.

Labels:

Monday, September 25, 2006

Bluetooth Western Electric 500 handset







  • Completed WE500 BT headset!
















  • Completed charging unit (AC/DC adaptor wired to RJ plug)















  • Pushbutton is wired to hangup/answer/on/off button (volume buttons are not connected)











  • Microphone connector
  • Charging connector is wired to the rj connector on the handset














  • My T-Mobile MDA and the completed handset















  • Dissassembly of WE500 handset














  • BT headset with board removed













  • Another picture of the inside of the bluetooth headset











  • Inside of bluetooth headset















  • Philips VOX120 bluetooth headset (CompUSA $30)
  • Western Electric 500 handset (Ebay $15)