element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Members
    Members
    • Achievement Levels
    • Benefits of Membership
    • Feedback and Support
    • Members Area
    • Personal Blogs
    • What's New on element14
  • Learn
    Learn
    • eBooks
    • Learning Center
    • Learning Groups
    • STEM Academy
    • Webinars, Training and Events
  • Technologies
    Technologies
    • 3D Printing
    • Experts & Guidance
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Arduino Projects
    • Design Challenges
    • element14 presents
    • Project14
    • Project Groups
    • Raspberry Pi Projects
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Or 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
Featured Articles
Announcing Pi
Technical Specifications
Raspberry Pi FAQs
Win a Pi
GPIO Pinout
Raspberry Pi Wishlist
Comparison Chart
Quiz
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 3920 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…
Parents
  • Former Member
    Former Member over 10 years ago

    I've been trying to configure the transmitter radios with a sparkfun USB Xbee shield, but they never seem to come out of sleep mode and have to be reset. Can configuration only be done with the Adafruit shields?

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

    FYI, I found out the hard way that you DO need the adafruit xBee shield for programing.

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

    Hi Kai, sorry for not responding earlier as I was traveling.  Thanks for the feedback on the SparkFun shield.  I think the SparkFun XBee Explorer would be comparable to the Adafruit XBee adapter.

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

    Hi Kai, sorry for not responding earlier as I was traveling.  Thanks for the feedback on the SparkFun shield.  I think the SparkFun XBee Explorer would be comparable to the Adafruit XBee adapter.

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

    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 one transmitter? I'm trying to get three going at once, but am having a hard time figuring out what needs to be altered in the wattcher_cosm.py file. I can get the 9 data feeds going, but they're all reporting the same set of data from T1. I know I'm receiving all 3 sets of data correctly as they are being printed out with the appropriate ID's. Do I need to alter something in the eeml file?

     

    EDIT: Just needed to use the sensorhistory.sensornum class.

     

    if (sensorhistory.sensornum==1):

                pac.update(eeml.Data(0,

                                     avgwatt,

                                     minValue=0,

                                     maxValue=None,

                                     unit=eeml.Unit(name='watt',

                                                    type='derivedSI',

                                                    symbol='W',

                                                   )

                                     )

                          )

                # total KWh

                pac.update(eeml.Data(1,

                                     kwhused,

                                     minValue=0,

                                     maxValue=None,

                                     unit=eeml.Unit(name='kilowatthour',

                                                          type='derivedSI',

                                                          symbol='KWh',

                                                   )

                                    )

                          )

     

     

                # Cost

                pac.update(eeml.Data(2,

                                     cost,

                                     minValue=0,

                                     maxValue=None,

                                     unit=eeml.Unit(name='cost',

                                                    type='contextDependentUnits',

                                                    symbol='$'

                                                    )

                                     )

                          )

     

     

    #------------------------------------------KaW2--------------------------------------------------------------------

            elif (sensorhistory.sensornum==2):

                pac.update(eeml.Data(3,

                                     avgwatt,

                                     minValue=0,

                                     maxValue=None,

                                     unit=eeml.Unit(name='watt',

                                                    type='derivedSI',

                                                    symbol='W',

                                                   )

                                     )

                          )

                # total KWh

                pac.update(eeml.Data(4,

                                     kwhused,

                                     minValue=0,

                                     maxValue=None,

                                     unit=eeml.Unit(name='kilowatthour',

                                                          type='derivedSI',

                                                          symbol='KWh',

                                                   )

                                    )

                          )

     

     

                # Cost

                pac.update(eeml.Data(5,

                                     cost,

                                     minValue=0,

                                     maxValue=None,

                                     unit=eeml.Unit(name='cost',

                                                    type='contextDependentUnits',

                                                    symbol='$'

                                                    )

                                     )

                          )

     

     

    #------------------------------------------KaW3--------------------------------------------------------------------

            elif (sensorhistory.sensornum==3):

                pac.update(eeml.Data(6,

                                     avgwatt,

                                     minValue=0,

                                     maxValue=None,

                                     unit=eeml.Unit(name='watt',

                                                    type='derivedSI',

                                                    symbol='W',

                                                   )

                                     )

                          )

                # total KWh

                pac.update(eeml.Data(7,

                                     kwhused,

                                     minValue=0,

                                     maxValue=None,

                                     unit=eeml.Unit(name='kilowatthour',

                                                          type='derivedSI',

                                                          symbol='KWh',

                                                   )

                                    )

                          )

     

     

                # Cost

                pac.update(eeml.Data(8,

                                     cost,

                                     minValue=0,

                                     maxValue=None,

                                     unit=eeml.Unit(name='cost',

                                                    type='contextDependentUnits',

                                                    symbol='$'

                                                    )

                                     )

                          )

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

    Excellent! Thanks for the tip.

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

    There's still something funny going on with the data/cosm feed though. The avgwatt value's make sense, but there is hardly any deviation between the kwhused values and none betwen cost for each sensor. Not sure what the deal is. I've been trying to work it out for a while.

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

    Hi - yeah I can see that looking at your cosm feed.  Could you post a link to your version of the code (for example you could create a GitHub Gist)

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

    Thanks for taking a look. Here's the Gist.

    • 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