Skip to content

Solve most of your issues, ESP32 #72

@alexmoz2016

Description

@alexmoz2016

Some code that you may want to change to make it work (I have ESP32):
In EmonLib.h:

	#if defined(__arm__)
	#define ADC_BITS    12
	#else
	#define ADC_BITS    10
	#endif

Just add/replace with:
#define ADC_BITS 12

Because ESP32 is a 12-bit ADC.

In EmonLib.cpp
Replace all occurences of "/1024" by "/(ADC_COUNTS>>1".
The code was originally written for a 10-bit ADC, without ability to change it to 12 bits.

That's all. The precision and predictability of the reading is improved a lot.

Another note, for Calibration (111.1 value). If you have a voltage-output sensor (SCT-013-015, SCT-013-020, etc.), replace the "111.1" with "15" for -015, "20" for -020, etc. In other words, use the same calibration value as the Amp/V value (15A/V use "15", 30A/V use "30"). Most of the examples I saw online, using the 111.1 calibration value, are only good for SCT-013-000 with current output (which also require a burden/load resistor). Since the non-000 (-015, -020, -050, etc.) sensors have the burden/load resistors integrated, the calibration constant is different.

I hope it helps someone. Took me a few days to figure it out.

Alex

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions