Replies: 1 comment 12 replies
-
You pointed the right lines where If you are using ADC_INPUT, the factor is set to 5 which means 32 readings |
Beta Was this translation helpful? Give feedback.
12 replies
# for free
to join this conversation on GitHub.
Already have an account?
# to comment
-
Hello,
I am using several analog sensors for various agricultural monitors and data loggers. I am noticing that the data signal from the ESP32's built-in ADC is very noisy and has a lot of "jitter" in the returned data. I am aware of the issues and limitations with the built-in ADC, not truly linear, and quite noisy without filtering capacitors, but Espressif's own documentation recommends that BOTH the filtering capacitors AND multi-sampling be used whenever possible to get more "accurate" readings from the ADC and reduce the noise and jitter.
https://docs.espressif.com/projects/esp-idf/en/v4.3.3/esp32/api-reference/peripherals/adc.html#minimizing-noise
I was told in the Discord discussion that Tasmota does have multi-sampling implemented and enabled, however it is by default only set to 2-samples per reading. This setting can be found in the following file, lines 314-328:
https://github.com/arendst/Tasmota/blob/development/tasmota/tasmota_xsns_sensor/xsns_02_analog.ino
uint16_t AdcRead(uint32_t pin, uint32_t factor) { // factor 1 = 2 samples // factor 2 = 4 samples // factor 3 = 8 samples // factor 4 = 16 samples // factor 5 = 32 samples uint32_t samples = 1 << factor; uint32_t analog = 0; for (uint32_t i = 0; i < samples; i++) { analog += analogRead(pin); delay(1); } analog >>= factor; return analog; }
I was also informed that to change this setting requires an entire re-compile of the firmware? This really seems like a feature that is important enough that it should have a console command to expose this setting for easier adjustment. Is there such a command? If not I would like to request this as a feature enhancement if possible.
Thank you for any help or info on this.
Beta Was this translation helpful? Give feedback.
All reactions