Recipe
Calibrate a sensor with two reference points
Use when: a sensor's readings are steadily off, and you can put it beside two known values
Goal: a gain and an offset that turn every raw reading into a corrected one
Taught in Calibration
Quick recipe
-
1
Choose two known values near the ends of the range you care about. Use a trusted reference: ice water for 0 °C, a calibrated thermometer, a multimeter for volts.
Example
Ice water (0.0 °C) and warm water beside a reference thermometer (40.0 °C).
Why: the farther apart the points, the less a small error in either one tilts the line.
-
2
Wait until both sensor and reference stop changing. Average several raw readings at each point.
Example
Raw averages 0.8 °C in the ice water and 41.1 °C in the warm water.
Why: a sensor reading on its way to a new temperature isn't at the reference value yet.
-
3
\text{gain} = (\text{ref}_2 - \text{ref}_1)/(\text{raw}_2 - \text{raw}_1), in decimals.
Example
(40.0 - 0.0)/(41.1 - 0.8) = 40/40.3 \approx 0.9926.
Why: the gain is how much the true value changes for each unit of raw change.
-
4
\text{offset} = \text{ref}_1 - \text{gain} \times \text{raw}_1.
Example
0.0 - 0.9926 \times 0.8 \approx -0.794.
Why: it puts the line through the first point; the gain already makes it pass through the second.
-
5
Apply the correction at a value you didn't calibrate with, and compare with the reference.
- within the reference's own accuracy — done; record the constants, the date and the references used.
- still off — the error isn't a straight line, or a reading wasn't settled; repeat, or calibrate a narrower range.
Why: two points always fit a line exactly, so only a third point tests it.
Common mistakes
- Using integer arithmetic for the gain, which rounds 40/40.3 down to 0.
- Choosing two references close together, so a small slip makes a large gain error.
- Calibrating a raw thermistor resistance as if it were a straight line.
- Swapping the order, so the gain comes out as raw over reference.