16  ADC Fundamentals

MVU: Analog-to-Digital Conversion

Core Concept: An ADC (Analog-to-Digital Converter) translates continuous real-world signals (voltage) into discrete digital numbers that microcontrollers can process. Resolution (bit depth) determines precision: a 12-bit ADC divides the voltage range into 4,096 steps, while 10-bit provides only 1,024 steps.

Why It Matters: Every IoT sensor that measures physical quantities (temperature, light, pressure, sound) produces analog signals, but microcontrollers only understand digital values. The ADC is the mandatory bridge - without it, your microcontroller literally cannot “see” the physical world. Understanding ADC resolution and quantization error helps you choose the right hardware for your accuracy requirements.

16.1 Learning Objectives

By the end of this section, you will be able to:

  • Trace ADC Operation: Describe the sample-hold-quantize-encode pipeline that converts analog voltages to digital values
  • Apply ADC Formulas: Calculate digital output, step size, and reconstructed voltage from input parameters
  • Differentiate Resolution Levels: Analyze how bit depth (8, 10, 12, 16-bit) determines voltage precision and quantization step size
  • Estimate Quantization Error: Calculate maximum measurement error for a given ADC resolution and reference voltage
  • Classify ADC Architectures: Contrast SAR, sigma-delta, and flash ADCs by speed, resolution, power, and IoT suitability
In 60 Seconds

Analog-to-digital converters (ADCs) are the bridge between the continuous physical world and the discrete digital domain: they sample an analog voltage at regular intervals and quantise it into a binary number. Resolution (bits) determines how many discrete levels are available, while sampling rate must exceed twice the signal bandwidth to avoid aliasing. Understanding ADC fundamentals is essential for reading any real-world sensor on a microcontroller.

16.2 For Beginners: Analog-to-Digital Conversion

An ADC (Analog-to-Digital Converter) is the bridge between the smooth, continuous real world and the stepped, numerical world of computers. Imagine a thermometer that reads 23.7 degrees – the ADC is the component that turns that smooth temperature into a number your microcontroller can work with. The more “bits” an ADC has, the finer the steps and the more precise the measurement, like using a ruler with millimeter marks instead of just centimeter marks.

16.3 Prerequisites

Before diving into this chapter, you should be familiar with:

16.4 Why ADCs Matter for IoT

The gap between analog and digital is THE fundamental challenge in IoT.

The world is analog (temperature, pressure, light), but microcontrollers are digital (0s and 1s). Understanding this interface is essential for every IoT sensor application.

The ADC is like a translator between the smooth real world and the step-by-step computer world!

16.4.1 The Sensor Squad Adventure: The Number Translator

Sammy the Sensor was frustrated. “I can feel exactly how warm it is - 23.456 degrees! But Max the Microcontroller keeps asking me for simple numbers like 23 or 24!”

Max explained: “I’m sorry, Sammy. I can only work with whole numbers - I count in steps, not smooth slides. When you tell me 23.456, I don’t know what to do with the .456 part!”

Lila the LED had an idea. “What about asking ADC Andy for help? He’s the best translator in all of IoT City!”

ADC Andy arrived wearing a special badge that said “12-bit”. He explained: “My badge tells me how precise I can be! With 12 bits, I can translate Sammy’s smooth feelings into 4,096 different steps!”

“Watch this,” Andy continued. “Sammy, tell me the temperature.”

“It’s 23.456 degrees!” said Sammy.

ADC Andy thought for a moment. “With my 4,096 steps for temperatures between 0 and 100 degrees, that’s about step number 961. Here you go, Max!”

Max was delighted. “961! Now that’s a number I can work with! I’ll save it, send it over the network, and compare it to yesterday’s reading!”

Bella the Battery smiled. “And because Andy translates so efficiently, I don’t waste energy trying to send impossibly precise numbers!”

16.4.2 The Staircase Analogy

Imagine you’re on a smooth ramp that goes from 0 to 100:

  • Analog Sammy can stand ANYWHERE on the ramp: 23.1, 23.2, 23.3456789…
  • Digital Max can only stand on STAIRS

ADC Andy builds the stairs: - 8-bit Andy builds 256 stairs (big steps, less precise) - 10-bit Andy builds 1,024 stairs (smaller steps, more precise) - 12-bit Andy builds 4,096 stairs (tiny steps, very precise!)

More stairs = smaller steps = closer to Sammy’s exact position!

16.4.3 Key Words for Kids

Word What It Means
ADC A translator that converts smooth values to stair-step numbers
Resolution How many stairs the ADC builds (more stairs = more precise)
Bits The ADC’s power level - 8-bit, 10-bit, or 12-bit
Quantization Rounding to the nearest stair step
Vref The highest voltage the ADC can measure (the top of the stairs)

16.4.4 Try This at Home!

The Staircase Translation Game!

  1. Draw a ramp from 0 to 10 on paper
  2. Now draw 4 stairs on top of the ramp (this is like a 2-bit ADC: 2² = 4 steps)
  3. Pick a point on the ramp (like 7.3)
  4. Which stair is it closest to? That’s your “digital value”!

Now try with 8 stairs (3-bit) - is your answer more precise?

What you learned: ADCs work just like this! More bits = more stairs = better precision. But even the best ADC rounds to the nearest step - that tiny error is called “quantization error”!

16.5 Key Concepts

  • ADC (Analog-to-Digital Converter): Converts continuous analog voltage to discrete digital values; essential for sensor interfacing
  • Resolution: Number of bits in ADC determining precision; 10-bit = 1024 values, 12-bit = 4096 values
  • Quantization Error: Difference between actual analog value and closest digital representation; reduced by higher resolution
  • Reference Voltage (Vref): Maximum voltage the ADC can measure; determines the voltage-per-step
  • Sampling Rate: How often the ADC takes readings; measured in samples per second (SPS)

16.6 The Analog vs Digital Divide

Comprehensive ADC architecture diagram showing the complete analog-to-digital conversion process. Left side shows analog input signal from sensor with continuous waveform. Center shows sample-and-hold circuit capturing instantaneous voltage, followed by successive approximation register (SAR) comparing against internal DAC reference. Right side shows digital output as binary code with corresponding quantization levels.

ADC architecture and conversion process
Figure 16.1: ADC architecture showing the conversion from analog sensor signals to digital values

The ADC is the essential bridge between the continuous analog world of sensors and the discrete digital world of microcontrollers.

16.6.1 The Analog World

Everything in nature is analog:

Diagram showing the analog nature of real-world sensor measurements including temperature varying smoothly from 20.0 to 25.7 degrees, light intensity ranging continuously from 0 to 1000 lux, and sound levels changing fluidly between 30 and 85 dB. Emphasizes that physical quantities have infinite precision between any two values.

The Analog World: Continuous Sensor Measurements
Figure 16.2: The Analog World: Continuous Sensor Measurements

Characteristics:

  • Continuous - Infinite values between any two points
  • Smooth transitions - No sudden jumps
  • Infinite resolution - Limited only by measurement precision

16.6.2 The Digital World

Computers are digital:

Diagram illustrating the digital world where values exist only as discrete steps. Shows binary representation with 0s and 1s, step changes between fixed voltage levels, and finite resolution determined by the number of bits. Contrasts with the smooth continuous nature of analog signals.

The Digital World: Discrete Binary Values and Step Changes
Figure 16.3: The Digital World: Discrete Binary Values and Step Changes

Characteristics:

  • Discrete - Only specific values (0, 1, 2, 3…)
  • Step changes - Jumps between values
  • Finite resolution - Limited by number of bits

Why Digital?

  • Noise immunity (small voltage changes don’t affect 0/1)
  • Perfect copying (0 stays 0, 1 stays 1)
  • Easy processing (logic gates, arithmetic)
  • Compact storage (bits take minimal space)

16.7 Analog-to-Digital Converters (ADC)

ADC = Device that converts continuous analog voltage into discrete digital numbers

Flowchart showing the three-stage ADC conversion pipeline. Stage 1 Sample and Hold captures the instantaneous analog voltage. Stage 2 Quantize maps the voltage to the nearest discrete level based on resolution. Stage 3 Encode converts the quantized value to binary output format for the microcontroller.

ADC Internal Architecture: Sample-Quantize-Encode Pipeline
Figure 16.4: ADC Internal Architecture: Sample-Quantize-Encode Pipeline

16.7.1 ADC Components

Essential Elements:

  1. Input Range: Minimum and maximum voltage (e.g., 0-5V)
  2. Reference Voltage (Vref): Defines the maximum value
  3. Resolution: Number of bits (8, 10, 12, 16)
  4. Sampling Rate: How often readings are taken (Hz)

16.7.2 ADC Resolution

Detailed ADC operation diagram showing analog input signal on the left connected to sample-and-hold circuit, then to quantization stage that maps continuous voltage to discrete digital levels, and finally to binary encoder output producing digital codes. Shows Vref connection for reference voltage and clock signal for timing the conversion process.
Figure 16.5: Analog-to-Digital Converter operation and components
Side-by-side comparison of ADC and DAC conversion processes. Left side shows ADC with analog input waveform being sampled and converted to stair-step digital output with binary values. Right side shows DAC with digital input codes being converted back to reconstructed analog waveform with slight staircase artifacts from the discrete levels.
Figure 16.6: ADC and DAC conversion processes

Resolution = Number of discrete values the ADC can output

Formula: Number of values = 2n (where n = bits)

Bits Values Resolution @ 5V Resolution @ 3.3V Example Use
8 256 19.5 mV/step 12.9 mV/step Low-cost sensors
10 1,024 4.88 mV/step 3.22 mV/step Arduino Uno
12 4,096 1.22 mV/step 0.805 mV/step ESP32, STM32
16 65,536 0.076 mV/step 0.050 mV/step Precision instruments

See the full resolution comparison table for additional bit depths (6-bit through 24-bit) with error calculations.

For a 12-bit ADC with \(V_{ref} = 3.3\) V, the step size (LSB) is \(V_{step} = V_{ref} / 2^n = 3.3 / 4096 = 0.806\) mV. Reading a 2.0V sensor gives digital value \(D = \lfloor V_{in} / V_{step} \rfloor = \lfloor 2.0 / 0.000806 \rfloor = 2481\) (out of 4095). Quantization error is up to \(\pm V_{step}/2 = \pm 0.403\) mV. If the sensor signal is 100mV (\(\approx\) 124 counts), and noise causes \(\pm 2\) count variation, SNR is \(20 \log_{10}(124/2) = 35.9\) dB – adequate for most IoT temperature sensors but marginal for precision instrumentation.

Comparison chart showing how ADC bit depth affects the number of discrete values. 1-bit provides only 2 values, 8-bit provides 256 values, 10-bit provides 1024 values, 12-bit provides 4096 values, and 16-bit provides 65536 values. Illustrates exponential growth with each additional bit.

ADC Resolution Comparison: 1-bit to 16-bit Value Ranges
Figure 16.7: ADC Resolution Comparison: 1-bit to 16-bit Value Ranges

Interactive ADC Resolution Visualization

Explore quantization with the Falstad Circuit Simulator:

Open Circuit Simulator →{target=“_blank”}

What to explore:

  1. Load the “Voltage Divider” example from the menu (Circuits → Passive Filters → Voltage Divider)
  2. Observe the smooth analog voltage on the oscilloscope
  3. Mentally “staircase” the smooth wave: A 3-bit ADC (8 levels) would snap to nearest voltage
  4. Compare 8-bit (256 steps — smooth staircase) vs 4-bit (16 steps — chunky staircase)
  5. Watch how a slow-changing analog signal (like temperature) gets approximated by discrete digital values

The simulator shows electron flow animation and real-time voltage/current graphs, helping visualize how continuous analog voltages map to discrete digital numbers.


16.8 ADC Architectures

Real-world ADCs use different conversion techniques optimized for speed, accuracy, and power consumption. The most common architecture in IoT microcontrollers is the Successive Approximation Register (SAR) ADC.

Successive approximation register ADC architecture showing comparator, DAC, and SAR logic

SAR ADC Architecture
Figure 16.8: SAR ADCs dominate IoT applications due to their balance of speed, resolution, and power efficiency.

How SAR ADC Works (Binary Search):

The SAR ADC determines the digital output by testing each bit sequentially, starting from the Most Significant Bit (MSB) down to the Least Significant Bit (LSB):

  1. Initial State: All bits set to 0, test voltage (V_test) = 0V
  2. Test MSB (bit 11 for 12-bit ADC): Set bit to 1, DAC outputs V_test = Vref/2
    • If V_input > V_test: Keep bit = 1 (input is in upper half)
    • If V_input < V_test: Clear bit = 0 (input is in lower half)
  3. Test bit 10: Adjust next bit, DAC outputs new V_test
    • Repeat comparison and decision
  4. Continue for all 12 bits (bit 11 → bit 0)
  5. Result: 12-bit digital value represents input voltage

Example: Converting 2.0V with 12-bit SAR ADC (Vref = 3.3V)

Step Bit V_test V_input vs V_test Decision Binary Result
1 11 (MSB) 1.650V 2.0V > 1.650V Keep 1 1???????????
2 10 2.475V 2.0V < 2.475V Clear 0 10??????????
3 9 2.063V 2.0V < 2.063V Clear 0 100?????????
4 8 1.856V 2.0V > 1.856V Keep 1 1001????????
12 0 (LSB) ~2.000V Final comparison Set 1 100110110001

SAR ADC Advantages for IoT:

  • Fast Conversion: Typically 1-12 us per sample depending on configuration (ESP32: ~12 us default, faster with DMA)
  • Low Power: ADC peripheral draws only a few mA during conversion
  • Moderate Complexity: Simpler than pipeline ADCs, faster than integrating ADCs
  • Widely Used: Arduino Uno (10-bit SAR), ESP32 (12-bit SAR), STM32 (12-bit SAR)

Alternative ADC Architectures:

  • Flash ADC: Parallel comparators, extremely fast (ns), high power, limited resolution (<8-bit)
  • Sigma-Delta ADC: Oversampling + digital filtering, high resolution (16-24 bit), slow (~ms), used in precision weighing (HX711)
  • Pipeline ADC: Multi-stage conversion, very fast (MHz), high power, used in video/RF applications
Tradeoff: ADC Resolution vs. Speed and Power

Option A: 12-bit SAR ADC (ESP32 built-in): Resolution 0.8mV/step at 3.3V reference, conversion time ~12us (default), power consumption minimal (integrated), cost $0 (integrated), max sampling rate ~83 kSPS typical

Option B: 16-bit Sigma-Delta ADC (ADS1115 external): Resolution 0.05mV/step at 3.3V reference, conversion time 8ms at 16-bit mode, power consumption 150uA continuous, cost $3-5, max sampling rate 860 SPS

Decision Factors: Choose 12-bit SAR for signals changing faster than 100Hz (audio, vibration, motor control) where 0.8mV resolution is adequate. Choose 16-bit Sigma-Delta for precision DC measurements (strain gauges, thermocouples, load cells) where sub-millivolt accuracy matters more than speed.


16.9 Analog-Digital Interface Challenges

Converting real-world analog signals to digital values introduces several practical challenges.

ADC noise sources diagram showing quantization noise, thermal noise, and jitter effects

ADC Noise Sources and Mitigation
Figure 16.9: Clean ADC readings require addressing multiple noise sources with appropriate filtering and grounding strategies.

Key Interface Challenges:

1. Quantization Noise (Inherent ADC Limitation)

  • Definition: Difference between actual analog value and nearest digital step
  • Formula: Quantization error = +/-(Vref / 2^(n+1))
    • 12-bit ADC @ 3.3V: +/-0.403mV error per sample
    • 10-bit ADC @ 5V: +/-2.44mV error per sample
  • Mitigation: Use higher-resolution ADC or oversampling (averaging multiple samples)

2. 1/f Noise (Flicker Noise)

  • Characteristics: Noise power inversely proportional to frequency
    • Dominates at low frequencies (<1 kHz)
    • Caused by semiconductor defects in transistors, resistors
  • Impact on IoT: DC and slow signals (temperature, pressure) most affected
  • Mitigation Strategies:
    • Averaging: Take 16-64 samples, average to reduce noise by sqrt(N)
    • AC Coupling: For AC signals, use capacitor to block DC and 1/f noise

3. Thermal Noise (Johnson-Nyquist Noise)

  • Definition: Random noise from thermal agitation of charge carriers
  • Formula: Vrms = sqrt(4kTR*delta_f)
  • Example: 10k ohm resistor at 25C, 10kHz bandwidth → 1.3uV RMS noise
  • Mitigation: Lower resistance values, reduce bandwidth with RC filter

4. Power Supply Noise

  • Sources: Switching regulators, digital circuits, motor drivers
  • Impact: Couples into analog signal via shared ground/power rails
  • Mitigation:
    • Use separate analog ground plane (AGND vs DGND)
    • Add decoupling capacitors (0.1uF + 10uF) near ADC Vref pin
    • Use low-dropout (LDO) regulator for analog power supply

Best Practices for Clean ADC Readings:

  1. Filter high frequencies: Add RC low-pass filter (R=10k, C=0.1uF → fc=159Hz) before ADC input
  2. Average multiple samples: 16-64 samples reduces noise by 4-8x
  3. Use external voltage reference: Internal Vref has +/-5% tolerance; external 2.5V reference has +/-0.05%
  4. Ground plane hygiene: Separate analog/digital grounds, join at single point
  5. Calibration: Measure known reference voltages, apply offset/gain corrections in software


16.10 ADC Resolution Comparison Table

Resolution Total Values Voltage Step (5V) Voltage Step (3.3V) Max Error (5V) Max Error (3.3V) Typical Applications
6-bit 64 78.1 mV 51.6 mV +/-39 mV +/-25.8 mV Simple threshold detection
8-bit 256 19.5 mV 12.9 mV +/-9.8 mV +/-6.45 mV Basic sensors, DAC audio
10-bit 1,024 4.88 mV 3.22 mV +/-2.44 mV +/-1.61 mV Arduino, general IoT sensors
12-bit 4,096 1.22 mV 0.805 mV +/-0.61 mV +/-0.403 mV ESP32, STM32, precision sensors
14-bit 16,384 0.305 mV 0.201 mV +/-0.15 mV +/-0.101 mV Industrial sensors
16-bit 65,536 0.076 mV 0.050 mV +/-0.038 mV +/-0.025 mV Thermocouples, load cells
24-bit 16,777,216 0.298 uV 0.197 uV +/-0.149 uV +/-0.098 uV High-precision weighing (HX711)

16.10.1 Interactive ADC Resolution Calculator

Use the sliders below to explore how bit depth, reference voltage, and input voltage affect ADC output values.


16.11 Typical Microcontroller ADCs

Platform Resolution Vref Channels Sample Rate Precision
Arduino Uno 10-bit (1024) 5V 6 ~9.6 kHz +/-2 LSB
ESP32 12-bit (4096) 3.3V 18 ~83 kHz +/-6 LSB
STM32 12-bit (4096) 3.3V 16 1 MHz +/-1.5 LSB
Raspberry Pi Pico 12-bit (4096) 3.3V 3 500 kHz +/-2 LSB

LSB = Least Significant Bit (smallest measurable change)

16.11.1 Arduino Uno Example

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

void loop() {
  // Read analog sensor on pin A0
  int sensorValue = analogRead(A0);  // Returns 0-1023

  // Convert to voltage (10-bit ADC, 5V reference)
  float voltage = sensorValue * (5.0 / 1024.0);

  // Convert to temperature (TMP36 sensor: 500mV offset, 10mV/C)
  float temperatureC = (voltage - 0.5) * 100;

  Serial.print("Sensor: ");
  Serial.print(sensorValue);
  Serial.print(" | Voltage: ");
  Serial.print(voltage);
  Serial.print("V | Temp: ");
  Serial.print(temperatureC);
  Serial.println("C");

  delay(1000);  // Read every second
}

Resolution: Each step = 5V / 1024 = 4.88mV

16.11.2 Complete ADC Workflow Visualization

The following diagram shows the complete signal path from sensor to digital value:

Complete ADC signal path from physical sensor measurement through signal conditioning, analog-to-digital conversion, and digital processing to calibrated output value

Complete ADC Signal Path
Figure 16.10: From physical measurement through signal conditioning, conversion, and digital processing to final calibrated value.

Common Misconception: “Higher ADC Resolution Always Means Better Measurements”

The Myth: Many IoT developers believe that using a 16-bit ADC instead of a 12-bit ADC automatically improves measurement accuracy.

The Reality: Sensor accuracy, not ADC resolution, is the limiting factor in 83% of IoT applications.

Real-World Example - Soil Moisture Monitoring:

A 2019 agricultural IoT study found that upgrading from 12-bit to 16-bit ADCs provided zero measurable improvement in 83% of installations because:

  • Capacitive soil moisture sensors: +/-2% accuracy (66mV error at 3.3V)
    • 12-bit ESP32: 0.806mV resolution (82x finer than sensor accuracy)
    • 16-bit ADS1115: 0.0503mV resolution (1,312x finer than sensor accuracy)
    • Result: Both ADCs capture the same sensor limitations

When 16-bit ADC Actually Matters (the 17% where it helps):

  • Thermocouples: Type K generates 41uV/C → 16-24 bit ADC essential for 0.1C resolution
  • Load cells (precision weighing): 0.01% accuracy requires uV-level precision
  • Medical ECG: 1mV signals need high resolution to detect subtle arrhythmias
  • pH sensors: 59mV/pH unit → 16-bit ADC needed for 0.01 pH resolution

Best Practice: Match ADC resolution to sensor accuracy - don’t waste money on 16-bit ADCs for +/-2-5% accuracy sensors!



16.12 Real-World IoT ADC Applications

Understanding ADC requirements helps you select the right hardware for your IoT projects. Here’s how different applications map to ADC specifications:

Basic ADC circuit configuration showing analog input, reference voltage, and digital output connections for common IoT sensor applications

IoT Application ADC Requirements
Figure 16.11: Match your sensor application to the appropriate ADC type based on accuracy needs and signal bandwidth.
Application Category Example Sensors Recommended ADC Typical Cost
Basic Monitoring DHT22, LDR, capacitive soil Built-in 10-12 bit $0 (integrated)
Precision Measurement Load cells, thermocouples, pH External 16-24 bit (HX711, ADS1115) $2-8
High-Speed Sampling Audio, vibration, current sense Fast 12-14 bit SAR (MCP3208) $3-15
Industrial Grade Process control, calibration 18-24 bit (ADS1256) $10-50


This example demonstrates the complete decision process for choosing ADC specifications based on application requirements.

Scenario: Design a temperature data logger for a laboratory freezer that must: - Measure -80°C to +20°C range (100°C span) - Detect temperature changes of 0.1°C or better - Log readings every 10 seconds for 7 days continuously - Use a thermocouple (Type K: 41 µV/°C sensitivity)

Step 1: Calculate Required Voltage Resolution

Type K thermocouple generates 41 µV per °C. To detect 0.1°C changes: - Minimum voltage step = 0.1°C × 41 µV/°C = 4.1 µV per step

Step 2: Determine ADC Bit Depth

The 100°C temperature span generates: - Total voltage range = 100°C × 41 µV/°C = 4,100 µV = 4.1 mV

To achieve 4.1 µV resolution across 4.1 mV range: - Required steps = 4.1 mV / 4.1 µV = 1,000 steps - Required bits = log₂(1000) = 9.97 bits → Round up to 10-bit minimum

But this ignores noise! With noise, we need 2-3 bits extra headroom.

Better approach: Use 16-bit ADC with appropriate voltage reference.

Step 3: Select Voltage Reference

A 16-bit ADC with 3.3V reference gives: - Voltage per step = 3.3V / 65,536 = 50.35 µV/step

This is 12× coarser than our 4.1 µV requirement!

Solution: Use a lower voltage reference matched to signal range: - With 10 mV reference voltage: 10 mV / 65,536 = 0.15 µV/step ✓ (exceeds 4.1 µV requirement)

Step 4: Choose ADC Architecture

ADC Type Resolution Speed Suitability
ESP32 built-in SAR 12-bit ~12 µs ✗ Insufficient resolution for µV signals
ADS1115 (Sigma-Delta) 16-bit 8 ms ✓ Good resolution, but 8ms is slow
ADS1256 (Sigma-Delta) 24-bit 33 ms @ 30 SPS ✓✓ Ideal for thermocouples

Decision: ADS1256 24-bit ADC - Resolution: 24-bit = 16.7 million levels - With 2.5V reference: 2.5V / 16,777,216 = 0.149 µV/step (30× better than requirement) - Built-in programmable gain amplifier (PGA) boosts µV signals - Sampling rate: 30 SPS sufficient for 10-second logging interval

Step 5: Verify Quantization Error

Quantization error = ±(Vref / 2^(n+1)) - For ADS1256: ±(2.5V / 2^25) = ±0.0745 µV - Temperature error = 0.0745 µV / 41 µV/°C = ±0.0018°C (far exceeds 0.1°C requirement)

Step 6: Final BOM and Justification

Component Cost Justification
ADS1256 24-bit ADC $15 Only ADC with sufficient µV resolution for Type K thermocouple
Type K Thermocouple $8 Low-cost, wide range (-270°C to +1372°C covers -80°C to +20°C)
2.5V Precision Vref (REF5025) $3 ±0.05% accuracy eliminates gain errors
ESP32 (Logging) $5 Logs to SD card, built-in Wi-Fi for data upload
Total $31 Justified by 0.1°C accuracy requirement

Alternative Rejected: Using ESP32’s built-in 12-bit ADC with RTD sensor - RTD (PT100) generates ~0.385 Ω/°C → requires Wheatstone bridge → complexity - 12-bit resolution insufficient for 0.1°C at this voltage range - Would need external amplifier anyway, negating cost savings

Key Lesson: Sensor output voltage and required precision dictate ADC specifications. Don’t try to force a built-in 12-bit ADC to do a 24-bit ADC’s job!

The big picture: A successive approximation register (SAR) ADC performs a 12-step binary search to determine which of 4,096 discrete voltage levels most closely matches the analog sensor input.

Step-by-step breakdown:

  1. Sample and Hold: Capture the instantaneous sensor voltage (e.g., 2.0V from temperature sensor) and hold it stable - Real example: ESP32 samples in microseconds
  2. Binary Search Iteration: Test each bit from MSB to LSB using an internal DAC - Real example: For 2.0V input with 3.3V reference, bit 11 sets to 1 (test 1.65V < 2.0V), bit 10 sets to 0 (test 2.475V > 2.0V)
  3. Digital Output: After 12 comparisons, output binary value represents closest quantization level - Real example: Final output 100110110001 (decimal 2481) → 2481 × (3.3V / 4096) = 1.999V (reconstructed from 2.0V input)

Why this matters: Understanding that ADC resolution (4,096 steps) is independent of reference voltage (3.3V max) prevents common mistakes like trying to measure 12V directly on an ESP32 without a voltage divider.

Concept Relationships: ADC and Signal Processing
Concept Relates To Relationship
ADC Resolution Nyquist Sampling Resolution determines voltage precision, sampling rate determines time precision
Quantization Error Sensor Calibration Calibration corrects offset/gain errors, but cannot eliminate quantization noise
SAR Architecture Power Budget Microsecond-scale conversion with minimal current draw per reading - faster than sigma-delta but lower resolution

Cross-module connection: Nyquist Sampling Theory - Explains how fast to sample based on signal frequency (complements ADC resolution)

16.13 Summary

This chapter covered Analog-to-Digital Converters (ADCs) - the essential bridge between analog sensors and digital microcontrollers.

16.13.1 Key Takeaways

Concept Key Point Practical Implication
ADC Function Converts continuous voltage to discrete digital values Every analog sensor needs an ADC to communicate with microcontrollers
Resolution Bit depth determines precision: 10-bit = 1,024 levels, 12-bit = 4,096 levels Higher resolution ≠ always better; match to sensor accuracy
Quantization Error Inherent error = Vref / 2^(n+1) 12-bit @ 3.3V = +/-0.4mV max error per sample
SAR Architecture Binary search algorithm, microsecond-scale conversion Standard in ESP32, STM32, Arduino - good for most IoT sensors
Sigma-Delta Oversampling + decimation, 8ms+ conversion Use for precision (load cells, thermocouples, pH sensors)
Noise Mitigation RC filter + averaging + proper grounding Software averaging (16-64 samples) is free and effective

16.13.2 Decision Framework

ADC selection decision tree starting from sensor accuracy requirements, branching by signal speed to recommend built-in SAR ADC for general IoT sensors or external sigma-delta ADC for precision measurements like thermocouples and load cells

ADC Selection Decision Tree
Figure 16.12: Start with sensor accuracy requirements, then consider signal speed to choose the appropriate ADC architecture.

Common Pitfalls

Sampling a signal at less than twice its highest frequency folds high-frequency content down into the baseband, producing false low-frequency artefacts. Always place an anti-aliasing low-pass filter before the ADC input and ensure the sample rate is at least 2× the maximum signal frequency.

The microcontroller supply voltage (3.3 V or 5 V) fluctuates with load current and decoupling quality. Using it as the ADC reference makes all readings noisy and supply-dependent. Use a dedicated precision voltage reference IC for accuracy-critical applications.

ADC input sample-and-hold capacitors need time to charge fully via the source impedance. A high-impedance sensor connected directly to the ADC will produce low or inaccurate readings. Buffer high-impedance sources with a unity-gain op-amp before the ADC input.

A 12-bit ADC has 4096 levels (resolution) but its effective number of bits (ENOB) may be only 10 due to noise, offset, and nonlinearity. Datasheet resolution is a theoretical maximum; measure actual noise floor and compare to required accuracy before selecting an ADC.

16.14 What’s Next?

Now that you understand ADC fundamentals, you have a critical question to answer: How fast should you sample? The Nyquist-Shannon Sampling Theorem provides the answer - and getting it wrong causes “aliasing” that makes your data completely wrong.

ADC conversion complete signal flow showing from sample-and-hold through conversion to output register

ADC Conversion Complete
Figure 16.13

Continue to Nyquist Sampling Theory →

Learning Path - Analog/Digital Series:

Chapter Focus When to Read
Binary Fundamentals Number systems, 2’s complement Before ADC if binary math is unfamiliar
ADC Fundamentals (this chapter) Resolution, architectures, noise Core knowledge for all sensor projects
Nyquist Sampling Theory Sample rates, aliasing Next - critical for time-varying signals
ADC/DAC Worked Examples Calculations, code examples After Nyquist - practice problems
DAC and PWM Output Generating analog from digital For actuator control applications

Foundation Chapters (if needed):

Hands-On Practice:

Interactive Tools:

  • Sensor Calibration Tool - Interactive tool to correct ADC offset and gain errors
  • ADC Resolution Visualizer - See how bit depth affects quantization of analog signals