I received the first of my SCT-013-000’s today and it might be another week before the Arduino shield and EmonTx V3 arrives. So I built the circuit as per the docs, firstly for a Nano and then a Leonardo.
I used a 99 Ohm and 47 Ohm resistor in parallel for the burden resistor as I don’t have anything close to 33 Ohm. Online calcs show this should be 31.7 Ohm and I measured it at 31.9 so pretty close. I am using 470K bias pair and not using the OEM adaptor yet but will add that later.
Used the calibration as shown above by @mel from the docs and the results without the CT connected and 5V from the Arduino:
You should never need to change anything inside the library. It should be possible to adjust everything that you must to cater for most normal situations by using the ‘setter’ methods.
Yes, 30 - 50 mA is the sort of number we usually see with ‘breadboard’ builds. The emonTx can get a bit lower, due to a careful pcb layout.
I thought @mel said he had no input connected.
He could have a ‘noisy’ electrolytic capacitor - unlikely, but they’re not unknown.
Guys, I found where was part of my problem. Thanks to @Robert.Wall
I added ceramic capacitor and result still floating. Than I checked all connections and found bad contact.
I’ve noticed that this deviation is present everywhere:
on arduino and 5v power supply
on stm32 and 3.3v power supply
In addition other people has the same deviation. It seems to be stable - around 0.15 ±noise
Where it comes from? How to reduce it? Currently I’m reducing it with correction like @GeorgeB showed.
if (Irms0<k) {i0 = 0;} else {i0 = (Irms0-k)*v;}
where is k is a correction coefficient. In my case it is equals 0.18
You started a parallel thread How to enable 12bit for STM32F103
that logically continues from the beginning part of this one. Separating this across two threads will waste everyone’s time.
What you need to do is determine whether __arm__ or anything else that indicates that you have a 12-bit ADC is set, then use that to switch ADC_BITS from 10 to 12. What you appear to have done will cause bad results for any sketch you compile for a 10-bit ADC. Do not forget that the same library is used in every sketch, unless you fork your own version, which you keep just for the STM board. And if you do that, you can leave out the test for __arm__ and simply write #define ADC_BITS 12
#if defined(__AVR__)
delay(2); // Wait for Vref to settle
ADCSRA |= _BV(ADSC); // Convert
while (bit_is_set(ADCSRA,ADSC));
result = ADCL;
result |= ADCH<<8;
result = READVCC_CALIBRATION_CONST / result; //1100mV*1024 ADC steps http://openenergymonitor.org/emon/node/1186
return result;
#elif defined(__arm__)
return (3300); //Arduino Due
#else
return (3300); //Guess that other un-supported architectures will be running a 3.3V!
#endif
}
three cases: for AVR, arm and other processor types.
@mel
Is __arm__ set for you? Print it and see. In setup for your sketch, put
#ifdef(__arm__) Serial.println("__arm__ is defined"); #endif
If it says it is, then you should be OK. If not, then the safest solution for you, unless you can find something set by your choice of board in the IDE, is what I wrote in post 18 above.