-
Notifications
You must be signed in to change notification settings - Fork 422
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Solve most of your issues, ESP32 #72
Comments
"Replace all occurences of "/1024" by "/(ADC_COUNTS>>1"." |
"Replace all occurences of "/1024" by "/(ADC_COUNTS>>1"." --> Error cause of missing ")" |
If I'm not mistaken, you should really change all values of It doesn't matter too much though since these values are just for the low-pass filter and either |
Note that the ESP32-S2 has a 13-bit ADC... |
Some code that you may want to change to make it work (I have ESP32):
In EmonLib.h:
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
The text was updated successfully, but these errors were encountered: