Tweet-a-watt – How to make a twittering power meter… using arduino




Tweet-a-watt – How to make a twittering power meter…

This project documents my adventures in learning how to wire up my home for wireless power monitoring. I live in a rented apartment so I don’t have hacking-access to a meter or breaker panel. Since I’m still very interested in measuring my power usage on a long term basis, I built wireless outlet reporters. Building your own power monitor isn’t too tough and can save money but I’m not a fan of sticking my fingers into 120V power. Instead, I’ll used the existing Kill-a-watt power monitor, which works great and is available at my local hardware store.

My plan is to have each room connected to a 6-outlet power strip which powers all the devices in that room (each kill-a-watt can measure up to 15A, or about 1800W, which is plenty!). That way I can track room-by-room usage, for example “kitchen”, “bedroom”, “workbench”, and “office”.

Each wireless outlet/receiver can be built for ~$55 with a few easily-available electronic parts and light soldering, no microcontroller programming or high voltage engineering is necessary!

You can see my setup including graphs and reports at http://twitter.com/tweetawatt

If you’d like to build one for yourself

1. Buy a kit: get all the parts you need, there’s a starter kit at the adafruit webshop
2. Make: turn each Kill-a-Watt into a wireless power level transmitter
3. Software: Download & run it on your computer to get data and save it to a file and/or publish it
Tweet-a-watt - How to make a twittering power meter...




If you want to know how it was made, check out:

1. Listen: write simple software for my computer (or Arduino, etc) to listen for signal and compute the current power usage
2. Store: Create a database backend that will store the power usage for long-term analysis at http://wattcher.appspot.com
3. View: Graph and understand trends in power usage

Check out the latest readings at http://wattcher.appspot.com

Step 1: Make it!

Before you start…

You should only attempt this project if you are comfortable and competent working with high voltage electricity, electronics and computers. Once the project is complete it is enclosed and there are no exposed high voltages. However, you must only work on the project when its not plugged in and never ever attempt to test, measure, open, or probe the circuitboards while they are attached to a wall socket. If something isn’t working: stop, remove it from the wall power, then open it up and examine. Yes it takes a few more minutes but it’s a lot safer!

Your safety is your own responsibility, including proper use of equipment and safety gear, and determining whether you have adequate skill and experience. Power tools, electricity, and other resources used for this projects are dangerous, unless used properly and with adequate precautions, including safety gear. Some illustrative photos do not depict safety precautions or equipment, in order to show the project steps more clearly. This projects is not intended for use by children.

Use of the instructions and suggestions is at your own risk. Adafruit Industries LLC, disclaims all responsibility for any resulting damage, injury, or expense. It is your responsibility to make sure that your activities comply with applicable laws.

OK, if you agree we can move on!

Make a tweet-a-watt

To make the tweet-a-watt setup, we will have to go through a few steps

1. Prepare by making sure we have everything we need and know the skills necessary to build the project
2. Build the receiver setup by soldering up one of the adapter kits
3. Configure the XBee wireless modems
4. Build the transmitter setup by modifying a Kill-a-Watt to transmit via the XBee
5. Run the software, which will retrieve data and save it to a file, upload it to a database and/or twitter

Step 2: Prep

Tutorials

Learn how to solder with tons of tutorials!
Don’t forget to learn how to use your multimeter too!

Tools

There are a few tools that are required for assembly. None of these tools are included. If you don’t have them, now would be a good time to borrow or purchase them. They are very very handy whenever assembling/fixing/modifying electronic devices! I provide links to buy them, but of course, you should get them wherever is most convenient/inexpensive. Many of these parts are available in a place like Radio Shack or other (higher quality) DIY electronics stores.

I recommend a “basic” electronics tool set for this kit, which I describe here.

Soldering iron. One with temperature control and a stand is best. A conical or small ‘screwdriver’ tip is good, almost all irons come with one of these.

A low quality (ahem, $10 model from radioshack) iron may cause more problems than its worth!

Do not use a “ColdHeat” soldering iron, they are not suitable for delicate electronics work and can damage the kit (see here)

Solder. Rosin core, 60/40. Good solder is a good thing. Bad solder leads to bridging and cold solder joints which can be tough to find. Dont buy a tiny amount, you’ll run out when you least expect it. A half pound spool is a minimum.

Multimeter/Oscilloscope. A meter is helpful to check voltages and continuity.

Flush/diagonal cutters. Essential for cutting leads close to the PCB.

Desoldering tool. If you are prone to incorrectly soldering parts.

Handy Hands’ with Magnifying Glass. Not absolutely necessary but will make things go much much faster.

Check out my recommended tools and where to buy.

Good light. More important than you think.

Step 3: Make the Receiver

Overview

We’ll start with the receiver hardware, that’s the thing that plugs into the computer and receives data from the wireless power plug. The receiver hardware does ‘double duty’, it also is used to update the XBee’s modems’ firmware (which, unfortunately, is necessary because they come from the factory with really old firmware) and configure the modems.

What you’ll need

The receiver is essentially, an XBee, with a USB connection to allow a computer to talk to it the XBee.

Name FTDI cable
Description A USB-to-serial converter. Plugs in neatly into the Adafruit XBee adapter to allow a computer to talk to the XBee.
Datasheet TTL-232R 3.3V or 5.0V
Distributor Mouser
Qty 1

Name Adafruit XBee Adapter kit
Description I’ll be using my own design for the XBee breakout/carrier board but you can use nearly any kind as long as you replicate any missing parts such as the3.3V supply and LEDs
You will have 2 adapter kits but you should only assemble one for this part! The other one needs different instructions so just hold off!
Datasheet Webpage
Distributor Adafruit
Qty 1

Name XBee module
Description We’ll be using the XBee “series 1” point-to-multipoint 802.15.4 modules with a chip antenna part # XB24-ACI-001. They’re inexpensive and work great. This project most likely won’t work with any other version of the XBee, and certainly not any of the ‘high power’ Pro types!
Datasheet
Distributor Adafruit
Qty 1

Solder the adapter together!

This step is pretty easy, just go over to the XBee adapter webpage and solder it together according to the instructions!

Remember: You will have 2 adapter kits but you should only solder one of them at this point! The other one needs different instructions so just hold off!

Connect to the XBee

Now its time to connect to the XBees

Find your FTDI cable – use either 3.3V or 5V. These cables have a USB to serial converter chip molded into them and are supported by every OS. Thus configuring or upgrading or connecting is really trivial. Simply plug the cable into the end of the module so that the black wire lines up with GND. There is a white outline showing where the cable connects.

You’ll need to figure out which serial port (COM) you are using. Plug in the FTDI cable, USB adapter, Arduino, etc. Under Windows, check the device manager, look for “USB Serial Port”

Digi/Maxstream wrote a little program to help configure XBees, its also the only way I know of to upgrade them to the latest firmware. Unfortunately it only runs on Windows. Download X-CTU from Digi and install it on your computer

After installing and starting the program, select the COM port (COM4 here) and baud rate (9600 is default). No flow control, 8N1. Make sure the connection box looks just like the image (other than the com port which may be different)

To verify, click Test / Query

Hopefully the test will succeed. If you are having problems: check that the XBee is powered, the green LED on the adapter board should be blinking, the right COM port & baud rate is selected, etc.

Now unplug the adapter from the FTDI cable, carefully replace the first XBee with the other one and make sure that one is talking fine too. Once you know both XBees are working with the adapter, its time to upgrade and configure them, the next step!

Step 4: Configure

Overview

OK so far you have assembled one of the XBee adapter boards and connected it to your computer using the FTDI cable. (The other adapter is for later so don’t do anything with it yet!) The XBees respond to the X-CTU software and are blinking just fine. Next we will update the firmware

Upgrading the firmware

There’s a good chance your XBees are not running the latest firmware & there’s a lot of features added, some of which we need to get this project running. So next up is upgrading!

Go to the Modem Configuration tab. This is where the modem is configured and updated

Click Download new versions… and select to download the latest firmwares from the Web

Once you have downloaded the newest firmware, its time to upgrade!

Click on Modem Parameters -> “Read” to read in the current version and settings

Now you will know for sure what function set, version and settings are stored in the modem

Select from the Version dropdown the latest version available

Check the Always update firmware checkbox

And click Write to initialize and program the new firmware in!

That’s it, now you have the most recent firmware for your modem. You should now uncheck the Always update firmware checkbox. If you have problems, like for example timing out or not being able to communicate, make sure the RTS pin is wired up correctly as this pin is necessary for upgrading. FTDI cables are already set up for this so you shouldn’t have a problem

Rinse & Repeat

Upgrade the firmware on both of the XBees so they are both up to date

At this point it might be wise to label the two XBees in a way that lets you tell them apart. You can use a sharpie, a sticker or similar to indicate which one is the receiver and which is the transmitter

Configure the transmitter XBee

Both XBee’s need to be upgraded with the latest firmware but only the transmitter (which is going to be put inside a Kill-a-Watt) needs to be configured. The configure process tells the XBee what pins we want to read the sensor data off of. It also tells the XBee how often to send us data, and how much.

Plug the transmitter XBee into the USB connection (put the receiver XBee away) and start up X-CTU or a Terminal program. Connect at 9600 baud, 8N1 parity.Then configure each one as follows:

1. Set the MY address (the identifier for the XBee) to 1 (increment this for each transmitter so you can tell them apart, we’ll assume you only have one for now)
2. Set the Sleep Mode SM to 4 (Cyclic sleep)
3. Set the Sleep Time ST to 3 (3 milliseconds after wakeup to go back to sleep)
4. Set the Sleep Period SP to C8 (0xC8 hexadecimal = 200 x 10 milliseconds = 2 seconds between transmits)
5. Set ADC 4 D4 to 2 (analog/digital sensor enable pin AD4)
6. Set ADC 0 D0 to 2 (analog/digital sensor enable pin AD0)
7. Set Samples to TX IT to 13 (0x13 = 19 A/D samples per packet)
8. Set Sample Rate IR to 1 (1 ms between A/D samples)

if you think there will be more XBee’s in the area that could conflict with your setup you may also want to

1. Set the PAN ID to a 4-digit hex number (its 3332 by default)

You can do this with X-CTU or with a terminal program such as hyperterm, minicom, zterm, etc. with the command string
ATMY=1,SM=4,ST=3,SP=C8,D4=2,D0=2,IT=13,IR=1
You’ll need to start by getting the modem’s attention by waiting 10 seconds, then typing in +++ quickly, then pausing for another 5 seconds. Then use AT to make sure its paying ATtention to your commands

Basically what this means is that we’ll have all the XBees on a single PAN network, each XBee will have a unique identifier, they’ll stay in sleep mode most of the time, then wake up every 2 seconds to take 19 samples from ADC 0 and 4, 1ms apart. If you’re having difficulty, make sure you upgraded the firmware!

Make sure to WRITE the configuration to the XBee’s permanent storage once you’ve done it. If you’re using X-CTU click the “Write” button in the top left. If you’re using a terminal, use the command ATWR !

Note that once the XBee is told to go into sleep mode, you’ll have to reset it to talk to it because otherwise it will not respond and X-CTU will complain. You can simply unplug the adapter from the FTDI cable to reset or touch a wire between the RST and GND pins on the bottom edge of the adapter.

Now that the transmitters are all setup with unique MY number ID’s, make sure that while they are powered from USB the green LED blinks once every 2 seconds (indicating wakeup and data transmit)

Configure the receiver XBee

Plug the receiver XBee into the USB connection (put the receiver XBee away) and start up X-CTU. If you set the PAN ID in the previous step, you will have to do the same here

  • Set the PAN ID to the same hex number as above

If you didn’t change the PAN above, then there’s nothing for you to do here, just skip this step

Next!

Now that the XBees are configured and ready, its time to go to the next step where we make the Kill-a-Watt hardware

Step 5: Solder the Transmitter – parts list

Before you start…

You should only attempt this project if you are comfortable and competent working with high voltage electricity, electronics and computers. Once the project is complete it is enclosed and there are no exposed high voltages. However, you must only work on the project when its not plugged in and never ever attempt to test, measure, open, or probe the circuitboards while they are attached to a wall socket. If something isn’t working: stop, remove it from the wall power, then open it up and examine. Yes it takes a few more minutes but it’s a lot safer!

Your safety is your own responsibility, including proper use of equipment and safety gear, and determining whether you have adequate skill and experience. Power tools, electricity, and other resources used for this projects are dangerous, unless used properly and with adequate precautions, including safety gear. Some illustrative photos do not depict safety precautions or equipment, in order to show the project steps more clearly. This projects is not intended for use by children.

Use of the instructions and suggestions is at your own risk. Adafruit Industries LLC, disclaims all responsibility for any resulting damage, injury, or expense. It is your responsibility to make sure that your activities comply with applicable laws.

OK, if you agree we can move on!

Transmitter partslist

For each outlet you want to monitor, you’ll need:

Name: Kill-a-Watt
Description: “Off the shelf” model P4400 power monitor
Datasheet: P3 Kill-a-watt
Distributor: Lots! Also check hardware/electronics stores
Qty: 1

Name: Adafruit XBee Adapter
Description: I’ll be using my own design for the XBee breakout/carrier board but you can use nearly any kind as long as you replicate any missing parts such as the3.3V supply and LEDs
Datasheet: Webpage
Distributor: Adafruit
Qty: 1

Name: XBee module
Description: We’ll be using the XBee “series 1” point-to-multipoint 802.15.4 modules with a chip antenna part # XB24-ACI-001. They’re inexpensive and work great. This project most likely won’t work with any other version of the XBee, and certainly not any of the ‘high power’ Pro types!
Distributor: Adafruit
Qty: 1

Name: D3
Description: 1N4001 diode. Any power diode should work fine. Heck, even a 1n4148 or 1n914 should be OK. But 1N4001 is suggested and is in the kit.
Datasheet: Generic 1N4001
Distributor: Digikey Mouser
Qty: 1

Name: D2
Description: Large diffused LED, for easy viewing. The kit comes with green.
Qty: 1

Name: C3
Description: 220uF, 4V or higher (photo shows 100uF)
Datasheet: Generic
Distributor: Digikey Mouser
Qty: 1

Name: C4
Description: 10,000uF capacitor (wow!) / 6.3V (photo shows a mere 2200uF) Try to get 16mm diameter, 25mm long
Datasheet: Generic
Distributor: Digikey [Mouser]
Qty: 1

Name: R4 R6
Description: 10K 1/4W 1% resistor (brown black black red gold) or 10K 1/4W 5% resistor (brown black orange gold). 1% is preferred but 5% is OK
Datasheet: Generic
Distributor: Mouser Digikey
Qty: 2

Name: R3 R5
Description: 4.7K 1/4W 1% resistor (yellow violet black brown gold) or 4.7K 1/4W 5% resistor (yellow violet red gold). 1% is preferred but 5% is OK.
Datasheet: Generic
Distributor: Mouser Digikey
Qty: 2

Name: Ribbon cable
Description: Ribbon cable, or other flexible wire, at least 6 conductors, about 6″ long
Datasheet: Generic Ribbon
Distributor: Digikey
Qty: 6″

Name: Heat shrink
Description: Heat shrink! A couple inches of 1/8″ and 1/16″ each
Datasheet: Generic

It will run you about $50-$60 for each outlet

Step 6: Transmitter Schematic

The XBee radio does all of the hard work, it listens on two analog input ports (AD0 and AD4) for voltage and current data. Then it transmits that information wirelessly to the host computer receiver XBee. There are a few we have to engineer around to make it Work:

1. We want to run the XBee off the Kill-a-Watt’s internal power supply. However its current limited and wont provide 50mA in a burst when the XBee transmits. We solve this by adding a simple ‘rechargeable battery’ in the form of a really large capacitor C4.

2. The Kill-a-Watt runs at 5V but XBees can only run at 3.3V so we have a voltage regulator IC1 and two capacitors two stabilize the 3.3V supply, C1 and C2.

3. The XBee will transmit every few seconds, even while the capacitor is charging. This means that it will keep draining the capacitor, resetting, and trying again, basically freaking out while the power supply is still building. We prevent this by adding another fairly big capacitor C3 on the reset line. This slows down the XBee, delaying the startup by a few seconds & keeps the XBee from starting up till we have solid power.

4. The XBee analog sensors run at 3.3V but the Kill-a-Watt sensors run at 5V. We use simple voltage dividers R3/R4 and R5/R6 to reduce the analog signal down to a reasonable level

Step 7: Assemble and create the transmitter – 1

Open up your kit and get out the parts for the transmitter. Remember that we’ll be using most of but not all of an XBee adapter kit. The two small LEDs, the 74HC125N chip, a 10K and 1K resistor are not used and you should put them aside for a future project so you don’t accidentally use them here.

Check to make sure you’ve got everything you need. The only thing not shown here is the XBee radio and Kill-a-Watt.

Place the PCB of adapter kit and get ready to solder by heating up your soldering iron, and preparing your hand tools

We’ll start by soldering in the 3.3V regulator, which is identical to the standard XBee Adapter kit you made in the receiver instructions. Don’t forget to check the polarity of C2 and that IC1 is in the right way. Then solder and clip the three components.

Now we will veer from the standard XBee adapter instructions and add a much larger LED on the ASC line so that we can easily see it blinking when its in the Kill-a-Watt. Make sure to watch for the LED polarity, because a backwards LED will make debugging very difficult. The longer lead goes in the + marked solder hole.

Give the LED about half an inch of space beyond the end of the PCB as shown. Also solder in the matching 1K resistor R2

Solder in the two 2mm 10pin female headers in the adapter kit. Be careful with the solder so that you don’t accidentally fill the female header. Use a sparing amount to make sure there’s a connection but its not overflowing

Step 8: Assemble and create the transmitter – 2

Now its time to prepare the wires we need for the next few stops. Use your diagonal cutters to notch off the brown, red, orange and yellow wires from the end of the rainbow ribbon cable in the kit.

Then tear off the four wires from the rest of the cable.

Do the same for the black and white wires and the single green wire. Then cut the green wire so its only about 1.5″ long. You should now have 3 strips of wire, one 6″ with 4 conductors, one 6″ with 2 conductors and one 1.5″ with 1 conductor

Use wirestrippers to strip the ends of the green wire, 1/4″ from the ends

Then tin the green wire by heating the ends of the wire and applying a little solder to bind together the stranded wire.

Use the green wire to create a jumper between the VREF pin, 7th from the top on the right and the VCC pin on the top left.

Double check to make sure you get this right! Then solder it in place. This will set the reference point of the analog converter to 3.3V

Go back to the 4-piece ribbon cable. Split the ends with the diagonal cutter, then strip and tin all 8 ends.

Put a 4.7K resistor in a vise or holder, then clip one end off and tin it just like the wires.

Cut a 1/2″ piece of 1/16″ heat shrink and slip it onto the yellow wire, making sure there’s clearance between the heatshrink and the end of the wire. Then solder the yellow wire to the 4.7k resistor.

Do the same for the orange wire and the other 4.7K resistor. Use a heat source (a heat gun or hair drier is perfect) to shrink the heatshrink over the soldered wire/resistor joint.Then bend the resistor 90degrees and clip the other end of the 4.7k resistors

Tweet-a-watt - How to make a twittering power meter...

Step 9: Assemble and create the transmitter – 3

Now we will build the voltage divider. Take the two 10K resistors and connect them as shown. One goes from AD0 and one from AD4. Both then connect to ground. Conveniently, the chip we are not using had grounded pins so we can ‘reuse’ those pins.

Now comes the tricky part. We want to connect the other end of the 4.7K resistor to the AD0 pin but the 10K resistor is already there. Use your soldering iron to melt a blob of solder onto the top of the 10K resistor and then piggyback the 4.7K resistor by soldering to the top of the 10K resistor.

Solder the orange wire to the AD0 pin, the yellow to the AD4

The other two wires are for carrying power. The red wire should be soldered to the +5V pin on the bottom of the adapter PCB. The brown wire to the GND pin.

We’re nearly done with the adapter soldering. Lastly is the 220uF reset capacitor. We’ll connect this to the RST pin, 5th from the top on the left. Make sure the long lead is connected to the RST pin and the shorter lead goes to the 4th pin of where the chip would go. Check the photo on the left to make sure you’ve got it in right.

The capacitor wont fit underneath the XBee module so give it some lead length so that the cylindrical bulk is next to the 3.3V regulator.

For reference, the images below show what the back should look like.

… and what it should look like with the XBee modem installed. Make sure the pins on the XBee line up with the header.

Step 10: Assemble and create the transmitter – 4

Now replace the PCB with the huge capacitor.

Clip the long leads down. You’ll need to use the “-” stripe to keep track of which pin is negative and which is positive.

Tin both leads with solder.

Solder the other end of the red ribbon wire (that goes to +5V on the XBee adapter) to the positive pin of the capacitor.

Then solder the brown wire (that goes to GND on the XBee adapter) to the negative pin.

Clip the cathode lead down of the 1N4001 diode, that’s the end with the white stripe. on it. Solder the diode so that the white-stripe side is connected to the positive pin of the big capacitor.

Take the black and white ribbon from earlier. Split, strip and tin the four ends. Cut a 1″ piece of 1/8″ heatshrink and slip it onto the white wire. Slip a 1/2″ piece of 1/16″ heat shrink onto the black wire.

Clip the other end of the diode (the side without a white stripe) and solder the white wire to it. Solder the black wire to the negative pin of the big capacitor.

Now shrink the heatshrink so that the capacitor leads and diode are covered.

All right, here is what you should have, an adapter with two sensor lines (orange and yellow) hanging off and two power lines (red and brown) that are connected to the big capacitor. Then there are two black&white wires connected to the capacitor, the white one through a diode.

 

For more detail: Tweet-a-watt – How to make a twittering power meter…




This Post / Project can also be found using search terms:

  • making mobile wattmeter project
Clip to Evernote

Leave a Comment

(Spamcheck Enabled)

Read previous post:
ZERO plus Prototype your IOT product in seconds
ZERO plus Prototype your IOT product in seconds

What we wish to achieve? Technology makes a better world ! We believe ZERO+ can turn great ideas into reality because with ZERO+, you can develop your smart device including hardware, cloud service and user application within just one hour. Traditionally, to develop your own smart device, you would need to go through hardware, embedded system, could service and mobile application development. This not only is time and resource consuming but also often needs a huge team to achieve. However, with zero+ now everything is changed. ZERO+ offers an all in one solution that includes hardware, embedded system, cloud service and user application. Now, you can truly bring your imagination to life within only one hour. ZERO+ is designed for both individuals and teams, so anyone from makers to startup companies can join in this family of hardware development. Any prototype made with ZERO+ can easily be manufactured in large scale. We are looking forward to seeing lives with all sorts of connected hardwares we develop because it is going to make the world a smarter, healthier and more convenient place. The only limit is...

Close
Scroll to top