All articles

    What Is an ADC? Reading Analog Values on Arduino and ESP32

    What an ADC is and how to use it: resolution on paper vs in practice, converting readings to volts, how a SAR ADC works, speed, the reference voltage with an LM35 example, the ESP32's ADC quirks, the external ADS1115, the voltage limit, and tips for steadier readings.

    Updated 6 min read

    The real world is analog: temperature, light and battery voltage change continuously. But a microcontroller only understands numbers. The bridge between the two is the ADC (analog-to-digital converter).

    What does it do?

    It measures the voltage on a pin and converts it to an integer, from zero up to a maximum that depends on its resolution.

    A continuously varying voltage becomes steps on a staircase; the more bits, the smaller the steps
    A continuously varying voltage becomes steps on a staircase; the more bits, the smaller the steps

    Resolution

    ResolutionNumber of stepsMaximum value
    8 bits256255
    10 bits (Arduino Uno)10241023
    12 bits (ESP32)40964095

    With an Uno and a 5 V reference, each step ≈ 5 ÷ 1023 ≈ 4.9 mV. So the smallest change the ADC can detect is about 5 mV.

    Resolution on paper vs real accuracy

    10 bits means 1024 steps, but it doesn't mean every reading is correct to the last step. The ADC itself has a small error, the supply has noise, and neighbouring pins affect each other. In practice an Uno gives readings that jitter by a count or two even with a steady voltage, and an ESP32 jitters more.

    The good news is that averaging many readings really does improve accuracy: averaging 16 readings cuts the jitter a lot, and a technique called oversampling can extract more resolution than the original 10 bits, provided there's a little natural noise making the readings differ. In most projects, a simple average is enough.

    Converting the reading to volts

    int raw = analogRead(A0);
    float volts = raw * 5.0 / 1023.0;

    And for an ESP32 (12 bits and about 3.3 V): raw * 3.3 / 4095.0.

    How does it measure inside the chip?

    The ADC in most microcontrollers is a SAR (successive approximation) type, and it works like a game of "guess the number":

    1. It holds the voltage on a small internal capacitor (sample and hold), so the voltage doesn't change while it measures.
    2. It compares it with half the range: higher or lower? That's the first bit.
    3. It splits the half containing the voltage in two and compares again, which gives the second bit.
    4. It repeats until all the bits are done: 10 comparisons for 10 bits.

    That's why the source resistance matters: that small capacitor must charge from the sensor in a short time. If the source has a high resistance, the reading comes out low or is affected by the pin read before it.

    Speed

    analogRead on an Uno takes about 100 µs, so at most about 10 thousand readings per second. That's plenty for temperature, potentiometers and batteries, but too slow for recording audio: to measure a signal of a given frequency, you must sample at least twice as fast, and audio reaches tens of kilohertz. For audio and fast signals, the ESP32 is much faster, or use a dedicated ADC chip.

    The reference voltage (Vref)

    The ADC compares the voltage against a reference. On the Uno it's the 5 V supply, so if the supply itself is only 4.8 V (from USB, say), all the readings will be slightly off. For better accuracy:

    • Use the internal reference (1.1 V on the Uno) with a voltage divider for the measurement.
    • Or an accurate external reference on the AREF pin.

    Example: an LM35 sensor with ten times the resolution

    The LM35 outputs 10 mV per degree. With a 5 V reference, each ADC step = 4.9 mV, so the resolution is about half a degree. If you switch to the internal 1.1 V reference:

    analogReference(INTERNAL);          // on the Uno: 1.1 V
    float mv = analogRead(A0) * 1100.0 / 1023.0;
    float tempC = mv / 10.0;

    Each ADC step is now about 1.07 mV, so the resolution is about 0.1 degree. The price: the maximum voltage you can measure is now 1.1 V (110 °C for the LM35), which is enough. Throw away the first few readings after changing the reference, because it takes a moment to settle. And the internal reference isn't exactly 1.1 V on every chip, so if you need real accuracy, measure it once and put the actual figure in your code.

    The ESP32's ADC

    • Noticeably non-linear at the ends (near 0 and near the maximum).
    • The range is set by the attenuation setting.
    • ADC2 doesn't work while Wi-Fi is on. Use ADC1 pins for readings.
    • If you need accuracy, use analogReadMilliVolts(), which returns the voltage in millivolts after the chip's built-in calibration, or an external ADC chip like the ADS1115.
    • With the default attenuation (11 dB) the practical range is roughly 0.15 to 3.1 V. Keep the signal within that range to stay away from the non-linear ends.

    An external ADC: the ADS1115

    If the chip's built-in ADC isn't enough, the ADS1115 is a small I2C module:

    • 16 bits: more than 65 thousand steps instead of 1024.
    • Programmable gain: can measure small signals (down to ±0.256 V full scale) with very high resolution.
    • Differential measurement: measures the difference between two pins, useful with current-sense resistors and load cells.
    • 4 inputs and a lower speed (up to a few hundred readings per second), which is enough for most sensors.

    And since it's on I2C, it works alongside other modules on the same bus. Learn more in the UART, I2C and SPI article. Some newer boards also have a higher-resolution ADC built in, such as the Uno R4.

    The most important rule: don't exceed the allowed voltage

    A voltage above the supply on an ADC pin can damage the chip. If you're measuring a higher voltage (such as a 12 V battery), bring it down first with a voltage divider. The full example is in the voltage divider article.

    Tips for steadier readings

    1. Average 10–20 readings.
    2. A 100 nF capacitor between the reading pin and ground.
    3. Don't use very large resistances (above about 10 kΩ equivalent) before the ADC, or add a capacitor to help it.
    4. Clean ground and a stable supply. Motors and relays on the same supply ruin readings.

    Sensors such as the potentiometer and the LDR and thermistor are all read with the ADC.

    FAQ

    Why does an unconnected pin read random numbers? Because it's floating and connected to nothing, so it picks up any stray charge or noise. Any analog pin you use must be connected to a source; leave unused ones alone.

    I read two pins one after the other and the second reading is affected by the first? The internal capacitor still holds the previous pin's voltage, and the second source has a high resistance so it doesn't change it in time. Read the pin twice and keep the second reading, or put a 100 nF capacitor on the input.

    Can I measure current with the ADC? Not directly. You pass the current through a small resistor and measure the voltage across it, or use a current-sensing module. The methods are in the current sensing article.

    Circuits Nerd
    © 2026 Circuits Nerd. All rights reserved.