Before you start
This tutorial is for any developer interested in working with energy data on the Web, with a particular focus on electricity data. You will use a number of technologies, including XML, Ruby, HTTP, Atom, Rails, Google Charts, and a little bit of Ajax thrown in for good measure.
Electricity is invisible. You use it all the time, but you rarely know how much you use. To understand your energy use (and hopefully reduce it), you need to re-engage with energy in a way which is currently impossible. Smart metering and real-time monitoring can help, by making it easy to see just how much energy you use. Forthcoming systems such as Google Powermeter and Microsoft® Hohm offer to make your energy usage available over the Web, but, in this tutorial, I will show you how to build a similar system from scratch using readily-accessible tools.
To effectively reduce energy usage, you need to understand how much you use, and yearly or monthly figures just aren't good enough. For proper understanding, you need instant feedback. With the AMEE API, you will build a system in this tutorial that lets you visualise your energy usage from minute to minute and see changes instantly, connecting you with your energy use like never before.
A number of devices on the market allow you to monitor your home energy usage. In this tutorial, you learn to hook up those devices to AMEE, a neutral energy management API, and then create a simple Ruby on Rails Web site to visualize the results, so you can see your carbon emissions from electricity in real time over the Web.
If you are unfamiliar with AMEE, I suggest you read my introductory article, "Introduction to AMEE," before you start this tutorial. See the link to this article in Resources.
The following tools are needed to follow along with this tutorial:
- A Linux™ PC; I assume you are working in a Linux environment, though most things should be easily adaptable to other platforms.
- Ruby 1.8.6 or greater. Most modern UNIX®-based operating systems will have this installed already. Windows® users can download a simple installer. See Resources for a link to the download site.
- Rubygems 1.3.1 or greater. Rubygems is a package management system for Ruby code (or "gems"). Once you have Rubygems installed, you will need to add GitHub to your sources list as shown in Listing 1.
You will also need the rb232 gem for accessing serial ports from Ruby. Note that this is
currently only available on Linux platforms—Mac and Windows versions are in the pipeline, however. For the display side of things, you will also need the rails gem installed. See Resources for a link to the download site for Rubygems.
Listing 1. Installing required Ruby gems
sudo gem sources -a http://gems.github.com sudo gem install Floppy-rb232 rails