openenergymonitor / EmonLib

Electricity monitoring library - install in Arduino IDE's libraries folder then restart the IDE
openenergymonitor.org
GNU Affero General Public License v3.0
584 stars 418 forks source link

ESP32 resolution #48

Closed Harriethijssen closed 4 years ago

Harriethijssen commented 5 years ago

More of a question than an issue (at this point).

The code applies a "low pass filter" (not sure what this is), that calculation has: offsetV = offsetV + ((sampleV-offsetV)/1024); offsetI = offsetI + ((sampleI-offsetI)/1024);

I'm a bit suspicious for the 1024 value: should this be 4096 for a 12 bit resolution ADC? Many places in the code use ADC_COUNTS which translates to ADC_BITS<<1 (power of 2), for 12-bit ADC this results to 4096.

Like I said, more of a question out of ignorance.

carranzafp commented 5 years ago

Yes you are right, what I did was to replace all 1024 by ADC_COUNTS on the .cpp and on the .h I forced the ADC_BITS to 12

That solved for the library running on ESP32 DOIT V1 Kit