Skip to content
UPEEC

Microcontroller ADC

Reading analog sensors with the built-in ADC — reference voltage, resolution and sampling.

Easy
Comments 0
int raw = analogRead(A0);              // 0–1023 on a 10-bit Arduino Uno
float volts = raw * 5.0 / 1023.0;       // (or / 1024, see datasheet)

Tips for accurate readings:

  • use a stable reference (VrefV_{ref}), not a noisy supply;
  • keep the source impedance low (≤ 10 kΩ for AVR) or add a buffer;
  • average several samples to reduce noise;
  • don't exceed VrefV_{ref} or the supply on the pin — divide higher voltages down.

ESP32 ADCs are notably non-linear; calibrate them or use an external ADC (ADS1115) for precision.

Spotted a mistake or want to add detail? Suggest an improvement — Content Contributors' edits are reviewed by editors before they go live.

Discussion (0)

Sign in or join free to ask questions and discuss this topic.