Meet the WattMote (Moteino based Tweet-A-Watt)

Python graph showing a cycle on my refrigerator (spikes are fridge light when door is opened)I assembled my Moteino circuit inside the KillAWatt. Everything fits very nicely and the LED blinks every ~2 seconds, and data finds its way to my RaspberryPi where EmonCMS records and graphs it nicely. At the last minute I found a leftover TMP36 analog temperature sensor that I had around, and thought – why not add it to the Moteino and report temperature along with power readings?

WARNING: If you attempt this project, make sure you never work on your KillAWatt while it is plugged in!  It is a shock hazard and you should never connect anything to it (including an oscilloscope that is not galvanically isolated from mains). You should never try to connect the Moteino/circuit to your computer to read serial from it while inside the KAW!  I mean this, the KAW might not work at all, or you will cause some damage to your tools or yourself!

I feared the TMP36 sensor alone would draw too much power (even an extra constant 2mA is too much for my KAW!). But it turns out it’s a very low power sensor (just 0.05mA). Since Adafruit has a very nice demo and code for TMP36, I won’t replicate the details here, you can check them out at Adafruit’s learning system.

Now I’m getting temperature, voltage and current waveform readings from my KAW. Sweet! Some assembly photos:

For a first run, I let my WattMote report my refrigerator power overnight. The KAW was reading 1.19kWh when I checked the next day, in EmonCMS it was showing 1.18kWh, I think I’m happy with this accuracy:


Here is the schematic of a WattMote node:

How does it all work?

The receiving end of the WattMote network is a Moteino that you can attach to a regular computer (boring…) or to a RaspberryPi (oh yeah). In my case I’m using a RaspberryPi with a python script that runs as a long running process (that lives after logoff). The script posts the incoming data to the EMONCMS instance running on the Pi. See details at their site on how to install EMONCMS.

The python script has a bunch of options which you can learn about by invoking the help command (python -h). You will need to either edit the script with your default settings or provide them through the command line. For the script to run properly you will need to tell it what to do and what not, and supply information such as the EMOCMS apiKey. Since not all KillAWatts are the same, you may tweak the incoming voltage/current data by altering these 2 parameters in the file:

CURRENTNORM = 15.8 # conversion to amperes from ADC
VOLTAGENORM = 0.94 # multiply each volt sample by this

On the RaspberryPi, you will connect the receiver (gateway) Moteino using 4 pins:

  • Pin2(5V)                    to Moteino-VIN
  • Pin6(GROUND)        to Moteino-GND
  • Pin8(UART_TXD)     to Moteino-RX
  • Pin10(UART_RXD)   to Moteino-TX.


Then, if you haven’t done this yet, you will need to free your serial port. The serial port by default is used by a getty process which allows you to log into your RPi using the hardware serial interface (kinda cool). To disable that run these commands:

  • Make backup first, then edit the original cmdline.txt file and remove parameters that contain “ttyAMA0”:
    sudo cp /boot/cmdline.txt /boot/cmdline_backup.txt
    sudo nano /boot/cmdline.txt
  • Then comment out the line that spawns a getty on ttyAMA0:
    sudo nano /etc/inittab
    #2:23:respawn:/sbin/getty -L ttyAMA0 115200 vt100
  • Restart the Pi
    RESTART – sudo shutdown –r now
  •  To test the ttyAMA0 serial port, install minicom and run it. You should see the raw data coming from the WattMote(s):
    Sudo apt-get install minicom
    minicom -b 115200 -o -D /dev/
  • At this point you should be able to start the script. To start it in long running process mode just add a ampersand at the end of the command.
    python &
  • To later kill this script you can use “ps aux” to find the script’s ID, then kill it:
    ps aux | grep WattMote    (or just ps aux to list all processes)
    pi   24036  2.0  3.1  11200  5892 ?   S    16:34   0:08 python
    pi@raspberrypi ~ $ sudo kill 24036

See my GitHub WattMote repository on how to setup the Moteinos inside your KillAWatts as transmitting WattMotes, and how to flash your central receiving Moteino.

Some/all parts are now available in the LowPowerLab store.

UPDATE: See Mike T‘s fix video where he shows how to add more stability to the KAW when the mains voltage sags below 120V:

19 thoughts on “Meet the WattMote (Moteino based Tweet-A-Watt)

  1. Pingback: Meet the WattMote (Moteino based Tweet-A-Watt)#piday #raspberrypi @Raspberry_Pi « adafruit industries blog

  2. … and I’m liking the idea to use a Moteino with the Pi. I was planning to use an RFM12B module directly for my Pi based central receiver and web server. But having an intelligent receiver running a sketch makes a lot of sense, versus making the Pi deal with RFM12B and the various nodes…

  3. Felix,

    Do you offer “kits” allowing someone to order all the little parts posted projects?

    I already have a Kill-A-Watt and would like to copy your project. I’d like to order parts for your other projects as well.


    • Ryan, good idea. I will look into putting together a kit-of-parts for this project.
      It would probably include just the discrete parts (resistors, cap, diode, LED), since the users can buy Moteinos separately with their options (depending if they already have a receiver or not).

  4. Hi
    Really like the solution and the logging ability, But I’m european based
    and would like to be able to deploy on a 220-240 volt. Do you know if the
    Kill a watt device is available for non us/110 voltage. Beest regards Sc

    • A basic search reveals other simiar devices for EU but I don’t think the KillAWatt is available. As long as the device uses an opamp similar to the one in the KillAWatt (for sampling A/V) you should be able to replicate the solution.

      • Hi,
        live in Austria (->230V) and I just openend my Voltcraft Energy Check 3000 Wattmeter ( about 20Euros) and it looks like it uses the same chips as the Kill-a Watts. Even the layout of the parts is very similar. Unfortunately the labeling is unreadable. I’m pretty sure it’s a LM 2909 in the small version. Good luck!

  5. Hi, I just started looking into microcontrollers so my knowledge is very limited. I am currently working on a project that requires controlling a relay and I was wondering if the Moteino is able to receive the signal from the Raspberry Pi to control the relay ?

    • Yes, you most likely will need a transistor to drive the relay, because of the limited current the Arduino/Moteino pins can supply.

      • Great!, so is there a limit of how many moteinos can the receiver/sender communicate with ? does the script need to be loaded to the Raspberry pi or to the moteino and what would be the code that enables communication between the receiver and sender ? Sorry for asking so many questions. Thanks

        • There is no limit per se, but the more RF traffic you have the more collisions you have. Also there’s a theoretical limit for how much traffic you can have in the unlicensed radio bands (I don’t have numbers).
          Having said that, if 1 Moteino transmits every 2 or 5 or 10 seconds for a few milliseconds that will be well within the limits and allow for a lot more Moteinos to talk to the main Moteino. Moteinos are transceivers, they can act as a sender or as a receiver. Python scripts run on the Pi. The code on the receiver Moteino is what receives the sender messages and passes it along to the Python script through the serial interface of the Pi. Read the article more carefully for the details on how to get it working.

  6. I love this project, but I am having some trouble getting it to work. When I connect the VCC and the GND to the Moteino from the Kill-A-Watt, the KAW shows the voltage increasing from 122 v to 150 volts and then the screen fades. Any suggestions. I have de-soldier the other two wires to ensure they aren’t the problem. It works fine without the load connected to the KAW.

    • Are you connecting the internals after plugging in the KAW? I hope not 🙂
      If you use the same components I did (or perhaps tweaked for your own KAW) and you have a regular KAW then you should see a blank screen for a few few seconds and then the LED should start blinking and the screen should come on. I tested many caps until I found that 330uF works well. What you describe is the typical problem that KAWs will render when you connect a load greater than the tiny KAW supply can handle, will destabilize the screen, and cause the KAW to stop working.

  7. Hi.. Thanks for the feedback. Should there be enough power to run the Moteino continuously? (I didn’t yet install the LED or the temp sensor and I wasn’t yet using the RFM). Any idea why the voltage is increasing even when I have the serial cable connected?

    • Make sure you are not connecting anything else to your KAW while it is plugged in. It is a shock hazard. That can easily explain why you see the weirdness. The RFM should have enough juice to power the Moteino continuously IF you are doing the exact same thing I did.

  8. Hey Felix! I have been having trouble replicating this as my KAW screen just fades down once I plug in the circuit. I even trimmed down the code to only use the onboard LED every 10 seconds for a blink, and I’m using a 1000uF capacitor and the signals aren’t connected.

    The capacitor only reads 2.6V after over a minute. If I don’t connect to moteino, the KAW vcc/gnd connection is 5.01V.

    • The bigger cap you connect the more current it will suck when you turn it on. That’s why the choice has to be wise, I used 330uF. You could use and RC circuit instead to slow down the charging of the cap but you will have to experiment for the value. Not all KAWs are made equal, older ones seem to have a stronger supply, supporting ladyada’s implementation with Xbee and much bigger cap.

Comments are closed.