Using an Arduino to Track My Electricity Consumption Cost in Real-Time

This is a basic of exploration of how I can now monitor my home's electricity consumption cost in real-time. There are many solutions to this problem. Some are more complicated than others. I needed to create a solution that did not involve any manipulation of my electric panel simply because I know very little about electrical work and did not want to mess around with high power.
Ultimately I found Avatar-X's electric meter reader project. This is, in my opinion, the most elegant and  unobtrusive way of obtaining the information I needed. He was gracious enough to share his wonderful code that converts the data received from the Arduino into real-time costs. In fact, most of my code comes directly from him. I just tweaked it for my own needs. Thanks again Av!

Like Av's setup, my electric meter has an infrared LED that blinks each time a KW of electricity is used. I placed an infrared photoresisitor directly in front of this LED ready to detect each time it turned on. The Arduino board reads the resistance from the IR sensor and the determines the amount of time that has passed between flashes. This time differential allows me to determine how much electricity is being used at any point in time.

Physical Setup
In my case my meter is outside and exposed to the elements. My setup required that the phototransistor be well protected from the elements. In addition, i need it to be flexible enough so it could be displaced by the electric company's technician if it ever needed to be accessed. I have noticed that FPL still reads the meters manually. This person still walks from home to home and reads the values from the meter. My IR resistor needed to be easy to move so if it needed to be taken out of the way it could be put a side with no damage to itself or the meter. I decided to use PVC tubbing to protect the cables from the Arduino board processing to the IR photoresistor facing the meter.

(the pics below show the PVC tubbing i used and how they protect the cables that connect the IR resistor to the Arduino board. The IR resistor is on a 90 elbow and has been sealed with silicon to protect it from the weather.)
  


The Arduino connected to the IR photoresistor is stored in a box inside my garage where it is safe from the elements. While humidty is a factor in Florida, i think it is pretty well protected. The box has a rubber ring around its cover and the hole i made for the power and resistor cables is sealed with silicon.

Storing Data
A windows service running in my computer reads the data coming from the Xbee radio connected to it via USB. The service connects to the Xbee via a COM serial connection and just listens to the data coming in from that port. When data arrives it simply connects to my SQL server database and inserts a new record in a table. This table is what stores all data coming from the meter reader.

Displaying My Data
I use three different methods to display my current electricity cost:

Analog meter using a simple servo as needle controller
   
I have another Arduino board connected to my computer via its USB port. Eventually i am going to change this so this Arduino has its own Xbee radio and can receive the data directly from the Arduino in my garage, but for now i am just connecting to my PC. In this case, the same windows service i am using to listen to my Arduino reading the meter and storing the data in the SQL database is also sending the serial data commands to the analog meter Arduino to move the servo needle to the correct location. The pictures above show the meter i built. Hey... i never called myself a carpenter! :) i just drilled a hole through a piece of plywood, put the servo shaft through it and then connected the lever to act as its needle indicator. Then I drew a piece of paper to show the consumption taking place at that moment. When my microwave runs, the needle jumps all the way to yellow. When the AC and the microwave are on, the goes well into the red area.

A video of the analog meter at work...

Web Interface Flash Graph
Since all data is stored in a database table i can perform all types of calculations and comparisons to see when i use the most electricity and others. The graph below show about 8 days worth of data. Notice the spikes and valleys.The flash charts are being generated by Open Flash Chart. I will probably make this graph more interactive by allowing the user to select time spans to see data in more detail.

Android Phone App
I have an HTC MyTouch Android phone. I've been wanting to find a reason to build an app so i can learn to program it. This finally gave me a reason to start! Based on some example work i found online, i basically wrote an rss reader. This means obviously that I also had to write an rss provider too. So i made one following this very simple example.
The feed now shows me the latest data coming from the meter. I also plan to expand the app to give me usage graphs and other more useful data. Perhaps an alarm when consumption goes over certain threshold during certain times and days (Like when my wife and I are at work) and others. Lots of little ideas, just not enough time!


Hope you enjoy it! Again, thanks to Av and the other people who posted their content so me, and lots of other people can use it.

Comments

  1. Can you provide some more specific information about the wiring? Are you using a pull down resistor? If so, how many ohms?

    I've been able to get my circuit working using a remote control to test, however when hooking it up to the actual meter, it doesn't seem to work.

    Trying to troubleshoot the issue.

    ReplyDelete
  2. Hello Andres,

    Very nice project. Thanks for sharing it.

    When I came across this the other day, I ran out and purchased a photo-transistor from the same store you got yours from to see how it work. I'm having trouble stopping sun light from washing out the IR emitter on the face of my utility power meter. My meter sits in a very shaded area and it's been very overcast where I live. I've placed the photo-transistor inside a short piece of black tubing to try and minimize the impact of sunlight, without much success.

    Please share what techniques you deployed to stop sunlight from messing things up.

    Best regards,

    Forst

    ReplyDelete
  3. Hi Andres,

    Would request your help with regards to the tweak that you did in the Adruino code for xbee communication. I am trying to implement the similar example that you did , but without the analog display part . I am just trying to insert into a database. Can also help me understand how you have done the database insert part and reading data on com port.

    ReplyDelete
  4. Hi Andres, neat setup!
    Sorry I am super late to the party ... I hope you see this comment..
    Can I ask what brand of meter you have? From your pictures, it looks like it might be a GE i210 meter. I am having some success with detecting and doing the time/pulse math with IR LED pulses from a GE i210+ce meter; however, once in a while, I detect a super fast burst of pulses and can't be related to my power usage (i.e. usage spikes from 3 kW to 180,000 kW ... I don't have anything that high power in my house :) ) I imagine that they are part of a communications protocol which a handheld diagnostic tool would understand, but I'm more interested in being able to predict *when* those bursts will happen so I can ignore them. Any ideas / similar issues in your project?
    Thanks!

    ReplyDelete
  5. If you live in the main Houston area, there are over 60 different energy suppliers competing for your business. Your points and all information are very useful. I must admire it all .Electricity is a necessity, so whatever companies charge is what the population has to pay. Business owners are always looking for ways to expand profit margins. I add one site where you can compare electricity rates.
    Electricity Rates Houston

    ReplyDelete
  6. There many thing in this industry where do get the electric equipment smart dimmer for lighting control

    ReplyDelete

Post a Comment

Popular posts from this blog

Arduino-Based Laser Controlled Wireless Automatic Cat Food Dispenser