ESP32 ADC: 10 Simple Steps to Improve Accuracy Fast (Beginner-Friendly Guide)

0b63979cd9494aa401d1fce2d73bb002
On: November 19, 2025
ESP32 ADC

Table of Contents

Learn ESP32 ADC with this easy, accurate beginner guide. Improve readings, fix errors, boost accuracy, and master ADC pins, voltage range, and calibration with simple steps.

If you’re working with sensors on the ESP32, you’ll eventually bump into one feature again and again: the ESP32 ADC. Whether you’re measuring temperature, light, soil moisture, battery level, or even capturing audio, the ESP32 ADC sits at the heart of all analog readings.

Think of this guide as a coffee conversation with a tech-savvy friend. We’ll walk through the basics, the small quirks, the pitfalls, and the tricks that help you get the most accurate analog readings out of your ESP32.

By the end, you’ll be able to choose the right ESP32 ADC pins, configure resolution, understand the voltage range, tune attenuation, and write clean code that gives stable results.

Let’s start from the basics and steadily walk toward real-world examples, performance tuning, and accuracy improvements.

What Is ADC and Why Does It Matter in ESP32?

Every sensor in the real world gives signals in the form of voltage. But microcontrollers can only understand numbers.
This is where an Analog to Digital Converter (ADC) comes in.

The ESP32 ADC takes an analog voltage and converts it into a digital value between 0 and ADC resolution (e.g., 0–4095 for 12-bit).

If we didn’t have an ADC, the ESP32 would be blind to all analog sensors.

How Many ADC Channels Does the ESP32 Have?

The ESP32 is generous when it comes to ADC support.

18 ADC channels in total
Split across two ADC units:

  • ADC1 → 8 channels
  • ADC2 → 10 channels

However, there’s an important note that beginners often miss:

ADC2 does not work reliably when WiFi is active.

If you’re using ESP32 ADC and WiFi together, always choose ADC1 pins.

We’ll explain why when we talk about ADC behavior, accuracy, and limitations.

ESP32 ADC Pins Overview

Here are the pins grouped by ADC unit:

ADC1 Pins (Recommended)

GPIO 32, 33, 34, 35, 36, 39
GPIO 37, 38 (in some modules)

ADC2 Pins (Not recommended when using WiFi)

GPIO 0, 2, 4, 12, 13, 14, 15, 25, 26, 27

If your project uses WiFi in any form (Web server, MQTT, Firebase, or OTA), stick with ADC1 pins for stable results.

ESP32 ADC Resolution (Bit Width)

The ESP32 ADC default resolution is:

12-bit (0–4095)

But you can change the ESP32 ADC bit width using code:

  • 9-bit → 0–511
  • 10-bit → 0–1023
  • 11-bit → 0–2047
  • 12-bit → 0–4095

This flexibility helps optimize speed vs accuracy.

High resolution = slower sampling
Lower resolution = faster sampling

For most projects, stick to 12-bit unless speed is more important than accuracy.

ESP32 ADC Voltage Range (Very Important)

Out of the box, the ESP32 ADC accepts:

0V to ~1.1V maximum

If your sensor outputs higher voltage (like 3.3V), the readings will saturate at max ADC value (4095).
This is why ESP32 has ADC attenuation.

ESP32 ADC Attenuation Explained

Attenuation allows the ESP32 to measure higher voltage safely.

Here are the modes:

AttenuationESP32 ADC RangeUse Case
0 dB0 – 1.1VSmall sensors, internal readings
2.5 dB0 – 1.5VSlightly higher voltage
6 dB0 – 2.2VMedium voltage sensors
11 dB0 – 3.3VFull range sensors, battery measurement

Most real-world sensors that work on 3.3V require:

11 dB attenuation

This is why knowing the ESP32 ADC voltage range matters.

ESP32 ADC Reference Voltage (Vref)

The ESP32 ADC uses an internal Vref around 1100mV, but it’s not the same for all boards.

Actual Vref can vary between 1000mV and 1200mV, which causes inconsistent readings.

To fix this, the ESP32 provides ADC calibration APIs (ESP-IDF).
We’ll cover ESP32 ADC calibration shortly.

ESP32 ADC Accuracy: What Beginners Should Know

Here’s the honest truth:
The ESP32 ADC is powerful but not extremely accurate out of the box.

Common issues include:

  • nonlinear readings
  • noise
  • variations between boards
  • WiFi interference
  • bad readings on ADC2
  • inaccurate low-voltage measurement

But the good news is:

There are simple tricks to improve ESP32 ADC accuracy instantly.

We’ll cover them after the examples.

Getting Started: Installing ESP32 Board in Arduino IDE

If you haven’t installed the ESP32 board package yet, follow this guide:

🔗 https://embeddedprep.com/how-to-install-esp32-in-arduino-ide/

This ensures your IDE has full support for ADC functions, attenuation, calibration, etc.

Basic ESP32 ADC Example

Let’s start with the simplest code.

Reading analog voltage on GPIO34

int analogValue = 0;

void setup() {
  Serial.begin(115200);
}

void loop() {
  analogValue = analogRead(34);  
  Serial.println(analogValue);
  delay(500);
}

This gives you a raw value between 0 and your set resolution (normally 4095).

But raw values are not very useful.
Let’s improve it.

Converting ADC Value to Voltage

float voltage = analogRead(34) * (3.3 / 4095.0);
Serial.println(voltage);

This works only when:

  • Your attenuation is set to 11 dB
  • Your board runs at 3.3V
  • Your Vref is close to 1100mV

If you want more accurate readings, calibration is required.

Setting the ESP32 ADC Attenuation

analogSetPinAttenuation(34, ADC_11db);

Available options:

  • ADC_0db
  • ADC_2_5db
  • ADC_6db
  • ADC_11db

This directly affects your ESP32 ADC voltage range.

Changing ESP32 ADC Resolution

analogReadResolution(12);

Options:

  • 9
  • 10
  • 11
  • 12 (default)

This controls ESP32 ADC bit width.

ESP32 ADC Sample Rate (Speed)

The ESP32 ADC can sample roughly:

6 kSamples/sec to 40 kSamples/sec (varies per mode)

For audio applications using ESP32 ADC audio, use I2S ADC mode, which supports higher speeds.

ESP32 ADC Frequency and Bandwidth

The ADC has limited bandwidth, especially for fast-changing signals like audio.

  • For slow sensors → bandwidth is more than enough
  • For waveforms or audio → use I2S with DMA (recommended)

This shifts processing to hardware, making sampling stable and high-speed.

Using ESP32 ADC for Audio (I2S ADC)

If you want to capture microphone input, avoid analogRead.
Use I2S ADC mode for:

  • cleaner audio
  • stable sampling frequency
  • higher ADC frequency (up to 44.1 kHz)
  • no block in CPU

This is ideal for:

  • Sound level meter
  • Voice detection
  • Spectrum analyzer
  • Audio streaming

ESP32 ADC and WiFi Issue: Why It Happens

A common beginner question:

Why does ADC stop working when WiFi starts?

Because ADC2 hardware is shared with WiFi radio.

When WiFi is active:

ADC2 reads are unreliable or fail entirely

Solution:

Always use ADC1 pins when doing ADC + WiFi projects.

ESP32 ADC Calibration (ESP-IDF Feature)

The ESP32 contains eFuse values that help you correct:

  • Vref variation
  • non-linearity
  • attenuation inaccuracies

Arduino does not expose full calibration APIs, but ESP-IDF does.

If you want best accuracy, use ESP-IDF functions such as:

  • adc1_get_raw
  • adc_cali_create_scheme_curve_fitting
  • adc_cali_raw_to_voltage

Calibration is a complete accuracy-booster.

Practical ESP32 ADC Accuracy Improvement Tips

Here are real-world tips used by experienced developers:

✔ 1. Always use ADC1 pins

Stable even when WiFi is on.

✔ 2. Use 11 dB attenuation for 3.3V sensors

Gives full range.

✔ 3. Add a 0.1 uF capacitor between signal & GND

Removes noise instantly.

✔ 4. Average multiple samples

int samples = 64;
long total = 0;

for (int i = 0; i < samples; i++) {
  total += analogRead(34);
}
int averageValue = total / samples;

✔ 5. Keep signal wires short

Long wires pick noise.

✔ 6. Use shielded cables for audio

Better signal-to-noise ratio.

✔ 7. Avoid powering sensors from 5V

Creates ground mismatch.

✔ 8. Calibrate using ESP-IDF

Most accurate results.


Measuring Battery Voltage with ESP32 ADC

If you want to read a Li-ion battery, you must divide voltage down using a voltage divider.

Example for 4.2V battery:

Use a 100k + 100k resistor divider → output becomes 2.1V
Set attenuation to 11dB

Then convert the ADC reading to voltage.

This uses the keyword ESP32 ADC battery voltage.


ESP32 ADC Error Sources

Understanding where ADC error comes from helps reduce it.

Common sources:

  • unstable power supply
  • non-linear ADC curve
  • inaccurate reference voltage
  • attenuation mismatch
  • sensor noise
  • temperature changes
  • WiFi interference
  • using ADC2 pins
  • breadboard resistance

Once you know these, accuracy becomes much easier to achieve.


Complete Example Code for Accurate ESP32 ADC Reading

#include 

const int adcPin = 34;
const float maxVoltage = 3.3;

void setup() {
  Serial.begin(115200);

  analogReadResolution(12);
  analogSetPinAttenuation(adcPin, ADC_11db);
}

void loop() {
  long sum = 0;
  int samples = 50;

  for (int i = 0; i < samples; i++) {
    sum += analogRead(adcPin);
  }

  float avg = sum / samples;
  float voltage = (avg / 4095.0) * maxVoltage;

  Serial.print("Raw: ");
  Serial.print(avg);
  Serial.print("  Voltage: ");
  Serial.println(voltage);

  delay(500);
}

This example combines:

✔ attenuation
✔ averaging samples
✔ 12-bit resolution
✔ stable ADC1 pin

This is the best balance between speed, accuracy, and simplicity.


ESP32 ADC in ESP-IDF (For Advanced Users)

If you’re developing a professional application, you should use:

  • adc1_config_width
  • adc1_config_channel_atten
  • adc1_get_raw
  • adc_cali_raw_to_voltage

These offer:

✔ highest accuracy
✔ calibration support
✔ predictable sample rate
✔ proper handling of attenuation
✔ better ADC bandwidth

Using ESP32 ADC ESP-IDF functions is essential for industrial-level precision.


ESP32 ADC Functions List (Arduino)

Useful Arduino functions include:

  • analogRead
  • analogReadResolution
  • analogSetWidth
  • analogSetPinAttenuation
  • adcAttachPin
  • analogSetClockDiv

These give basic control over ESP32 ADC functions for most hobby projects.


Real-World Use Cases of ESP32 ADC

Here are projects where ESP32 ADC shines:

✔ Soil moisture sensor

Reads 0-3.3V from a capacitive probe.

✔ LDR light sensor

Maps daylight to numeric values.

✔ Temperature sensors

NTC sensors connect easily to ESP32 ADC.

✔ Battery-powered IoT device

Measure battery level for power management.

✔ Audio capture

Record sounds using I2S ADC mode.

✔ Power monitoring

Measure voltage drop across resistors.

✔ Home automation

Detect doorbell, knock, or vibration.

Troubleshooting Guide: ESP32 ADC Problems and Solutions

Below are the most commonly searched ESP32 ADC troubleshooting questions, each answered clearly and naturally, using your keywords without keyword stuffing.

1. Why are my ESP32 ADC readings inaccurate or unstable?

The ESP32 ADC accuracy is affected by noise, uncalibrated reference voltage and wrong attenuation.
To improve ESP32 ADC accuracy improvement:

  • Use ADC1 pins instead of ADC2
  • Set correct ESP32 ADC attenuation
  • Calibrate Vref
  • Take multiple samples and average them
  • Keep wires short to reduce noise

This fixes most ESP32 ADC error issues.


2. Why does ESP32 ADC change when WiFi is turned on?

Because ADC2 shares internal hardware with WiFi.
When WiFi is active, ESP32 ADC and WiFi conflict, causing unstable readings.

Solution:
Use only ADC1 pins for sensors while WiFi is running.


3. Why are ESP32 ADC values always lower than expected?

This happens when:

  • Wrong ESP32 ADC attenuation is selected
  • Voltage range exceeds the ESP32 ADC reference voltage
  • Sensor output is not 0–3.3V
  • Vref varies between chips

Fix:
Set attenuation to 11 dB and calibrate Vref.


4. Why does the ESP32 ADC read 4095 always?

This means the input voltage is higher than the ESP32 ADC voltage range.
Your sensor output may be too high.

Solution:
Reduce voltage using a voltage divider so it stays within ESP32 ADC range.


5. ESP32 ADC only returns 0 or very small numbers. Why?

This is caused by:

  • Attenuation set to 0 dB
  • Wrong pin configuration
  • Loose connections
  • Sensor not powered properly

Fix:
Use analogSetPinAttenuation(pin, ADC_11db); so the full ESP32 ADC bit width can detect voltage fluctuations.


6. Why do ESP32 ADC values fluctuate even with a stable sensor?

Fluctuations are common because the ESP32 ADC resolution and internal circuit pick up noise.

You can improve stability by:

  • Using shielded cables
  • Adding a 0.1 µF capacitor between input and ground
  • Averaging multiple samples
  • Running ESP32 ADC calibration

7. Why is ESP32 ADC reading wrong battery voltage?

The ESP32 ADC battery voltage must always be measured through a voltage divider.
Direct connection will damage the board.

Correct way:

  • Reduce battery output to below 3.3V
  • Set attenuation to 11 dB
  • Calibrate Vref

8. Why does ESP32 ADC show different values compared to a multimeter?

Multimeters use high-precision hardware; the ESP32 ADC accuracy varies due to factory variation.

To reduce error:

  • Use ESP32 ADC calibration
  • Manually enter the measured reference voltage
  • Apply linear correction in code

9. Why does ADC read correctly sometimes and fail other times?

This usually happens when power supply is unstable or you used ADC2.

Fixes:

  • Use a stable 5V/3.3V power source
  • Switch to ADC1 pins
  • Add a decoupling capacitor
  • Keep cables short

10. Why does ESP32 ADC stop working after sleep mode?

Deep sleep reconfigures some GPIO pins.

Solution:

  • Reinitialize the ESP32 ADC functions after wakeup
  • Reapply attenuation and width settings

11. Why do ESP32 ADC readings jump when touching wires?

Your body acts like an antenna and introduces noise.

Fix:

  • Use shielded wires
  • Add proper grounding
  • Add a small signal capacitor

12. Why is the ESP32 ADC sample rate too slow?

Using standard analogRead gives a low ESP32 ADC sample rate (around 6–10 kHz).

To increase speed:

  • Use I2S ADC mode
  • Increase ESP32 ADC frequency
  • Use DMA

13. Why can’t I read analog input on some pins?

Some pins are digital-only or used internally.

Check ESP32 ADC pins list:
ADC1 channels: 32, 33, 34, 35, 36, 39
ADC2 channels: 0, 2, 4, 12–15, 25–27

If you are using WiFi, ADC2 pins will fail.


14. Why does ADC return full-scale value (4095) when voltage is below 1V?

This happens when the ESP32 ADC bit resolution is misconfigured or attenuation was set incorrectly.

Fix:
Set:

analogReadResolution(12);
analogSetPinAttenuation(pin, ADC_11db);

15. Why does ESP-IDF ADC example not match Arduino output?

The ESP32 ADC ESP-IDF uses a more accurate and calibrated backend.
Arduino analogRead is more basic.

Solution:
Use ESP-IDF if you want higher accuracy and stable readings.


16. Why does my ESP32 board affect ADC values?

Every ESP32 ADC board has:

  • different PCB layout
  • different noise levels
  • different factory Vref

Always calibrate per board.


17. Why does my ESP32 ADC audio sound distorted?

Distortion happens when:

  • sample rate too low
  • missing I2S mode
  • low bandwidth
  • wrong attenuation

Use I2S ADC mode for clean ESP32 ADC audio.


18. Why is ADC bandwidth too low for my project?

The ESP32 ADC bandwidth is limited in analogRead mode.

Use:

  • I2S
  • DMA
  • ESP-IDF ADC continuous mode

to boost bandwidth.


19. Why does my code crash when using ADC functions?

Crashes happen if the wrong pins or modes are used.

Fix:
Make sure:

  • Pin is ADC capable
  • Pin is not used by another peripheral
  • WiFi is not interfering with ADC2

20. Why am I getting random high values during fast sampling?

This happens because the ESP32 ADC frequency can overload the internal ADC if too high.

Solution:

  • Lower sample frequency
  • Add filtering
  • Use DMA I2S mode

21. My ESP32 ADC calibration data is missing. What do I do?

Some ESP32 chips don’t store factory calibration.

Fix:
Use software-based calibration and apply correction formulas manually.

Frequently Asked Questions (FAQ): ESP32 ADC1. What is the ESP32 ADC?

The ESP32 ADC is an analog-to-digital converter that reads analog voltages and converts them into digital values. It supports multiple channels, different attenuation levels and high-resolution measurement.

2. How many ADC channels does the ESP32 have?

The ESP32 has a total of 18 ADC channels, spread across ADC1 and ADC2.
If you are using WiFi, only use ADC1, because ADC2 becomes unstable with WiFi.

3. What is the ESP32 ADC resolution?

The ESP32 ADC resolution supports up to 12-bit, meaning you get values from 0 to 4095.
You can manually set 9-bit, 10-bit, 11-bit, or 12-bit depending on your project.

4. What is the ESP32 ADC voltage range?

By default, the ESP32 measures only 0–1.1V.
But with attenuation, the ESP32 ADC range increases:

  • 0 dB → 0 to 1.1V
  • 2.5 dB → 0 to 1.5V
  • 6 dB → 0 to 2.2V
  • 11 dB → 0 to 3.3V

5. What is ESP32 ADC attenuation?

ESP32 ADC attenuation allows the ADC to measure higher input voltages safely.
Most sensors that run on 3.3V need 11 dB attenuation.

6. Why is my ESP32 ADC inaccurate?

The ESP32 ADC accuracy may vary due to:

  • electrical noise
  • WiFi interference
  • uncalibrated Vref
  • long wires
  • poor grounding

Use averaging, proper attenuation, and calibration to improve ESP32 ADC accuracy improvement.

7. What is the reference voltage for ESP32 ADC?

The ESP32 ADC reference voltage (Vref) is around 1100 mV, but it varies from chip to chip.
Using calibration can correct this error and improve accuracy.

8. Can the ESP32 ADC measure battery voltage?

Yes, but you must use a voltage divider because Li-ion batteries are above 4V.
Then choose ESP32 ADC battery voltage code formulas for safe calculation.

9. Why does ADC stop working when WiFi turns on?

Because ADC2 shares hardware with WiFi.
If you use ESP32 ADC and WiFi together, only use ADC1 pins.

10. What is ESP32 ADC sample rate?

The ESP32 ADC sample rate varies depending on settings, normally from 6 kHz to 40 kHz using analogRead.
For higher rates, use I2S ADC mode.

11. Can I use ESP32 ADC for audio recording?

Yes.
If you need clean audio, use ESP32 ADC audio with I2S mode. It supports stable sampling, DMA, and higher bandwidth.

12. How do I reduce ESP32 ADC errors?

To minimize ESP32 ADC error, follow these steps:

  • Use ADC1 pins
  • Set correct attenuation
  • Take multiple samples
  • Add a capacitor on signal line
  • Run calibration

13. Which pins support ADC on ESP32?

All ESP32 development boards include multiple ESP32 ADC pins, but the most reliable ones are on ADC1:

32, 33, 34, 35, 36, 39

Avoid ADC2 pins when WiFi is required.

14. How do I set the ESP32 ADC bit width?

You can configure ESP32 ADC bit width (resolution) using:

analogReadResolution(12);

This sets the ESP32 ADC bit precision.

15. Can I use ESP-IDF for better ADC performance?

Yes.
The ESP32 ADC ESP-IDF APIs provide:

  • calibration
  • high-speed sampling
  • improved accuracy
  • control over attenuation, width, and frequency

This is recommended for industrial applications.

16. What is the maximum ESP32 ADC frequency?

With simple analogRead, the ESP32 ADC frequency is moderate.
But with I2S DMA mode, you can capture signals in the tens of kHz, suitable for audio and waveform sampling.

17. Why does my ESP32 ADC reading fluctuate?

Fluctuations happen due to noise, unstable power supply, or long wires.
Use:

  • averaging
  • filtering
  • shielded cables
  • proper grounding

to stabilize readings.

18. How do I use ESP32 ADC functions?

Common ESP32 ADC functions include:

  • analogRead
  • analogSetPinAttenuation
  • analogReadResolution
  • adcAttachPin

These help you configure and read analog inputs easily.

19. Does the ESP32 board affect ADC performance?

Yes.
Each ESP32 ADC board model may have different:

  • internal noise
  • Vref value
  • PCB layout interference

Always test readings per board and apply calibration.

20. What is ESP32 ADC bandwidth?

The ESP32 ADC bandwidth defines how fast the ADC can track changes in input signals.
For slow sensors it is enough, but for audio you must use I2S mode.

Leave a Comment