Home Energy Prototypes

Web Interface Version 1 with a Google look and feel

In my previous post I talked about my motivations for building a home energy monitoring system like lack of open data and expensive monthly plans. Today I'll share some of my prototypes and future plans.

Wireless Temperature Sensor

Wireless temperature sensor with attiny45

This wireless temperature sensor has Sparkfun's basic 315MHz wireless transmitter, an ATtiny45, LM335A temperature sensor and a 12mm battery holder. This device lasted a couple of weeks by disabling the brown out detector, enabling internal pull ups on all unused I/O and disabling all peripherals. It would periodically wake up and transmit the temperature to a hub with an ATtiny328.

Smart Meter Reader

Wireless Smart Meter reader with IR LED

I used a similar device to read my Smart Meter and wirelessly transmit my homes power usage. I used an IR detector from Sparkfun to read the IR signals from the meter, which outputs 1 pulse for every 1 watt-hour. Since my meter was outside I had to build and enclosure to keep the sunlight out. The newer Smart Meters apparently run a mesh network to report the homes power usage back to the power company, but the signals are encrypted. Still might be worth investigating because they appear to use Zigbee. I plan to try with my new Zigduino.

By separately turning appliances on and off and subtracting the before and after meter readings it is posible to get the power usage for each device. This is actually more accurate than current clamps because the smart meter is multiplying the actual voltage and current instead of the estimated voltage. For this reason current clamps can be inaccurate for inductive loads. Checkout the power factor wiki page for more info. 

Here are some example readings from my house.
    Fridge                    - 180W
    HDTV TV + cable box       - 130W
    Hot water heater          - 70W
    Hall way spot lights full - 220W
    Dryer                     - 5840W
    Large stove high          - 3000W
    Toaster oven              - 1000W
    Notebook charge           - 65W

Wireless Power Bar

220VAC @ 20A relay and current clamp

This was part of a wireless power bar, which is at the breadboard stage. This containes an ATmeaga168, Hope RFM12B wireless module, current clamp, 220 VAC relay,  which connected to a power bar. The web interface would display the power usage of the power bar and the state of the relay. In the web interface (2 images below) this appeared as a button labeled light 1.
At this point I started to transition to the Hope RF modules because they offered duplex communications in a small and cheap package for almost the same cost as the basic RF modules. They were also easier to get reliable communication working.

Wireless Thermostat

Wireless Thermostat with ATmega328
Blue thing is the temperature and humidity sensor

The wireless thermostat is probably the most important part of this build. It has one relay to control each part of the HVAC system: heating, AC and fan. Like the previous devices it has a Hope RF module for communication and an ATmega328 for control. I replaced the LM35 temperature sensor for a module with a digital interface and humidity sensor. The AVR runs a P controller to moderate the house temperature, but a more sophisticated control methods is definitely needed. In the future it should have safe guards to protect the HVAC from overwork especially when overshoot occurs. This current version works OK, but I am hesitant to continue testing on my house. The best solution would be to build a test chamber like the guys at Nest did.

Nest's thermostat test chamber
(via Wired article)

Wireless Hub and Garage Door Opener

Two devices, which I have no pictures for are the wireless hub and the garage door opener. The wireless hub contains an ATmega328, Hope RF module and a usb to serial converter. It's job was to act as a bridge between the physical devices and the computer. The garage door opener was a similar board  that used a reed switch to determine if the garage door was open and an IR led beam to detect if a car was in the garage.

Web Interface Version 1

Web Interface Version 1 with a Google look and feel

The initial version of my web interface was written in the Google Web Toolkit (GWT) as an experiment after I attended the Google IO conference. If you are not a fan of Javascript and want to get a dynamic web app working fast GWT may be a good choice. The difficulties appear when you need features GWT doesn't provide like a fancy JS plotting library. It is also complicated to setup your own server so you probably have to use App Engine. If you ever decide to move to a new platform you'll probably have to rewrite everything, which is what I ended up doing.

The chart is the same one used by Google Finance with a few limitations. The biggest being dynamically updating the chart without refresh. For example, sending 2 years of power data with thousands of points will either kill the browser or take forever to load. A better way would be to reduce the resolution and just get the big picture. It's posible to hack this together, but there is no API call to refresh the data as the user zooms in without reloading the widget, which produces and annoying flicker.

This version featured:
  • Electricity bill based on time of use price
  • Realtime cost per hour
  • Power and temperature history 
  • Thermostat controls (far right)
  • Power bar switch and power usage (button that says light)
  • Garage door controls and state info
  • Parking info

Version 2

For the next version I wanted to improve the web interface and provide granular power usage. 

Current Meter

To begin I created another board with a Hope RF module, an ATmega168 and this time added six 3.5mm jacks connected the the AVR's analog input. The current clamps are the same as before except some are rated for 100A and other 15A. I use the 100A for circuits with large appliances like the stove.

Power meter in a Sparkfun box

Wireless power meter with
6 current clamp

Current clamps installed in breaker panel

The current version of this board only supports 6 current clamps so I attached them to the most power hungry appliances: the stove, dryer, ground floor, top floor, fridge and AC.

Installation was fairly simple. Just switch off power coming from the mains. Remove a couple of screws to get the front panel off. Attach the clamps to one side of a wire and route the clamp wires through an existing hole in the case. Put the front panel back on and turn on the power.

Web Interface Version 2

To incorporate the new electronics I decided to move to Pyramid and Javascript. Pyramid is the new and improved Pylons project with a bunch of other combined technologies. It's a bare bones framework that allows you to drop in your own database, template system and UI libraries. Don't worry it still comes with useful things like user authentication, url traversal and more. If you want a more complete framework try Django or Ruby on Rails. That's probably why they call it "Rails".

For serial communication I'm using PySerial, which does the job well. To receive dynamic updates on the web page like the opening of a garage door I'm using SocketIO and Gevent. Gevent provides asynchronous functions, which wait on events in the physical world in this case. This way the server can do other things like take more requests. SocketIO provides socket like functionality to the web browser so when an event does occur on the server side the user can be notified immediately. I highly recommend this tutorial from Alexandre Bourget to learn how to build a website using these tools.

To reproduce Google's Finance chart I'm using an awesome JS plotting library called Flot. I adding controls for each plot, a plot overview with controls to zoom and server side code to reduce the data points for large ranges. This might be useful for others so I'll build a sample app and post on Github soon. Checkout the screen caps below.

Web Interface version 2 - breaker panel power historical plots

Web Interface version 2 - realtime power plots

Web interface version 2 - Temperature and humidity plots
(those large spikes are bad data)

Future Plans

The 3 things I would like to improve are the wireless modules, web interface and the hub.

  • Replace Hope RF modules with an ATmega128RFA1 with integrated Zigbee for more functionality and simplicity.
  • Add user accounts to the web interface and clean up the JS code.
  • Develop a hub to connect the devices to the internet. Working on a small Linux board based on the i.MX233.
  • Do another revision of the electronics and iron out the bugs

electronicshome automationsmart home
comments powered by Disqus

Creative Commons License
Nabil's blog by Nabil Tewolde is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.