ESP32 ADC strange offset drift

zhaozhao
Posts: 2
Joined: Sat Jan 30, 2021 2:30 am

ESP32 ADC strange offset drift

Postby zhaozhao » Sat May 29, 2021 8:40 pm

Recently I am trying to build a Ni-MH battery charger with ESP32, more specifically using an ESP32-DevKitC board with a Rev1 chip. I used the ADC1 to monitor the battery voltage and logged it on a computer. The code is derived from the adc example code included in esp-idf. To my surprise, I discovered some strange, occasional jumps of the output offset that are around 4 LSBs and last for quite a few seconds or even minutes. This is quite annoying -- even oversampling won't remove this kind of correlated noise.

Attached is a plot of ADC conversion results over the course of ~20 minutes. A battery (very quiet and stable) is connected to pin34 via a 10k/10k voltage divider + 220nf decoupling cap between pin34 and ground. I also did 4096x oversampling and decimated the result to 16 bits. WiFi or BT are not used.
esp32_voltage.png
esp32_voltage.png (63.68 KiB) Viewed 1804 times
What I have tried so far:
- Switch to different channels/pins --> does not help
- Use ADC2 instead of ADC1 --> does not help
- Use different attenuation --> does not help
- Use lower or higher ADC clock division--> does not help
- Force ADC power on (ADC_POWER_SW_ON) --> does not help
- Add delay between ADC conversions --> does not help
- Reduce CPU clock to 80MHz --> does not help
- Shield the board & battery --> does not help

Initially I have suspected that this could be due to the local non-monotonicity of the ADC. But later I realized that this occational fluctuation is actually additive -- It shifts everything up by 4 LSBs, no matter what the input voltage is.

I appreciate it if there are any solutions. Thanks!

Who is online

Users browsing this forum: Majestic-12 [Bot] and 147 guests