Better Analogue Measurements with SAMD21: Resolution, References and Calibration
A SAMD21 board offers more ADC resolution than a classic 10-bit Arduino, but extra digits do not automatically produce a better measurement. A slowly changing sensor can still give unstable results, a stable reading can still be wrong, and a beautifully averaged signal can hide an input that is clipping.
The useful goal is a measurement chain whose behaviour you can explain: sensor, input circuit, ADC configuration, conversion to engineering units and display. The compact Zero-compatible SAMD21 board provides a practical platform for exploring that chain. Verify its installed board core and pin map rather than assuming every feature of a full-size Arduino Zero is present.
Separate resolution, repeatability and accuracy
Resolution describes the available output steps. Repeatability describes how consistently the system reports the same input. Accuracy describes how close the result is to the quantity being measured. These properties interact, but they are not interchangeable.
A 12-bit conversion has 4096 possible codes. For an idealised 3.3 V full-scale span, one code step is approximately 3.3 / 4096, or 0.806 mV. That calculation describes nominal quantisation; it does not establish that the system measures voltage to within 0.806 mV.
Analog Devices' guide to ADC errors explains how offset, gain, nonlinearity and reference errors affect accuracy. Keep the displayed precision consistent with your tested uncertainty. A temperature display showing three decimal places is unhelpful if the complete sensor system is only trustworthy within a much wider interval.
Select the intended Arduino resolution
Arduino's analogReadResolution() reference explains that supported boards can return different result widths. The standard Zero/SAMD Arduino implementation supports 12-bit readings, while the compatibility default is commonly 10 bits. Set the resolution explicitly rather than relying on a previous sketch or an assumed default:
void setup() {
analogReadResolution(12);
}
Confirm that the selected board package implements the function as expected. Arduino's SAMD analogue core source is the primary reference for its behaviour. Requesting more output bits than the hardware provides does not create additional measured information.
Update thresholds and scaling when changing resolution. A raw threshold of 500 has a very different meaning in a 0–1023 range than in a 0–4095 range. Put the resolution choice and conversion constants together so they cannot quietly drift apart.
Protect the input and define its range
The linked SAMD21 board operates with 3.3 V I/O and is not a direct destination for a 5 V sensor output. Determine the sensor's minimum, maximum and fault output, then design suitable scaling or buffering. Check behaviour when the sensor remains powered while the microcontroller is off.
Do not assume a nominally 3.3 V sensor always stays inside the permitted ADC input range. The ADC reference and gain configuration can make its measurement span narrower than the board's supply voltage. Conversely, selecting a different reference does not increase the pin's safe electrical limits.
For a resistor divider, calculate both the ratio and the source resistance seen by the ADC. Then account for resistor tolerance and the maximum possible source voltage. A divider that fits the expected reading exactly against full scale leaves no margin for tolerance or unusual conditions.
Allow the sampling circuit to settle
The ADC input is not simply an infinite-resistance voltmeter. During acquisition, the source must charge an internal sampling capacitance. Microchip's SAM D21/DA1 datasheet describes the relationship between source resistance and sample-and-hold time.
This matters with high-value dividers, some sensors and rapid switching between channels. Use the exact device's acquisition requirements and the core's configuration. A suitable buffer or longer acquisition time may be needed; adding an arbitrary delay elsewhere in the loop is not necessarily the same as extending the ADC's acquisition window.
A practical diagnostic is to compare a channel measured repeatedly with the same channel measured immediately after another channel at a very different voltage. If the result depends on the previous channel, investigate settling and configuration before trying to hide the effect with averaging.
Characterise the reference and grounding
Record which reference configuration the programme uses. A scale factor copied from another board may assume a supply or reference that is different from your actual circuit. Measure relevant rails using an appropriate instrument and repeat the measurement with displays, radios and other loads active.
Use deliberate signal returns. A sensor return sharing a resistive path with a changing load can shift the voltage seen by the ADC even when the sensor itself is stable. Keep test leads short and the arrangement repeatable while diagnosing small changes.
Begin with a known steady input safely inside the allowed range. Collect a few hundred raw readings and record the minimum, maximum and mean. Repeat after the board warms up and after changing its power source. These observations are more informative than watching the final rounded display value.
Use averaging for the right problem
Averaging can reduce suitable random variation, but it trades response speed for a steadier result. It cannot repair an incorrect scale factor, a saturated input or a systematically unsettled sample. Analog Devices' discussion of ADC input noise explains the conditions under which averaging can reveal more useful resolution.
Choose the averaging interval from the application. A room-temperature logger can tolerate a slower update than a knob controlling an interactive demonstration. Test a deliberate step in the input and measure how long the displayed result takes to respond. Keep raw readings available during development so filtering does not conceal faults.
Calibrate, then check a separate point
For an approximately linear measurement chain, two known inputs can establish a slope and offset. If raw readings r1 and r2 correspond to known values x1 and x2, an application-level conversion is:
x = x1 + (raw − r1) × (x2 − x1) / (r2 − r1)
Use suitable numeric types and reject the invalid case where r1 equals r2. Choose calibration points within the intended operating range, allow readings to settle and record the conditions. This conversion is not a replacement for the device's required factory calibration handling.
Check a third known point that was not used in calibration. A large error there can reveal nonlinearity or a flawed test setup. Repeat at representative operating temperatures if the project requires that range.
When selecting SAMD21 boards, consider access to analogue pins and documentation as well as processor speed. A measured error budget and repeatable validation make the extra ADC resolution useful.