# HomePowerMonitor on an Arduino? First tests.

Using an Arduino for my Home Power Monitor (HPM) has many advantages. It is cheap, simple, small, and has a good user base behind it. But could it meet my requirements (more on these in a future post)? To find out, I started to prototype the software last night and time it with my scope. I was pleasantly surprised.First test I ran was to simple take an ADC reading as an integer and toggle an IO pin in a tight loop. I found I could perform 8,929 samples per second. I then tried to read the ADC into a double expecting a significant hit on performance. I did not, the samples per second was nearly identical.

So the next test was to see the hit that squaring a double would take on the speed. Again, no hit whatsoever. At this point I was beginning to think that since I was not using the results of the calculations that perhaps the compiler was optimizing them out. So I wrote the bulk of the power computation code. This meant for each loop reading two DAC channels; one for voltage and one for current. Then squaring the raw values and summing them in accumulators. These computations would support computing apparent power. For true power, I took the product of the raw voltage and current and accumulated a running sum. After N samples, I would divide the sums by N to get averages.

The results show that I can take 3,680 samples of V and I every second. At a 60Hz line frequency, that means I can over sample by about 60x.

Is a 60x over sample enough to compute a fairly accurate real power for simple resistive loads and if so, what about bizarre reactive loads? I think I can compute the accuracy loss of a resistive load. And I think I can model and numerically compute the accuracy of an arbitrary reactive load. But at only a 60x over sample a pathological reactive load will have a significant error. But do I have any such devices that might draw a spike of power in 60th of a power cycle (1/3,600th of a second)?

Perhaps it is now time to pop open the breaker box and sample the real signals I will be dealing with.

This entry was posted in Home Energy Monitor, Projects. Bookmark the permalink.