Skip to main content

skip to main content

developerWorks  >  XML | Web development | Open source | Linux  >

Monitor home energy with AMEE

Create an energy monitor using XML, Ruby, Rails, and Ajax

developerWorks
Page 1 of 10 Go to the next page

Document options
PDF format - Fits A4 and Letter

PDF - Fits A4 and Letter
233 KB (24 pages)

Get Adobe® Reader®

Sample code


My developerWorks needs you!

Connect to your technical community


Rate this tutorial

Help us improve this content


Level: Intermediate

James Smith, Development Manager, AMEE

29 Sep 2009

Electricity is invisible. To understand how people use it, you need to make it visible. This tutorial will show you how easy it is to build a Web-based energy monitoring system yourself, using a Current Cost real-time energy monitor and AMEE, a neutral Web-based API for energy data, combined with some XML, Ruby, Rails, and Ajax.

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.

About this tutorial

Frequently used acronyms
  • Ajax: Asynchronous JavaScript + XML
  • AMEE: Avoiding Mass Extinctions Engine
  • API: Application program interface
  • HTML: Hypertext Markup Language
  • HTTP: Hypertext Transfer Protocol
  • MVC: Model-View-Controller
  • PC: Personal computer
  • REXML: Ruby Electric XML
  • UID: User identifier
  • URL: Uniform Resource Locator
  • USB: Universal Serial Bus
  • XML: Extensible Markup Language
  • YAML: YAML Ain't Markup Language

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.

Prerequisites

Join the green groups on My developerWorks

Discuss topics and share resources about energy, efficiency, and the environment on the GReen IT Report space and the Green computing group on My developerWorks.

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
    



Back to top



Page 1 of 10 Go to the next page