IBM DeveloperWorks articles
Posted by james on October 28th, 2009Over the summer, I was asked to write an article for the IBM DeveloperWorks site about energy monitoring and so on. Eventually, that turned into a series of articles centered around AMEE and how you can track energy consumption and calculate carbon emissions with it.
So, now that they're all published, here's a bit of a linkdump to the various articles and other things that came out of them.
- Introduction to AMEE
- This is a technical introduction to the AMEE platform, how it works, and what you can do with it. It covers things like signing up, creating profiles, storing data, and getting results. It was also adapted into a screencast for the AMEE developer site.
- Calculate your computer's carbon footprint using AMEE
- This one is an introduction to the wide variety of ways in which you can track energy data using AMEE, using the monitoring of computer energy use as a case study. It also shows some code examples for the AMEE ruby gem.
- Monitor home energy with AMEE
- This is my favourite of the three - a long tutorial, with lots of code, which shows a complete implementation of an online energy-monitoring system, using a CurrentCost display, AMEE, and a little Rails code. This uses a lot of the open source software I've been writing over the last year, which regular readers will have seen in previous posts, but it's really nice to tie it all together and tell the world how it works!
- James Smith on embedding environmental intelligence
- Scott Laningham was nice enough to interview me for the DeveloperWorks podcast when the first article went out, so if you want to hear me blathering on about it in person, you can do so!
Reboot Britain
Posted by james on July 8th, 2009I was lucky enough to be invited to talk at the Reboot Britain conference on Monday. It was a fascinating day, with lots of inspiring moments. It left me with a feeling that we can make the world a better place if we all get out there and make things. It's something I already believed, but it's great to have a recharge every now and again.
My session was on hacking energy data, kind of a Homecamp intro for the uninitiated. My slides are up on Slideshare, and embedded here for your viewing pleasure. Hopefully at some point I'll get to re-record the audio and add it in.
Publishing CurrentCost data to the world
Posted by james on March 28th, 2009A while ago, I started hacking around with a CurrentCost real-time energy monitor. This is a very nice little device that measures your electricity use, but more importantly has a serial output on the bottom so you can get data out of it.
Well, eventually I decided that while being able to get data off the meter was nice, it would be better if I could publish it somewhere. So, I wrote a program in Ruby to do exactly that. It reads data from the meter, and sticks it on the web. I'll go into a bit more detail in a minute, but first, you can download it (and get the source code) from github.
The program operates as a system daemon, which runs in the background on your Linux box (Mac should work as well) and uploads to various places. Adding new publishers is dead easy, so if you want to publish your data somewhere else, you can easily add it.
The Carbon Diet
First up, my own site, The Carbon Diet. This uploads your daily usage history from the meter into your carbon diet account so that you don't have to take so many meter readings to get an accurate graph. This is still pretty experimental and needs more work, but it's pretty useful already. You can see how it looks on my profile.
AMEE
Next, what I think of as the important one. AMEE, if you're not aware, AMEE is a neutral aggregation platform for sharing energy data and carbon calculations (disclaimer: I work for them these days). Think OpenID for your energy identity. Anyway, we have a nice "smart meter" demo which uses my currentcost app as the data source. Every minute, it uploads into an AMEE profile, and then another app makes a nice graph of the CO2 produced. In theory, the Carbon Diet could pull that data from AMEE instead of me publishing it directly, but that's still to come.
Pachube
Another energy data sharing service is Pachube (pronounced "patch bay"). As far as I can tell, this is more geared at art and design than rigorous data, but it's fun to play with. They've done a bunch of stuff with the CurrentCost, and now my app joins the throng. My pachube feed updates every 6 seconds - every time the meter sends data out.
Finally, what would be the point of a web energy publisher if it couldn't tweet? If you really want to, you can see my minute-by-minute energy usage on Twitter by visiting @james_energy.
CurrentCost data live on Pachube
Posted by james on August 29th, 2008So, the other day I got a nice little tray icon working for my CurrentCost power monitor. That's great, but data is only really gets fun when it's mashable, so the next step was to get it online somehow.
Pachube is a site which aggregates data feeds from real-world (and virtual-world) devices, shows them on a map, makes graphs, things like that, so it seemed like a good first attempt at putting my power data online. My first thought was to get my app to post data at regular intervals to the service, but unfortunately Pachube doesn't work like that. Instead, it acts more like a news reader, not a publishing platform - Google Reader instead of Blogger, if that makes sense. So, I had to publish my feed live on the web and point Pachube at the URL.
First step: EEML. This is an XML-based format which Pachube reads which can contain not only multiple data feeds, but tags and other metadata. So (as seems to be the fashion), I wrapped it up in a Ruby gem, available from GitHub as ever. The gem simply provides utility classes to build an EEML feed and convert it to the XML-based format for delivery over the web.
Then, the final step was to publish the data on the web. For that, we need a web server. However, having a full web server for just one feed seemed overkill, and I didn't want to publish to yet another intermediate server, so we need to serve the data directly. Ruby to the rescue once again. WEBrick is a simple web server which is part of the core Ruby libraries. You create a server, write simple servlet classes, and mount them at particular locations. For instance:
# Create WEBrick server s = WEBrick::HTTPServer.new( :Port => 50000 ) # A simple "hello world" servlet class HelloServlet < WEBrick::HTTPServlet::AbstractServlet def do_GET(request, response) response.status = 200 response['Content-Type'] = "text/xml" response.body = "hello world" end end s.mount("/", HelloServlet)
Now, http://localhost:50000/ will say "hello world". From here it's a simple modification to publish the EEML feed. EEML-Ruby includes a simple EEML server script as an example. So, after building this into the tray app, now whenever my CurrentCost is connected and the app is running, it serves up EEML data to the web. You can see the data feed (fairly intermittent, as obviously the meter isn't always connected to my PC at the moment) live on Pachube.
Some successful CurrentCost hacking
Posted by james on August 22nd, 2008After a bit of work, I've finally got my CurrentCost meter working in Ruby, and I now have a power monitor sitting in my system tray! There were a few stages involved...
Serial comms: The ruby-serialport library that already existed for Ruby was no good to me. Firstly, it didn't seem to be in a working state, but more importantly, the license it is under (GPL) is no good to me. So, I had to write my own. I've created a nice simple serial library (including a gem) for Ruby called RB232, which is available on GitHub. It only supports reading at the moment, and only works on Linux systems, but it's a start. Next!
Reading CurrentCost data: Once RB232 was in place, this was pretty easy. Just create a couple of classes to wrap up the process of getting data from the meter, and away you go. Easy. Also released as a Ruby gem on Github.
User interface: Last step was to make a simple user interface for the meter, which you can see in the picture above. It's a simple tray icon that changes colour based on power usage. It's based heavily on another very useful tool called cctrayrb, so many thanks to Daniel Parnell for doing the heavy GUI lifting there. The app is included as part of the currentcost-ruby gem mentioned above.
Anyway, it's all freely available, so if you have a CurrentCost meter and a serial cable for it, you can grab the code and get going. Enjoy :)