1.Why should I care?
Real sensors differ from their datasheets and from each other. Calibration measures your actual sensor against things whose values you know, so your machine reports the truth. It is how scientific instruments, kitchen scales and weather stations are kept honest.
- ◇ Convert a raw reading to a physical quantity with a two-point calibration.
- ◇ Calculate the calibration's slope and offset from two reference points.
- ◇ Explain why calibration points should span the range you care about.
Safety: Simulation only. Boiling water scalds: in the apply challenge, use safe reference temperatures and a trusted thermometer instead.
2.Predict
A sensor reads 100 counts at 0 °C and 900 counts at 100 °C. It now reads 500. Assuming a straight line, what is the temperature?
Guess first. Being wrong here is how the surprise works.
3.Discover
Set the ice and boiling readings for your imaginary sensor, then move the new reading. Find the raw reading that means 18 °C. Then drag the new reading below the ice point: what does the readout warn you about?
Loading the interactive…
Can't use the interactive? Read a description instead
The calibration diagram plots raw count (0–1023) against temperature. Two green points mark the ice reading at 0 °C and the boiling reading at 100 °C; a straight blue line joins them and extends beyond. Moving the new-reading slider places an orange point on the line and states its temperature, using slope = 100 ÷ (boiling − ice) and T = (reading − ice) × slope. Readings outside the two points are flagged as extrapolation.
4.Checkpoint: guided practice
Check what you just discovered before going on. Hints appear after a wrong answer.
Practice 1 · a fresh version every time
In ice water (0 °C) your sensor reads 118 counts; in boiling water (100 °C) it reads 820 counts. A new reading is 488 counts. Assuming a straight line, what temperature is that, in °C?
5.Understand
Two known points fix a line
If the sensor is linear, two readings at known values fix its line. Melting ice is close to 0 °C and boiling water about 100 °C at sea level (lower at altitude), which makes them handy references. The slope is the true change divided by the raw change; then any reading converts by T = T₀ + slope × (raw − raw₀).
Interpolate, don't extrapolate
Between the two points (interpolation) the line is usually trustworthy. Beyond them (extrapolation) small curvature in the real sensor grows into big errors. So choose reference points that bracket the range you care about: for a greenhouse, perhaps 5 °C and 35 °C rather than 0 and 100.
Calibration in firmware
Store the two raw readings, measured once per sensor, and convert every reading:
R0, R1 = 118, 870 # measured in ice and boiling water
def temp_c(raw):
return 100 * (raw - R0) / (R1 - R0)Record the date and method in your notebook: a calibration is evidence.
Explain it another way
You know two places on a map exactly. Draw a straight road between them and you can locate anything along it.
Two-point calibration corrects offset and gain (slope) errors. Nonlinear sensors need multi-point calibration or a lookup table. Reference conditions (pressure for boiling point, purity of ice) set the calibration's own uncertainty.
T = T₀ + (T₁ − T₀)(r − r₀)/(r₁ − r₀). Rearranged into y = mx + c: m = (T₁ − T₀)/(r₁ − r₀), c = T₀ − m·r₀.
Kitchen scales calibrate with a known mass; pH meters with two buffer solutions; weather stations against a reference thermometer. Each stores numbers like R0 and R1 in memory.
Derivation: The line through two points
Reference points: raw r₀ at true T₀, raw r₁ at true T₁ (here T₀ = 0 °C, T₁ = 100 °C).
Slope: m = (T₁ − T₀) ÷ (r₁ − r₀) degrees per count. For r₀ = 118, r₁ = 870: m = 100 ÷ 752 ≈ 0.1330 °C per count.
Any reading: T = T₀ + m × (r − r₀).
Example: r = 450 → T = 0 + 0.1330 × (450 − 118) = 0.1330 × 332 ≈ 44.1 °C.
Check the ends: r = 118 gives 0 °C and r = 870 gives 100 °C, as they must.
Worked example 1
Ice reads 92 counts, boiling reads 868. A reading of 310: what temperature?
Slope = 100 ÷ (868 − 92) = 100 ÷ 776 ≈ 0.1289 °C per count. T = (310 − 92) × 0.1289 ≈ 28.1 °C.
Common mix-ups
- Calibration makes a sensor perfect.
✓ It removes offset and slope errors at the calibration points. Noise, drift and curvature remain. - Water always boils at 100 °C.
✓ Only at sea-level air pressure. Up a mountain it boils at a lower temperature, which shifts your calibration.
6.Practice on your own
Practice, not a test. Wrong answers get a hint and another try.
Practice 2 · a fresh version every time
In ice water (0 °C) your sensor reads 90 counts; in boiling water (100 °C) it reads 886 counts. A new reading is 256 counts. Assuming a straight line, what temperature is that, in °C?
Practice 3
A sensor reads 100 counts at 0 °C and 900 counts at 100 °C. What raw reading means 18 °C?
Practice 4
You calibrated at 0 °C and 100 °C. Which reading should you trust least?
Practice 5
A greenhouse must be held at 16–24 °C. Which pair of calibration points is best?
7.Apply it
Design a calibration procedure for the greenhouse sensor: which two reference temperatures, how you would produce them safely without boiling water (for example a fridge and a warm room measured with a trusted thermometer), how many readings you would average at each, and what you would write in your notebook.
8.Reflect
Concepts: How sensors measure · Measurement error and uncertainty