Recipe
Turn an ADC reading into a real-world value
Use when: firmware has a raw ADC code and needs a voltage, or the temperature, light level or battery voltage behind it
Goal: the quantity the sensor measures, with the arithmetic in the right order
Taught in How an ADC works
Quick recipe
-
1
Note n and V_{ref} as the firmware sets them, and which step convention you are using.
Example
Uno R4 Minima at its default 10 bits; suppose a 5 V reference: step = 5/1024 \approx 4.88 mV.
Why: the same code means different voltages at different settings.
-
2
Multiply the code by one step.
Example
Code 614: 614 \times 5/1024 \approx 3.00 V.
Why: the code counts whole steps up from 0 V.
-
3
If a divider scaled the signal down, divide by its ratio k = R_2/(R_1 + R_2).
Example
A 1/3 divider: 3.00 / (1/3) = 9.0 V at the battery.
Why: the ADC measured the divider's output, not the original voltage.
-
4
Use the datasheet's relation between volts and the quantity.
Example
A sensor at 10 mV per °C reading 0.90 V, with 0.75 V meaning 25 °C: 25 + (0.90 - 0.75)/0.010 = 40 °C.
Why: the sensor's datasheet, not the ADC, defines what a voltage means.
Common mistakes
- Using 3.3 V or 5 V as the reference without checking what the firmware set.
- Forgetting the divider, and reporting the pin voltage as the battery voltage.
- Mixing the 2^n and 2^n − 1 conventions inside one calculation.