element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Members
    Members
    • Benefits of Membership
    • Achievement Levels
    • Members Area
    • Personal Blogs
    • Feedback and Support
    • What's New on element14
  • Learn
    Learn
    • Learning Center
    • eBooks
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • Experts & Guidance
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Dev Tools
    • Manufacturers
    • Raspberry Pi
    • RoadTests & Reviews
    • Avnet Boards Community
    • Product Groups
  • Store
    Store
    • Visit Your Store
    • 'Choose another store...'
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
Raspberry Pi
  • Products
  • More
Raspberry Pi
Blog RaspiWatt: discover power consumption using a Kill-A-Watt & Pi
  • Blog
  • Forum
  • Documents
  • Events
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Raspberry Pi requires membership for participation - click to join
Blog Post Actions
  • Subscribe by email
  • More
  • Cancel
  • Share
  • Subscribe by email
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: fustini
  • Date Created: 5 Apr 2013 3:24 AM Date Created
  • Views 3365 views
  • Likes 2 likes
  • Comments 33 comments
Related
Recommended
  • rpiintermediate
  • hack
  • raspi
  • ladyada
  • raspberry_pi
  • rpi
  • adafruit

RaspiWatt: discover power consumption using a Kill-A-Watt & Pi

fustini
fustini
5 Apr 2013
imageWant to build this project?
View Parts

 

Say you want to know how much electricity an appliance like an air purifier is consuming?

image

You can hook it up to the nifty Kill-A-Watt power meter (aka KaW).  The KaW will keep track of and display the killowatt-hours, or kWh, used by the plugged in device.

imageimage

However, the total will be reset anytime the KaW is unplugged and loses power.  Limor Fried (aka ladyada) recognized this shortcoming and created the clever Tweet-A-Watt project back in 2009. She modded the KaW into a wireless data logger by soldering a XBee wireless module to the KaW's op-amp chip:

image

image

The XBee's built-in ADC reads the power sensor signals inside the KaW and transmits it to a receiver XBee module connected to a computer via USB.  This diagram by ladyada gives a good sense of the architecture:

image

(source: http://www.ladyada.net/make/tweetawatt/)

 

The Tweet-A-Watt (TaW) is an awesome project, but I felt it's requirement to have a computer receive the data was cumbersome and power hungry.  Thankfully, we now live in an world of powerful, tiny & cheap single board computers (SBCs) like the Raspberry Pi .  I decided to use the Pi in place of a traditional computer.  I also used the Adafruit LCD Pi Plate to display the power usage data. and the Adafruit Pi Box enclosure to protect the Pi (which has a convenient "convertible" mode to accommodate the LCD Pi Plate on top):

image

The receiver XBee module connects to the Pi via a FTDI USB-to-serial cable :

image

Ladyada used Google AppEngine for graphing the TaW data, but I decided to take advantage of the newer Cosm graphing service (formerly named Pachube).  Here is a screenshot of my RaspiWatt Cosm feed showing Watts, kWh, and USD$ (based on the cost of a kWh for my power company):

image

Here is the list of parts I used if you are interested in building your own "RaspiWatt":

 

SKU Qty NamePurpose

53W5739

1Adafruit Tweet-A-Watt starter pack Includes 2 XBee radio modules and adapter boards; components to mod the XBee transmitter; FTDI USB-to-serial cable

07P6545

1Kill-A-Watt P4400 power meter Power meter which the XBee transmitter taps into
44W34651Adafruit Pi Box enclosure Protects Pi and has 'convertible' mode to accommodate the LCD Pi Plate
52W90851Adafruit RGB LCD Pi Plate Displays current power usage; intend to use it's buttons to create simple UI

53W5726

1

Adafruit Stacking Header

to replace the header that comes with the above Plate, it allows the Cobbler to be used
44W34971

Adafruit Pi Cobbler

to connect additional sensors to log to Cosm like temperature, humidity, etc

56T0250

1Full-size breadboard to construct additional sensor circuits
43W53021Raspberry Pi Model B replaces the TaW "traditional" computer

 

You can Add to Cart on Newark element14 all of the above (excluding the Raspberry Pi Model B).

 

My Pi is currently running a Python program named wattcher_cosm.py which is based on ladyada's original TaW wattcher.py program.  bonnie555 has been a big help in developing it for the RaspiWatt project, and it incorporates code from Adafruit's Cosm tutorial and their LCD Pi Plate tutorial.  In future posts, I'll describe in more detail how I assembled the hardware and provide instructions for installing the software on the Pi.

 

Cheers,

Drew

http://twitter.com/pdp7

 

 

 

 

Product Name*DescriptionSupplier
Raspberry Pi Model B Raspberry Pi model BRaspberry Pi
Buy Now
Optical mouse Basic USB optical mouseIONE / Pro Signal
Buy Now
Raspberry Pi Power Supply 120-240v to 5V power supply with micro USB connectorRaspberry Pi
Buy Now
Keyboard Basic USB keyboardGear Head / A4 Tech
Buy Now
Pre-programmed 4GB SD card 4GB Class 4 SD card preloaded with Debian 6 LinuxSamsung
Buy Now
Adafruit Tweet-A-Watt starter pack Includes 2 XBee radio modules and adapter boards, components to mod the XBee transmitter and an FTDI USB-to-serial cableAdafruit
Buy Now
Kill-A-Watt P4400 power meter Power meter which the XBee transmitter taps intoP3 International
Buy Now
Adafruit Pi Box Enclosure Protects Pi and has 'convertible' mode to accommodate the LCD Pi PlateAdafruit
Buy Now
Adafruit RGB LCD Pi Plate Displays current power usage; Buttons can be used to create simple UIAdafruit
Buy Now
Adafruit Stacking Header Replaces the header that comes with the Pi Plate, and allows the Pi Cobbler to be usedAdafruit
Buy Now
Adafruit Pi Cobbler Allows for easy connection to the Pi's GPIO pinsAdafruit
Buy Now
Full-Size Breadboard Allows for easy construction of additional sensor circuitsTwin Industries
Buy Now

 

*Products and resources are listed to help members build their own Pi Projects. For substitutions of any parts, please login to post a question to the original author.

  • Sign in to reply

Top Comments

  • Former Member
    Former Member over 10 years ago in reply to Former Member +1
    FYI, I found out the hard way that you DO need the adafruit xBee shield for programing.
  • Former Member
    Former Member over 10 years ago in reply to fustini +1
    Me too. I was trying to avoid buying more than I needed, as I already had several SparkFun XBee Explorers. My guess is the FTDI vs USB cable. Have you or anyone else set up the COSM code for more than…
  • felixemman
    felixemman over 10 years ago +1
    Hye guys in my case the XBEE didn't work because it was drawing too much power from the KillAWatt and causing the screen to flicker and turn off. I created my own version of the Tweet A Watt using a Moteino…
  • ejsbrown
    ejsbrown over 6 years ago

    Drew -
    I know this post is a few years old but I am just getting into power sensing as a hobby. You mention future posts - did those ever happen or are these comments the rest of the detail I need? Thanks!

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • fustini
    fustini over 10 years ago in reply to chrisjx

    Thanks for sharing!

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • chrisjx
    chrisjx over 10 years ago

    Just wanted to add some of my notes and code to this subject.

     

    I started using wifi routers flashed with OpenWRT, hacked with an XBee radio, and running python scripts.  That was the upgrade from using a full PC with Adafruit's Tweet-a-watt approach.

     

    What I have running now is a raspberry pi with an xbee mounted on a GPIO card.  The code started with wattcher.py but has been extended to allow you to track any kind of data from an xbee radio.  I've got temp, light, gas, power sensors attached to xbees around my house; sending the data to xively/cosm, thingspaek, open.se, etc.  There are methods for sending the data to different data logger APIs.

     

    https://github.com/TinajaLabs/gateway_raspi/blob/master/allsensors.py

    (also see supporting files etc)

     

    Here are my rough notes on setting up the Raspi, the CISECO GPIO board, python libraries, starting the python script automatically, etc.

    http://tinajalabs.wordpress.com/2012/09/02/raspberry-pi-as-an-xbee-wireless-sensor-network-gateway/

     

    I plan to extend the code further so I can setup all the sensor definitions into an xml or json file (as opposed to the hard coded variables).

     

    Hope it helps or adds to our collective knowledge.

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • Former Member
    Former Member over 10 years ago in reply to Former Member

    Alright! It seems to finally be working. Thanks to Bonnie and Drew.

     

    If anyone is looking for it, the final gist is here.

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • Former Member
    Former Member over 10 years ago in reply to Former Member

    Two things to look at:

     

    Not sure if you copy and pasted the variable name, but there's a typo (should be wattsused not wattsuesed).

     

    Also, notice the "+=" operator from the original code changes to just "=". 

     

    += takes the variable on the left and increases it by the value on the right.  The original code totals the values across all sensors this way.

     

    In our modification, we aren't incrementing or adding all the values together, but creating a dictionary entry for each sensor and corresponding value.  Does that make sense?

     

    (The reason you're getting a KeyError is because you can't increment a value that doesn't exist yet).

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
>
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2023 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube