Robert, thanks for the reply. I left some of the seemingly important details out to keep the initial post brief. To answer your questions:
How are you getting analogue values into your Raspberry Pi?
I’m using an ADS1115 I2C ADC to get the analog input into my Pi. The ADC has an input voltage limitation of 3.3V, so my reference voltage is 3.3 / 2.
This is a great point and something I had not thought about yet. In my testing environment, I’m using an electric space heater, so I suppose the AC waveform is as close to a sine wave as it could possibly get. Does the RMS calculation method account for non-sinusoidal waveform help?
This is one of the possibilities I’ve thought of this morning after revisiting my setup. I don’t have any guarantees - I’m simply taking 120 samples in just under 2 seconds and hoping that one of them is the peak of the wave. While it’s pretty close, it’s most likely not exact. My research has led me to the idea of using a peak detector, and measuring the voltage from it instead of directly from the CT sensor. If I go this route, I’ll need a transistor gate to open and close a path to ground to “reset” the capacitor in the peak detector back to the reference voltage (and I’d also need to account for the voltage drop across the diode).
Sorry about that - I’m using the YHDC SCT-013-000 100A CT sensor. There is some uncertainty about the # of turns in the sensor. The Amazon product page shows 1800:1, but the rating on the sensor (100A : 50 mA) suggests it’s actually 2000:1, which agrees with the documentation on the OpenEnergyMonitor tutorial. I used a turn ratio of 1800:1 in my calculation for the burden resistor so that could be a source of issue too. I’m using a burden resistor value of 20 Ohms.
I’ve made a slight change in how I’m calculating power. If you do check my work, don’t use the process in the bullet points in the original post. The process I’m using now is much more accurate for my space heater, which is:
- Take 120 readings from the CT sensor (< 2 seconds)
- Take a live measurement of the reference voltage (about 1.6578V)
- Get the max value from the 120 CT readings
- Find the difference between max CT and reference. With a 700W load, the CT sensor reads about 1.7124272 V. So, the difference is 1.7124272 - 1.6578 = ~ 0.0546272 V
- The difference is essentially a fraction of the maximum rating of the 100A CT sensor, so the measured current is 100A * 0.0546272 = ~ 5.462 A.
- I multiple the calculated current by a constant 120V to get power. 5.462 * 120 = 655W.
I think my burden resistor value might be off by a couple Ohms because of the confusion over the turn ratio. The randomness of the 120 samples I’m taking is the next likely probability IMO, so if recalculating and changing the value of the burden resistor doesn’t help, I’ll implement the peak detector circuit next.
As for the RMS calculations, I don’t know enough about the RMS theory to understand the impact it would have on the value. I can implement the calculations summarized in the “Arduino Maths” AC Power Theory review if that is recommended.