Ad Space — Top Banner

ADC Reading Wrong

Espressif ESP32

Severity: Moderate

What Does This Error Mean?

ESP32 ADC readings are noisy because the ESP32 ADC has a known non-linearity issue, especially on ADC2 pins when Wi-Fi is active. Use ADC1 pins (GPIO 32–39) instead of ADC2 pins, take multiple readings and average them, and use a 100nF capacitor on the analog input.

Affected Models

  • ESP32 DevKit
  • ESP32-WROOM-32
  • ESP32-S2
  • ESP32-S3
  • ESP32-C3
  • ESP32 WROVER

Common Causes

  • ADC2 pins conflict with Wi-Fi — ADC2 cannot be used when Wi-Fi is active
  • ESP32 ADC non-linearity — readings at the extremes (0–100mV and 3.1–3.3V) are inaccurate
  • Floating analog input — unconnected pin picks up noise
  • ADC attenuation set to wrong level for the input voltage range
  • Missing bypass capacitor — power supply noise coupling into the ADC input

How to Fix It

  1. Use only ADC1 pins when Wi-Fi is active.

    ADC2 pins (GPIO 0, 2, 4, 12–15, 25–27) are shared with the Wi-Fi radio and cannot be used for ADC while Wi-Fi is connected. Switch your analog input to ADC1 pins: GPIO 32, 33, 34, 35, 36 (VP), or 39 (VN). This alone fixes the majority of ADC issues on Wi-Fi projects.

  2. Average multiple readings.

    Take 32–64 ADC samples and average them in code to reduce noise. Example: sum all readings in a loop and divide by the count. This filters out high-frequency noise and gives a more stable reading.

  3. Add a 100nF capacitor on the analog input.

    Place a 100nF (0.1µF) ceramic capacitor between the analog input pin and GND as close to the ESP32 as possible. This forms a low-pass filter that reduces high-frequency noise from coupling into the ADC.

  4. Set the correct ADC attenuation.

    By default, ESP32 ADC attenuation is set for 0–1.1V input (ADC_ATTEN_DB_0). If your signal is 0–3.3V, set the attenuation to ADC_ATTEN_DB_12 (full range) using analogSetAttenuation() or the specific channel setting. Wrong attenuation causes readings that saturate or clip.

  5. Apply ADC calibration correction.

    ESP32 ADC has a known non-linearity especially between 0–150mV and above 3.0V. For the most accurate readings, use the ESP32 ADC calibration API (esp_adc_cal library) which applies a correction curve. This is documented in the Espressif ESP-IDF programming guide and improves accuracy significantly.

When to Call a Professional

ESP32 ADC hardware limitations are well-documented. If absolute precision is required, consider using an external I2C ADC (e.g., ADS1115) which provides better accuracy than the built-in ADC.