36 ADC and DAC: Interactive Design Calculators
36.1 Start With the Decision
A converter setting changes counts, volts, and error at once. Move one control and check each result against the formula.
36.2 Route Overview
This is part 2 of 2. Review ADC and DAC: Conversion Calculations for the preceding evidence.
36.3 Learning Objectives
- Calculate interactive calculators from stated measurements and limits.
- Measure ground current path omitted from current, time, and transition evidence.
36.4 Chapter Roadmap
- Interactive Calculators
- Match ADC/DAC Definitions
- ADC Conversion Step Quiz
- Label the Diagram
- Code Challenge
- ADC Resolution and Vref
- Reference: ESP32 Pinout, Power, and Signal Formula Cheat Sheet
- ADC Resolution and Vref Contracts
- Summary
- See Also
- Common Pitfalls
- Convert Units Before Solving
- Check Result Plausibility
- Component Tolerance Matters
- Ground Current Path Omitted
- What’s Next?
36.5 Interactive Calculators
Try the formulas from this chapter yourself. Adjust the sliders and inputs to see how ADC output, quantization error, DAC voltage, gamma correction, Nyquist sampling rates, and oversampling resolution change in real time.
36.5.1 ADC Conversion Calculator
36.5.2 DAC Output Calculator
36.5.3 Gamma Correction Calculator
36.5.4 Nyquist Sampling Rate Calculator
36.5.5 Oversampling Resolution Calculator
36.6 ADC Resolution and Vref
The worked examples above show how to convert ADC codes, sensor voltages, sampling rates, DAC outputs, and PWM tables step by step. A design review also needs one compact ledger: what does one ADC count mean in the sensor’s own units, and is that resolution meaningful compared with the sensor’s accuracy?
For the layered engineering checks, continue to ADC Resolution and Reference Voltage Contracts. It works through LSB size, sensor sensitivity, reference-voltage span, quantization error, and the point where more ADC bits stop improving the measurement.
36.7 Reference: ESP32 Pinout, Power, and Signal Formula Cheat Sheet
36.7.1 Interactive Formula Reference
36.7.1.1 Interactive Calculators
36.7.2 Formula Cards
Trace One Pin Before Trusting a Formula
Picture an ESP32 reading a tank level, driving a control voltage, and sending a short status line to a service tool. A correct equation cannot rescue a pin that is wired to the wrong function or outside its safe range.
An analog-to-digital converter is a circuit that turns a voltage into a number. ADC is its short name. DAC means a digital-to-analog converter that turns a number into a voltage. I2C is a shared two-wire link for nearby parts. SPI is a clocked link with separate data paths. UART is a simple serial link that sends timed bits between two endpoints.
Mark the chosen pins, reference voltage, units, and expected range. Test the low, middle, and high points, swap one wire while power is safe, restart the board, and compare the physical input with the recorded number. Reject any result that lacks a pin identity or unit.
This runway does not certify a board, radio link, or battery life. The cards below provide compact calculations and pin facts; the surrounding chapters explain tolerances, loading, timing, protection, and field measurement.
Let’s design a LoRaWAN sensor for EU868 using the formulas above. Goal: 5-year battery life on 2× AA batteries (2400 mAh).
Step 1: Choose spreading factor
- Urban environment, gateway at 500m
- Free Space Path Loss:
- Link budget:
- SF7 sensitivity is -123 dBm → link margin = → SF7 works comfortably
Step 2: Calculate airtime and duty cycle
- Payload: 12 bytes, SF7 → airtime ≈ 40 ms
- EU868 duty cycle: 1% = 36 seconds TX per hour max
- Messages allowed per hour: messages/hour max
- We want 1 message every 10 minutes = 6 messages/hour → well within duty cycle (OK)
Step 3: Battery life calculation
Average current:
Battery life: (OK)
Key insight: TX energy actually dominates, not sleep! The device spends 99.99% of its time asleep, but the 30 mA TX burst is 30,000× the 1 µA sleep current, so each 40 ms transmission moves about as much charge as the entire ~10-minute sleep interval around it: TX supplies roughly 66.7% of the average current versus 33.3% from sleep. That is why reducing sleep current from 1 µA to 0.5 µA only gains about 14.6 years (life rises to ≈87.7 years), while reducing TX power from 14 dBm to 10 dBm (15 mA) gains far more, about 36.5 years (life rises to ≈109.6 years) — because it cuts the term that actually dominates.
36.7.3 Pin-Out Reference
36.7.3.1 ESP32 Quick Reference
36.7.4 Conversion Tables
Scenario: You need to connect a DHT22 temperature sensor, an I2C OLED display, and monitor battery voltage on an ESP32.
Step 1: Identify Required Interfaces
- DHT22: 1-wire digital protocol (needs any GPIO)
- OLED: I2C interface (needs SDA + SCL)
- Battery voltage: Analog input (needs ADC)
Step 2: Consult Pin-Out Reference
- I2C (default): SDA=GPIO21, SCL=GPIO22
- Decision: Use default I2C pins for OLED (no conflicts, easier debugging)
- ADC (12-bit): GPIO32-39 (ADC1), GPIO0,2,4,12-15,25-27 (ADC2)
- Note: ADC2 unavailable when Wi-Fi active
- Decision: Use GPIO34 (ADC1_6) for battery voltage - available while Wi-Fi is active, but input-only and without an internal pullup
- DHT22 data pin: Needs any free GPIO
- Avoid: GPIO0,2,4,5,12,15 on typical ESP32 boards (strapping pins can affect boot)
- Avoid: GPIO34-39 (input-only, can’t use internal pullup)
- Decision: Use GPIO16 when it is exposed on the chosen board and not reserved by another peripheral
Step 3: Validate No Conflicts
- GPIO16 (DHT22): Available in this example board, not used by I2C or ADC
- GPIO21/22 (OLED I2C): Default I2C, no conflicts
- GPIO34 (battery ADC): ADC1, works with Wi-Fi enabled
Step 4: Reference Formulas for ADC
- From formula card:
ADC Resolution = Vref / 2^bits - ESP32: 12-bit ADC, 3.3V reference
- Step size: 3.3V / 4096 = 0.8mV per step
- For 0-5V battery (using voltage divider): Divider ratio = 5V/3.3V = 1.52
- Use 10kΩ and 15kΩ resistors: (15kΩ/(10kΩ+15kΩ)) × 5V = 3V at GPIO34
Step 5: Code Pattern from Reference
# From Moving Average Pattern (reference card)
battery_filter = MovingAverage(window=10)
# From Sensor Reading Pattern (reference card)
def read_dht22_with_retry():
for attempt in range(3):
try:
temp, humidity = dht.read()
if temp > -40 and temp < 80: # Valid range
return temp, humidity
except:
time.sleep(0.1 * (2 ** attempt))
return None, None
Result: Complete wiring plan and code skeleton in 5 minutes by referencing the Quick Reference Cards instead of searching through 4 different chapter pages and datasheets.
Time Saved: Without reference cards: 20-30 minutes (find I2C chapter, find ADC chapter, look up strapping pins, search for code patterns). With reference cards: 5 minutes (scan one page, make decisions).
36.8 ADC Resolution and Vref Contracts
36.8.1 Start Simple
Map One Code Step to a Real Decision
Picture a pressure sensor used to decide whether a filter needs service. More converter bits help only when one code step is smaller than the physical change the decision must detect and the rest of the measurement path is good enough.
An analog-to-digital converter is a circuit that turns a measured voltage into a number; ADC is its short name. A digital-to-analog converter is a circuit that turns a number into an output level; DAC is its short name. Pulse-width modulation is rapid on-off switching that varies average drive; PWM is its short name.
Apply known low, middle, and high inputs. Record reference voltage, bit depth, code step, sensor scale, noise, calibration result, and service threshold. Change the reference, repeat a boundary value, and restart. Reject precision that exists only in displayed digits.
This runway does not prove accuracy from resolution alone. The deeper sections cover volts per step, physical units per step, measurable span, quantisation error, reference choice, and when a better sensor matters more.
Imagine a pressure sensor whose datasheet says it changes only a tiny amount for each physical unit. ADC resolution matters only if one code step is smaller than the change the product needs to detect, and accuracy still depends on the sensor, reference, noise, and calibration. Start with LSB size, units per step, and the real-world decision threshold.
36.8.2 Learning Objectives
After this page, you should be able to:
- Convert ADC bit depth and reference voltage into volts per step.
- Convert volts per step into sensor units using a sensor sensitivity.
- Compare reference-voltage choices by resolution and measurable span.
- Estimate quantization error from the selected ADC step size.
- Decide when extra ADC resolution is below the sensor’s accuracy and therefore not useful.
36.8.3 Why This Follows ADC/DAC Worked Examples
An oscilloscope view ties ADC and DAC calculations back to the voltage-versus-time signal available at the bench.
Use the photograph to challenge any assumption that the logical block alone captures the complete field system.
ADC/DAC Worked Examples teaches the formula-by-formula workflow for converter calculations, sampling, DAC output, PWM approximation, and verification. This page turns those examples into a measurement contract: each count must map to a physical unit, and the chosen reference and bit depth must match the sensor’s real range and accuracy.
Use it when a project is choosing an ADC reference, claiming a temperature resolution, comparing 12-bit and 16-bit converters, or deciding whether calibration and a better sensor matter more than more converter bits.
36.8.4 Overview: Turn “Bits” Into the Sensor’s Own Units
"12-bit" tells you nothing useful on its own. What a design actually cares about is resolution in the physical quantity being measured — degrees, pascals, g’s. The bridge is a two-step chain any datasheet lets you compute:
- Volts per step:
LSB = Vref / 2^N. - Units per step: divide the LSB by the sensor's sensitivity (its volts-per-unit).
The release contract should record each link in that chain rather than only the final headline resolution. Capture the sensor output range, sensitivity, chosen reference, ADC bit depth, volts per code, units per code, quantization error, and the accuracy band claimed by the sensor or calibration procedure. That record makes it obvious whether the extra digit is earned or just printed.
And the measurement span is range = Vref / sensitivity. With those two lines you can state exactly what a sensor-plus-ADC pair resolves before touching hardware.
Before accepting a bit-depth claim, inspect Figure 36.1 to translate converter codes into voltage steps and then into the sensor’s physical units.
Read Figure 36.1 from 8 bits through 12 bits to 16 bits. Each increase enlarges the codebook and reduces the ideal voltage step, but it can also demand more conversion time, power, and analogue quality. Map the chosen step through sensor sensitivity next, then compare it with reference noise, front-end noise, and sensor accuracy. That order connects a headline bit count to the physical resolution the measurement chain can actually defend.
That is the evidence reviewers need when a dashboard shows one more decimal place than the measurement chain can defend.
The reference-voltage decision is also a range decision. A smaller reference gives finer codes, but it also lowers the largest voltage the ADC can report without clipping. For a field device, leave room for tolerance stack-up: sensor maximum, calibration offset, resistor-divider tolerance, supply variation, and credible fault values. The useful contract is not "12-bit at 1.1 V"; it is "this sensor's accepted range maps to these codes, with this much headroom, and each code is worth this many physical units."
Step 1 — LSB
Vref / 2^N. For 12-bit at Vref = 3.3 V: 3.3 / 4096 = 0.806 mV.
Step 2 — units/step
Divide by sensitivity. An LM35 gives 10 mV/°C, so 0.806 / 10 = 0.0806 °C per step.
Span
Vref / sensitivity. Here 3.3 V / (10 mV/°C) = 330 °C of ADC coverage.
Resolution ≠ accuracy
A fine step does not beat the sensor's own tolerance. The LM35 is only about ±0.5 °C accurate.
A good review therefore asks two questions in order: first, is the code step small enough to see the smallest meaningful change; second, is the claimed change larger than the sensor, reference, and calibration uncertainty. If the first answer is no, adjust reference, gain, or bit depth. If the second answer is no, more bits will only create more-looking numbers.
36.8.4.1 Overview Knowledge Check
36.8.5 Practitioner: A Reference-Voltage Ledger
Because resolution scales with Vref, the single most effective lever on a small-signal reading is choosing the smallest reference that still spans the range you need. Here is the same LM35 at 12-bit under two references:
| Reference | LSB = Vref / 4096 | Resolution (/10 mV/°C) | ADC span (Vref / 10 mV/°C) |
|---|---|---|---|
| 3.3 V (supply) | 0.806 mV | ~0.081 °C per step | 0 – 330 °C |
| 1.1 V (internal ref) | 0.269 mV | ~0.027 °C per step | 0 – 110 °C |
Dropping from a 3.3 V to a 1.1 V reference makes each step three times finer (0.081 → 0.027 °C) at the cost of a smaller span (330 → 110 °C). Since the LM35 tops out near 150 °C anyway, and few IoT enclosures approach that, the 1.1 V reference is usually the better trade. The quantization error is ±0.5 LSB, so at 3.3 V that is ±0.04 °C.
The ledger should also reserve headroom. If the real input can exceed the nominal range during startup, fault, calibration, or hot ambient conditions, the narrow reference may clip exactly when the diagnostic needs the reading most. The practical acceptance test is to sweep the expected minimum, nominal, maximum, and fault-adjacent values and confirm that all accepted values stay inside the ADC range with margin.
Reference choice is therefore a measured hardware decision, not only a spreadsheet decision. Record whether the reference comes from a regulator rail, internal bandgap, external precision reference, or ratiometric sensor excitation, and verify that its tolerance and drift are smaller than the improvement you expect from the finer code step.
The rule generalizes: pick the smallest reference (or add gain ahead of the ADC) that still covers your real-world range, and you buy resolution for free — provided the reference is a clean, stable one rather than a noisy supply rail.
36.8.5.1 Practitioner Knowledge Check
36.8.6 Under the Hood: Don’t Buy Resolution the Sensor Can’t Use
It is tempting to chase more bits. A 16-bit ADC at 3.3 V has an LSB of 3.3 / 65536 ≈ 50 µV, or about 0.005 °C per step on the LM35 — sixteen times finer than the 12-bit case. But the LM35 itself is only accurate to about ±0.5 °C. Those extra bits report changes far smaller than the sensor's own error, so they add digits that are not real information.
This is the resolution-versus-accuracy ceiling stated numerically: resolution is how finely you can distinguish, accuracy is how close you are to the truth. Past the point where one step is comfortably smaller than the sensor's tolerance (a common rule of thumb is a few steps per accuracy band), extra ADC bits buy nothing but noise and data. The right move when you truly need more accuracy is a better sensor, a stable reference, calibration, and averaging — not simply a wider converter.
Under the hood, every code is compared against a reference that has its own tolerance, drift, and noise. If that reference moves by the equivalent of ten ADC counts over temperature, a one-count LSB calculation is not the limiting error anymore. The same is true for amplifier offset, sensor self-heating, PCB leakage, and supply coupling. The resolution contract should name the dominant error term instead of assuming quantization is always dominant.
The acceptance evidence is a small uncertainty budget: quantization error, reference tolerance, reference drift, front-end noise, calibration residual, and sensor tolerance in the same physical units. Once those terms are listed side by side, the decision becomes concrete: keep the cheaper converter, lower the reference, add gain, improve calibration, or buy a sensor whose accuracy actually justifies the extra bits.
36.8.6.1 Under-the-Hood Knowledge Check
36.9 Summary
This chapter provided step-by-step worked examples for ADC and DAC calculations:
Read these conclusions as one connected engineering argument: ADC Conversion Formula: Digital Output = floor((Vin / Vref) x (2^n - 1)). Temperature Sensor: Match Vref to sensor range for optimal resolution. Quantization Error: +/-(Vref / 2^(n+1)) is the inherent measurement uncertainty. Nyquist Calculations: f_sample >= 2 x f_max for accurate digitization. DAC Output: V_out = Vref x (Digital Input / (2^n - 1)). Gamma Correction: Apply non-linear mapping for perceptually-correct LED dimming. Real-World Applications: Soil moisture, ultrasonic distance, motor control.
These formulas and examples form the practical foundation for sensor interfacing in IoT systems.
36.10 See Also
Within This Series:
Follow these connections in order: Analog-Digital Electronics Overview - Complete ADC/DAC series roadmap; ADC Fundamentals - Theory behind analog-to-digital conversion; Nyquist Sampling - Detailed sampling rate calculations; DAC and PWM Output - Digital-to-analog conversion methods.
Related Sensors:
Follow these connections in order: Sensor Fundamentals and Types - TMP36, LM35, thermistors, and other sensor types; Sensor Circuits and Signals - Photoresistors, photodiodes, and analog signal handling; Sensor Interfacing and Processing - Connecting analog sensors to microcontrollers.
Practical Application:
Follow these connections in order: Signal Conditioning - Amplification, filtering, level shifting; PWM and Actuator Control - PWM motor speed control and servo positioning.
External Resources:
Follow these connections in order: TI ADC Selection Guide - Choosing the right ADC for your application; Microchip AVR ADC App Note - Practical ADC design techniques; SparkFun ADC Tutorial - Beginner-friendly ADC examples.
Common Pitfalls
A calculation using kOhm, mA, and V (mixing kilo-prefix with base units) produces an answer 1000x too large or too small. Always convert all values to SI base units (Ohm, A, V) before substituting into formulas, then convert the result back to convenient units for the answer.
A LED resistor calculation yielding 0.3 ohm should immediately raise a concern — that would allow 10 A through a standard LED, destroying it. Always sense-check computed values: resistances should be between ohms and megaohms, currents should be microamps to amps, voltages should be millivolts to tens of volts for typical IoT circuits.
Resistors have tolerances (typically +-1% to +-5%). A 10 kohm 5% resistor may be 9.5-10.5 kohm. For a voltage divider, this translates to +-5% error in the output voltage. For precision circuits (ADC references, calibration circuits), use 1% or 0.1% tolerance resistors and verify the circuit’s sensitivity to component variations.
Every current that flows into a circuit must return to the source through the ground path. Analyzing only the forward signal path while ignoring the ground return path leads to missed design issues: shared ground impedance causing crosstalk, inadequate ground plane copper causing voltage drops, and missing return current paths causing incorrect voltage measurements.
36.11 What’s Next?
Now continue to learn about Digital-to-Analog Converters (DACs) and PWM output for actuator control.
| Direction | Chapter | Topic |
|---|---|---|
| Previous | ADC Fundamentals | Theory behind analog-to-digital conversion |
| Previous | Nyquist Sampling | Sampling rate requirements and aliasing |
| Current | ADC/DAC Worked Examples | Step-by-step conversion calculations |
| Next | DAC and PWM Output | Digital-to-analog conversion and PWM control |
| Next | Analog-Digital Electronics Overview | Complete ADC/DAC series roadmap |
36.12 Continue Your Route
This final part closes the route from Interactive Calculators through What’s Next?. Return to ADC and DAC: Conversion Calculations or continue from the electronics module index.
