Tags
ADC, anolog, arduino, BITS, digital, embedded, embedded programming, energy meter using arduino, iMeter, mini project
I am currently pursing MS Software Engineering in BITS through WILP via my current employer. As part of my first semester, I was enrolled into Embedded Systems course. The course was very well structured and special thanks to Mr MJ Shankar Raman professor, who provided an opportunity to explore Arduino board as part of mini project in Sem 1.
Wow… the experience was fantastic. I got to know.. how to program a micro controller and how to get things done in a hardware. It is like… binding programming world with real hardware world.
One of the main point which drawn me towards arduino is the vast resources for arduino board. You wont be let alone if you got arduino board. Getting started is damn easy. You will feel confident that you can do something with this board.
Since both [me and my partner Sankar :)] doesn’t know anything about embedded systems, I decided to start off with a starter Kit. Obviously it had all that you require to get started. Inorder to keep the project’s budget under our pockets, I had one point in mind. Do whatever which is possible with the available components. No extra sensor / components. My buddy supported my decision and gave me the full freedom to explore what I wanted to do. Thanks Sankar 😉
One advice which we got from our professor was, “Take a real world problem, which everyone of us face. time to time. Try to solve this problem using an embedded system”. This advice shucked me and all of my leisure time was dedicated to identify a real world problem and solving it by applying the RT logic.
Here my manager (Raja) gave us a hint 🙂 . He hinted that, if given a total power consumed by a house hold, we should be able to find the power consumption split ups among the electrical devices. This way, the consumer / user may become aware that, he / she is using too much power, thereby the thought of power conservation may crop in.
That’s the spark, we started our project. But all of a sudden, we can’t invent a complete device to give the split ups. Obvious choice to as Google Professor [only professor who is always ready 24/7 to answer any question you have in your mind… some time he is too fast that, he completes your question, even before you type 😉 ] . Google Professor did showed me some useful sites, where I learnt about how the unit of consumption is calibrated in electricity meters, how you can use arduino board along with current sensor and voltage divider.
We wanted to keep our project, very simple, yet powerful. So settled down with Kirchhoff’s Voltage Law (KVL).
KVL states that..
The total voltage around a closed loop must be zero
Or in other words, the input voltage can be expressed as a sum of voltage differences across different component, which forms a closed loop.
Or.. in other words…
In a circuit with components of known & unknown components [in our case this the load / electrical appliance whose power we are interested to calculate], if we know the input load and voltage of known components, then we can easily get the voltage of unknown component i.e load.
From then on, Ohm’s Law / Watt’s Law can be applied…
Ohm’s law states that…
Power consumed by any component is nothing but product of its Current consumed i.e Current passed and Resistance offered …
i.e P = V * I (or) I * I * R
Putting everything together, I arrived at the below circuit..
[ You can use the fritzing tool to neatly draw your circuits ]
Circuit Information
Basically it had 2 circuits. Measuring Ciruit which measures the current across a unknown load and alarm circuit, which alarm whenever the power consumption of the load, has exceeded the preset value. The alarm circuit consisted of piezzo buzzer and red led .
The measuring circuit is quite simple and completely based on KVL and Ohm’s law. Arduino board is capable of working upto 5V. Arduino’s ADC convertor, can measure 0 – 5V on a 0-1023 scale. i.e If ADC’s output is 1023, then input voltage is 5V. i.e For every increase of 0.00488V [4.8mV] , the precision of the ADC will increase by 1. If you ever wonder how 0.00488 came, it is due to this.. 5/1023.
So the minimum voltage difference between every ADC point is 4.8mV. We know current is nothing but Voltage divider by Resistance. So if we place 4.8 ohm resistor, then what ever the value read by the ADC can be directly interpreted as mA [milli amps]. In short, we can measure the current passing in the circuit, in the form of voltage, since we already know what resistance the circuit has.. Pretty neat isn’t it. Browsing through arduino forums, gave me this thought. Actually you can get lot more details in Arduino forums. Thanks Aruduino users.
OK… coming back to the circuit, now we have to put 4.8 ohm resistor. But this not available in market. The least value which we could find is 5.6 ohms. If I place 5.6 ohm in place of 4.8 ohms, then instead of interpreting every unit of ADC as 1mA, I should interpreting as 0.85mA. This I can correct by presetting 0.15mA in my calculation to adjust my final result or simply live with the best possible approximation. I kind of did both 😉
So now.. we have a mechanism to sense what is the actual current going through the circuit with a known resistance R1. Let the unknown resistance or load be R2. So by KVL, V1 of R1 and V2 of R2 together be equal to input voltage Vin. So by measuring the voltage V2 and by measuring the current passing though the circuit using R1, we can get the power drawn by R2. Just keep on accumulating it to get the power in kWH. That’s the overall idea.
Some pics of the circuit…
Also added support to dynamically view the power consumption in a LCD and here is the sample..
[Thanks to Jeya who came forward to do the soldering 🙂 and Sankar who sponsored the soldering iron and other related stuffs 😉 . Team work helps :)]
Arduino has a wonderful serial monitor, which aids for live debugging as follows.
I had a wonderful semester full of learnings. It kick started my burning desire to write this blog and now I am proud be a student again, trying and experimenting new things, without the fear of getting failed. 🙂
I had not posted the source code, as it is very much available as part of arduino examples and forums. This project is not something special w.r.t to real time projects. It is a simple project without any hifi sensors. We just wanted to learn how to use Arduino and embedded systems. Though these projects are already available in markets, one satisfying fact is that, we did these things on our own. If anybody wants to take a look at our code [OfCourse we had implemented some calculations on our own 😉 ], do leave a comment below and I will get back to you..
Once again.. thanks for stopping @ my blog and sparing your time. I will keep blogging more about my future experiments with arduino. Stay Tuned.
Happy Coding 🙂
Posted by kspviswa | Filed under Arduino, Uncategorized