As promised, here are the Eagle files and software for my Wireless Four Channel 'Honest' RMS Power monitor I mentioned in other postings. This monitor uses inexpensive clamp-on AC Current Probes (
http://www.ebay.com/itm/281272305250) to pick up the AC Current used on various branch circuits in my Home and Workshop.
I use the term 'Honest' RMS because it does perform a square root of the mean of sum of squared current readings (hence RMS) but has not been calibrated to a traceable standard and probably is off for some kinds of loads. I've spot tested with a number of loads and am satisfied that it meets my requirements (Water Heater, Well Pump, Air Compressor, Heat Pumps, Dust Collector, etc) but YMMV.
The probe has a sensitivity of 1V output for 30Amps of current in the monitored leg. Since I'm only interested in monitoring branches 20Amps or less, this is ideal as the Peak current, with 20Amp RMS load, would be slightly more than 28Amp (within the probes specification).
As you'll see in the circuit, I use an LM317 to produce a 2.00Volt reference. This reference is used for the AREF input on the Moteino, as well as provide the bias reference for each of the channels. Each channel has a 10K/10K divider to divide the reference down to half the AREF value, thereby biasing the analog inputs at the midway point, yielding an ADC value of 512 with no current (or offset error). The range was chosen so the full scale current of 30A provides a full scale digital reading of 1023 or 0, depending on polarity. The probes are DC isolated with 100uF caps.
In the code, you'll see that I use Glenn Sweeney's code to set the ADC to operate with continuous sampling on an interrupt driven basis. This not only frees the processor to do other things (rather than wasting time waiting for the ADC conversion to complete) like manage the Moteino radio, to take a random example and, running in continuous sampling mode, also means that every sample takes exactly the same amount of time, providing the best accuracy of the integrated signal.
Each channel is sampled in turn and, with four channels, sampling over a 10 60Hz cycle interval, yields approximately 400 samples per channel per interval. The sample is converted to floating point to improve dynamic range with acceptable precision. Each sample is then squared and summed (sum of squares) and the number of samples tracked. At the end of the interval, the sum is divided by the number of samples (the mean) and the square root is taken (Root Mean Square). These are then accumulated over a ten minute period and then reported over the Moteino network as total AmpSeconds (AKA coulombs) accumulated in the ten minute window. These samples are saved on my Home Server and used in a variety of ways to monitor power usage.
Note a couple of things:
1. The sample code doesn't have the radio code because we all do it differently and, if you can't figure that out, learn that first.
2. The monitor measures AC Current only. To convert to KWHr you need to know the voltage of the corresponding circuit. This info is kept in my device database as a constant for each channel (I don't monitor as our voltage is constant enough so that results are WAQL without measuring).
3. The circuit uses very large through-hole pads for the components. This is because I used this design to test CNC Routing of PCB. It worked well, primarily because it's a simple circuit built around the Moteino module.
4. I used a TO220 version of the LM317 because that's what I have on hand. You could easily use a TO92 or SMD version as there is very little power dissipated in the regulator.
5. The design MAY work for 50Hz systems if the intervals are changed, but has not been tested at this frequency.
I think that's it and probably all the forum SW will let me say anyway. Ask questions, I'm happy to answer. Code and Eagle files attached. Photos in a trailing posting because they're too big to add to this one...
Tom