I am well on my way to building a DIY energy monitor with Arduino Nano as the computational device. I don’t pretend that this is will be a precision instrument. I present it here, in its incomplete form, to spark discussion about my hardware approach and some question about the algorithms I am using.
The main components are the Nano, the ZMPT101B transformer, and the DL-CT08CL5-20A/10mA current transformer. The power supply that supplies 5V for the Nano is connected directly to the mains. (not only are there ripple concerns, but safety and regulatory concerns, too). I estimate a DIY cost in the neighborhood of US$20-30.
I am designing for a maxium 260Vrms and 20Arms
I am using the 3.3V output of the Nano for the voltage reference for the DAC. I also use this for the bias circuits for the AC signal. This will be a source of error.
For the voltage my input resistance is 132kΩ (6x22k). My burden resistor for the voltage is 510Ω. I can’t find it now, but there was some discussion about making this value too large would result in distortion of the wave. My bias resistors are of equal value, 39KΩ. Theoretically, this will be 2.98Vp-p, which is within my reference voltage. My 'scope shows 0.44Vrms for a 118Vrms input which is pretty close to 0.45 predicted. The waveform is slightly flattened on the top. Is this distortion caused by the large burden resistor?
I have not connected the current transformer, I calculated a 100Ω burden resistor. I will mount this resistor to the CT to avoid most issues of the CT being disconnected while energized.
I use the 16bit timer1 to cause an interupt every 1/100th of 1/60th of a second. I take 100 10-bit samples over 1 cycle (a sample takes ~100 μseconds to acquire) Memory limitations prevent taking samples over more cycles. I take the average of the samples to get the DC component. The rms value is determined: sqrt(Σ((sample - DC)2) ) / samples). The rms value of the samples is multiplied by the factor that relates sample value to input voltage (Rin/Rout * Vref/(210 - 1). Actual was close to theoretical, which I attributed to resistor tolerance, though I suspect there are other lurking factors.
Here’s where I’d like some opinions. As noted, the Nano has some serious RAM limitations. Putting data into program space is slow and degrades the Nano.
I am thinking two possible algorithms. The first is to interleave the sample taking between voltage and current. Multiply adjacent values gets power and multiply that by the interval between samples to get energy. This would only be 50 samples though.
Or take a voltage measurement over 1 cycle then current over the next cycle and on the third cycle do the interleaving acquisition and to determine the relative voltage and current zero crossings to determine the phase angle.
I’ll probably try both, but I don’t like working independently so I seek your opinions.
My last challenge will be to send the data to my home automation program. There could be problems with insufficient memory, and using the timer and interupts. (I could offload this task to an ESP8266)
Thanks for being here!