Skip to content

ESP32 ADC Attenuation Setting Wrong

DodaTech Updated 2026-06-26 1 min read

In this tutorial, you'll learn about ESP32 ADC Attenuation Setting Wrong. We cover key concepts, practical examples, and best practices.

The Problem

ESP32 ADC input voltage saturates or reads too low due to incorrect attenuation settings.

Quick Fix

Wrong

analogSetAttenuation(ADC_0db);  // Only 0-1.1V range
int val = analogRead(34);  // Reading 3.3V gets 4095 (saturated)
Input at 2.5V reads 4095 (saturated). Cannot distinguish voltages above 1.1V.
analogSetAttenuation(ADC_11db);
// 0-3.3V full range
int val = analogRead(34);
float mv = analogReadMilliVolts(34);
Serial.printf("ADC: %d, mV: %.0f\n", val, mv);
ADC: 3100, mV: 2500
(Proper reading for 2.5V input with 11dB attenuation)

Prevention

Use ADC_11db for 0-3.3V (recommended for most sensors). Use lower attenuation for better resolution on low-voltage signals. Set attenuation before reading. Check the max input voltage for your ADC pin.

DodaTech engineers apply these same patterns across Doda Browser, DodaZIP, and Durga Antivirus Pro for production IoT reliability.

FAQ

### What do the attenuation values mean?

ADC_0db: 0-1.1V, ADC_2_5db: 0-1.34V, ADC_6db: 0-2.0V, ADC_11db: 0-3.3V. Higher attenuation = wider range, lower resolution.

Can I set attenuation per channel?

Yes. Use analogSetPinAttenuation(pin, attenuation) for per-pin configuration instead of global setting.

Does attenuation affect accuracy?

Higher attenuation amplifies the input signal, which also amplifies noise. ADC_11db has about 2x more noise than ADC_0db.

Built by the developers of DodaTech

Doda Browser, DodaZIP & Durga Antivirus Pro