

The problem with all of these is that you are trying to hit a ‘moving target’. Even with a 1ms sample time you are only measuring at 20 points in a cycle and, by definition, each sample is going to different and you can’t guarantee that you will hit the same points in the cycle every time – if you miss the peak your results will go haywire.
Full wave rectification of the output with a smoothing capacitor would be best because you would be measuring a true DC signal (but impossible due to the voltage drop over the rectifier) so the LTC1966 should give you the best results – adding the op-amp would just give further inaccuracy.
Your issues are why I ended up using the PZEM-004 which, over 2 years, has resulted in a 13kWh reading error between it and my electricity meter over just under 6000kWh.
Regards
Phil K
Sent from Mail for Windows 10
From: FransOv
Sent: 16 May 2021 15:28
To: TasmotaUsers
Subject: Power measurement with SCT-013
Over the past few months, I've tested mains power measurement with the SCT-013 current transformers in Tasmota. The tests have been hampered by the inaccuracy of the esp8266 and esp32 ADC inaccuracies. I used the esp32 as I needed two adc's.
I would like to share the results of these experiments and if you can agree with my findings, I could perhaps submit a request to implement the changes I made.
I've tried simple circuits like this:
and circuits with true RMS LTC1966 based modules like this one:
In both cases the results were far from satisfactory, especially at low power levels. Even giving the output of the LTC1966 module a voltage offset with an opamp did not help much. The result was a significant signal at zero input and strongly fluctuating output at all input levels.
As adding hardware did not noticeably improve the situation, probably even introducing extra noise, I returned to the simple schema with only the voltage divider and the capacitor and the ADC__CT_POWER module of Tasmota.
The Tasmota xsns_02_analog.ino module reads the power level every second by reading the analog value 32 times with a 1 ms interval and measuring the peak-to-peak voltage by subtracting the minimal value obtained from the maximum value. From this peak to peak value the current is calculated by means of the parameters given in AdcParamx.
I made some changes to the xsns_02_analog module to improve stability and accuracy:
Using these changes and an ADCParam value of AdcParam1 7,0,1000,0.23. I get fairly consistent results. It took a lot of time, including waiting for the LTC1966 modules to arrive from China, learning how to make a voltage adder with an opamp, soldering 4 variants of the boards and checking those boards for shortcuts and bad joins.
There probably is a good hardware solution to this problem, using a better quality external adc instead of the esp's adc, but I'm more at ease with my programming pencil then with the soldering gun. Programming pencil because when I started with computers, we had to write our programs with a pencil on 80 column sheets of paper that were then transcribed to a bunch of punched cards that you read into a computer. Mostly at night because the computer was used for production purposes in the daytime. I'm that old.
--
You received this message because you are subscribed to the Google Groups "TasmotaUsers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sonoffusers...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/sonoffusers/cb05ed05-7977-46aa-ae3f-90b2e483b7f0n%40googlegroups.com.