Community
OpenEnergyMonitor

Community

EmonLib / ESP32 How to calibrate?

Hi,

I am using my Arduino development tools to use emonlib on an ESP32 development board. I got everything compiling and running but my serial output is not putting out stable and correct values. So I guess I need to calibrate but after several days I haven;t managed to get it working.

I am using an SCT-013-010 sensor. This sensor has a build in burden and puts out 0-1V for 0-10A.

I am using 2x 10k Ohm resistor devider between +3v3 and gnd. One side of the sct to the middle of this devider and the other pin to ESP input pin GPIO-36.

My question:

  • How to get the correct value for Cal in: emon1.current(CurrentSensePin, Cal);

  • Is 1480 good enough for my setup? double Irms = emon1.calcIrms(1480); I notice no stable value with a stable load…

I am not measuring the voltage.

I just want to measure my power usage and put it out on serial. no more then that. Well, next step will be sending an email when power passes a border, hence the ESP32. But basically my question is just Arduino / EmonLib.

I havent found many example with the SCT-013-010. So probably others may find this a helpfull question as well. Thank you!

I haven’t worked with the SCT-013-010, or the ESP. But
I have built an Arduino with other clamp-on CT’s.
My experience has been at the lower end of the scale,
less than 1.5 amps, the accuracy was like +/- 50%.
I would suggest try measuring at 5 or even 10 amps.

Few people use the low current c.t’s, but there’s no specific reason to think it should be any different to the “shop standard” SCT-013-000 except that the burden is internal.

1.  The current calibration constant for your 10 A c.t. is 10.0
2.  “1480” is no longer the optimal value. You want the closest number that is the number of samples to a whole number of mains cycles. The sampling rates, measured with a standard emonTx V3.4 (and the emonPi is the same processor) are:
calcIrms( ) - approx 5588 current samples per second.
calcVI( ) - approx 2535 pairs of voltage & current samples per second.
See
Sampling rate of emonLib
for more details.

I’ve no idea how good (or otherwise) the ADC on the ESP32 is, but the one in the ESP8266 is not really usable for our purposes, as it takes far too long to make a reading, hence there are not enough samples in each mains cycle to get a sensible reading.
I’ve read that it is capable of 6000 samples / second, but whether that is using the same method to access the ADC that emonLib uses, I do not know.

If you are interested in measuring currents significantly lower than 10 A, you can of course multiply the current by passing more turns through the c.t, then change the calibration accordingly: 5 for 2 turns, 3.33 for 3, etc.

I think the ESP32 ADC is not compatible with emonlib or it is just very bad at all. It seems to have functions to set the attenuation and voltage range. This makes the 2 resistors not ending up in the middle. But even after studying ESP32, I still dont understand the values read. I made my own lowest/highest detector over 50000 samples and calculated RMS from there but the values are just very noicy and come not close to what I expect. On my scope I do understand the readings and can manually calculate the power (using a 100W light bulb). So I will probably move to a normal Arduino as a test now.

EmonLib was designed and developed for the Arduino platform and the Atmel 328P.

Is the title of this thread correct? It seems that your problem is not calibration, but with correctly designing the input conditioning components and converting emonLib to work with the ESP32. Is that correct?

It is very obvious to me that changes will be necessary for a different processor with a different architecture, so my first question is, having quickly looked at some of the documentation for the ESP32, how have you changed emonLib to cater for the different commands that the different processor requires, and the different procedures required by the ADCs?

That makes no sense to me, can you explain what you mean?
Looking here, it would appear that (a) noise is a problem that Espressif acknowledges, and (b) that the input must be biased to a level of 1 V for optimal operation, not 1.65 V as you appear to have it.