Hi Phil,
I always look for software solutions first before going the hardware way. Just because I’m more comfortable with software than with hardware.
The current transformers I use, SCT013-30A, deliver 1V at 30 Ampère. They do have a burden resistor built in, but no rectifier.
I agree that it would be better to rectify the voltage and than input it to the ADC. However, bridge rectifiers have a forward voltage drop of up to 0.6V which makes them not suitable in this case. I would have to amplify the AC voltage 10x then rectify it and after that drop it down to a level that the ADC can handle.
However your suggestion made me look further and I found this solution to rectify the AC with only a very small (0.03V) forward voltage drop. It comes from a publication at https://arxiv.org/vc/arxiv/papers/1205/1205.4604v1.pdf.

To view this discussion on the web, visit https://groups.google.com/d/msgid/sonoffusers/5fef4958-b951-4bf5-9b5c-2b9461c3e4dbn%40googlegroups.com.


Have you adjusted AdcParam 7?
7 = CT POWER parameter adjustments:
<param1> = ANALOG_CT_FLAGS (default 0 for a non-invasive current sensor). When value is >0 its sets the adcLow value as base for the measurement via OpAmp differential amplifier.<param2> = ANALOG_CT_MULTIPLIER ( 2146 = Default settings for a (AC) 20A/1V Current Transformer.) multiplier*100000 to convert raw ADC peak to peak range 0..1023 to RMS current in Amps. Value of 100000 corresponds to 1<param3> = ANALOG_CT_VOLTAGE (default 2300) to convert current in Amps to apparent power in Watts using voltage in Volts*10. Value of 2200 corresponds to AC220V. For DC its Volt/1000. Eg. 12VDC = 0.012.AdcParam 7,406,3282,0.012
Sent from Mail for Windows 10
From: FransOv
Sent: 31 January 2021 15:37
To: TasmotaUsers
Subject: Re: ADC CT Power calculation on ESP32
With ADC CT Power, I do not get the results I expect.
The code of xsns_02_analog.ino at lines 328 to 340 every second gets 32 samples from the ADC and records the maximum and minimum value from those samples. It then calculates the current as (max-min)*adcparam_factor/100000.
line 339: Adc[idx].current = (float)(analog_max-analog_min) * ((float)(Adc[idx].param2) / 100000)
For a test I used a load of about 1000W (4.25A) and attached a scope to the CT013. For ease of calculation I set the factor to 1000. The scope shows that peak to peak voltage at the ADC input is about 500 mV. The web interface of the ESP32 shows a current varying from 6.2 to 6.8 A. If the measurement of the peak to peak voltage by the 32 samples was correct, I would expect something like 5A.
The conclusion, I think is, that you do not get a reliable peak to peak voltage this way. Thus rectifying the input before connecting it to the ADC seems to be the better way. At this voltage level, rectifying is not going to be easy. In addition to the above circuit I need to invert the signal and to smooth the ripple. The full wave rectifier based on a transistor as specified in the above publication is rather complex.
I'll check for an integrated solution. Digital circuits I can understand to a certain degree, analog circuits not so much.
Op zaterdag 30 januari 2021 om 15:39:00 UTC+1 schreef justi...@adieandco.com:
When you say that your values are way off what are you seeing vs expecting?
On Sat, 30 Jan 2021, 14:21 FransOv, <frans.ove...@gmail.com> wrote:
Hi Phil,
I always look for software solutions first before going the hardware way. Just because I’m more comfortable with software than with hardware.
The current transformers I use, SCT013-30A, deliver 1V at 30 Ampère. They do have a burden resistor built in, but no rectifier.
I agree that it would be better to rectify the voltage and than input it to the ADC. However, bridge rectifiers have a forward voltage drop of up to 0.6V which makes them not suitable in this case. I would have to amplify the AC voltage 10x then rectify it and after that drop it down to a level that the ADC can handle.
However your suggestion made me look further and I found this solution to rectify the AC with only a very small (0.03V) forward voltage drop. It comes from a publication at https://arxiv.org/vc/arxiv/papers/1205/1205.4604v1.pdf.
I’m going to try this, unless someone can suggest a simpler solution.
Op vrijdag 29 januari 2021 om 14:16:15 UTC+1 schreef knowles..@gmail.com:
Most CTs have a built in resistor, etc so that you get a DC voltage output so there shouldn't be a 'bias voltage'. If there isn't I would use a bridge rectified to convert the output to DC. Then what you need to think about is 2 things what is the full scale output of the CT in Volts and how does that compare to the full scale of the ADC. It's easy enough to connect a known load say 100W incandescent bulb and measure the voltage at the ADC and then scale from there.
Regards
Phil K
From: sonof...@googlegroups.com <sonof...@googlegroups.com> on behalf of FransOv <frans.ove...@gmail.com>
Sent: Friday, January 29, 2021 12:36:47 PM
To: TasmotaUsers <sonof...@googlegroups.com>
Subject: Re: ADC CT Power calculation on ESP32
I checked the code and see that it does not matter, as it is an alternating current. The code checks the upper and lower values in the samples, assuming it gets the top and the bottom of the sine wave that way. The difference is scaled by the factor.
So why am I getting values that are way off.
--
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/62c2e4b5-ac44-420d-920c-4b67274ba154n%40googlegroups.com.
--
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/5fef4958-b951-4bf5-9b5c-2b9461c3e4dbn%40googlegroups.com.
--
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/9731abb3-eb7b-4f83-b007-09587c570852n%40googlegroups.com.
What happens if you try
AdcParam 7,0,1073,0.23
Op zaterdag 30 januari 2021 om 15:39:00 UTC+1 schreef justi...@adieandco.com:
To view this discussion on the web, visit https://groups.google.com/d/msgid/sonoffusers/2015f29c-3c16-4161-a1ef-0ed230b63274n%40googlegroups.com.
On Feb 1, 2021, at 1:33 AM, FransOv <frans.ove...@gmail.com> wrote:
I tried, it only raises the amperage a bit. The root cause of the inaccuracy seems to be measuring the peak to peak voltage of the ac, changing the parameter does not affect that.
I found a cheap RMS to DC Converter module based on the LTC1966 chip on Aliexpress that looks promising (https://www.aliexpress.com/wholesale?catId=0&initiative_id=SB_20210201000221&SearchText=ltc1966). I ordered a couple. As soon as I receive them, will be a week or two, I'll report on whether they will do the job.
--
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/1b54b51d-ce11-4415-9bf0-fd2a5673c843n%40googlegroups.com.

The module has all the components of the application note on board. So no external components needed apart from the SCT013 current transformer. Makes me happy, no messy soldering required.
--
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/fd7dee51-ba62-4bd0-ad44-f481ef997047n%40googlegroups.com.
