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.
Right
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
Built by the developers of DodaTech
Doda Browser, DodaZIP & Durga Antivirus Pro