Sensors & Measurement · Study deck

Sensor Calibration Techniques

Calibration is the moment a sensor reading becomes accountable.

Physics Phoebe is your guide for this deck.

sensortypescalibration
Physics Phoebe, the module guide, in a scene from this chapter.
iotclass.org

After studying this chapter

Learning objectives

You will be able to:

  • Justify why sensor calibration is necessary for production IoT systems and identify which error type each technique corrects
  • Execute one-point and two-point calibration procedures using reference standards
  • Implement calibration routines in MicroPython on ESP32 and store coefficients in non-volatile memory
  • Design a calibration maintenance schedule for deployed sensors based on sensor type and environment
iotclass.org

Major section

Start With the Measurement Story

Calibration is the moment a sensor reading becomes accountable.

  • The next shows that its plotted readings can sit off the reference line.
  • The third compares the probe with the reference again; the last shows a corrected line kept inside a checked band.
  • A clean line is evidence only for the conditions actually tested.
iotclass.org

Major section

In 60 Seconds · Two Different Things Both Called "Gain"

The correction slope and converter step size describe different limits; independent validation rejects this fit.

  • Calibration scale changes the raw-to-corrected slope.
  • Converter step size changes displayed granularity.
  • Independent validation misses by 1.68 °C; the allowed error is 0.5 °C.
  • Decision: the two-point fit fails.

Numbers to remember

0.100 °CDHT22 step
Calibration scale changes the raw-to-corrected slope. Converter step size changes displayed granularity. Independent validation misses by 1.68 °C; the allowed error is 0.5 °C. Decision: the two-point fit fails.
iotclass.org

Major section

Key Concepts

Calibration: the process of comparing a sensor's output against a known reference standard and applying correction factors to make readings accurate.

  • Gain (Scale) Error: a proportional error where the sensor's reading diverges from truth at a rate proportional to the measured value; requires at least two reference points to correct.

- Calibration: the process of comparing a sensor's output against a known reference standard and applying correction factors to make readings accurate.

iotclass.org

Major section

For Beginners: Sensor Calibration

Calibration is like setting your bathroom scale to zero before weighing yourself.

  • Every sensor has small manufacturing differences, so two identical temperature sensors might give slightly different readings in the same room.
  • Calibration corrects these differences by comparing the sensor's reading against a known reference value and applying a simple correction formula to get accurate results.
iotclass.org

Major section

Every Sensor Needs Calibration

Even the best sensors have manufacturing variations.

  • Two DHT22 sensors from the same batch might read 0.5°C apart when measuring the same temperature.
  • Production spread can make devices from the same run disagree.
  • Different sensing principles can respond differently under similar conditions.

Why it matters

Low-cost deployments need this discipline because variation arrives from several places at once.

iotclass.org

Major section

Putting Numbers to It

The two reference points set a line, while a separate point tests its validity.

  • The raw reading maps through the fitted scale and offset.
  • The two fit references do not prove the middle of the range.
  • Validate at an independent reference point.
corrected = raw × 1.034 − 1.86
24.5 °C raw → about 23.5 °C corrected
iotclass.org

Major section

Multi-Point Calibration

When to use: Sensor has nonlinear response that two-point calibration cannot correct (as demonstrated in the worked example below).

  • The following example uses NumPy for polynomial fitting.
  • On resource-constrained microcontrollers, compute the coefficients on a PC and hard-code them, or use a simple lookup table with linear interpolation between points.
iotclass.org

Major section

Polynomial Calibration Explorer

Enter 3--5 calibration points (reference vs raw) and see how a quadratic polynomial fits the data.

  • Adjust individual points to observe how nonlinearity affects the correction curve.

Enter 3--5 calibration points (reference vs raw) and see how a quadratic polynomial fits the data. Adjust individual points to observe how nonlinearity affects the correction curve.

iotclass.org

Major section

Calibration Schedule Guidelines

Humidity and gas sensors receive shorter default intervals because high-humidity exposure and contamination can alter their sensing films or chemistry.

  • A pH probe is checked before each use because storage state and electrode condition directly affect the next measurement, while a load cell's annual interval is immediately overridden by an overload event.

Why it matters

A temperature sensor's six-month interval is shortened by shipping or extreme temperature because either can change mechanical stress or calibration.

iotclass.org

Major section

ESP32 Two-Point Calibration

The reference uncertainty and application range bound the chosen calibration points.

  • The reference thermometer is accurate to ±0.1 °C.
  • The greenhouse operating range is 0–50 °C.
  • Use a high reference near 45 °C and validate at a separate point.
Reference accuracy: ±0.1 °C
High reference near 45 °C; greenhouse range 0–50 °C.
iotclass.org

Major section

Try It: Calibration Validation Checker

Enter your calibration coefficients and a validation measurement to determine if your calibration is adequate or if you need a different approach.

  • This makes deployed readings auditable and repeatable.
iotclass.org

Major section

Lesson from This Example · Common Calibration Pitfall

The validation step (Step 4) caught a problem that two-point calibration alone would have missed.

  • In production, always validate against a reference point that was NOT used for calibration.
  • Temperature and humidity affect many sensor types beyond the one you are calibrating.
iotclass.org

Major section

For Kids: Meet the Sensor Squad!

Temperature Terry was feeling embarrassed. "I keep saying it is 2.3 degrees when it should be zero!" he told the Squad while sitting in a bowl of ice water.

  • "Do not worry, Sammy!" said the microcontroller. "That is totally normal.
  • Every sensor is a little bit different from the factory.

Why it matters

In six months, we do it again because sensors can drift over time -- like a clock that slowly gets behind.".

iotclass.org

Major section

For Kids: Meet the Sensor Squad! (continued)

We just need to calibrate you!".

  • Max explained: "We dip Sammy in ice water -- we KNOW that is 0 degrees.
  • "And ALWAYS use a reference that is MORE accurate than the sensor you are calibrating," Max added. "Otherwise, it is like asking someone who is MORE lost for directions!".
  • In six months, we do it again because sensors can drift over time -- like a clock that slowly gets behind.".
iotclass.org

Major section

Calibration Decision Guide

Low-risk, easily reached equipment may justify a quick one-point correction when validation shows only offset.

  • The result should be the smallest method that passes independent validation, not automatically the most elaborate curve available.

Why it matters

Access changes the lifecycle decision as well as the laboratory method; a remote installation may justify more validation and a longer-lived reference record because an early revisit is expensive.

iotclass.org

Major section

Try It Yourself

Beginner: You have a DHT22 that reads 23.8°C while your reference thermometer reads 22.0°C.

  • Advanced: An MQ-135 gas sensor gives these readings at known CO₂ concentrations: (400 ppm, raw=120), (800 ppm, raw=280), (1200 ppm, raw=390), (1600 ppm, raw=460), (2000 ppm, raw=505).

Calculate the offset and write one line of code to apply it.

iotclass.org

Major section

Common Pitfalls

Calibrating a sensor against a reference that has not been verified against a primary standard propagates the reference's error into the calibrated sensor.

  • A one-point offset calibration at 25 C assumes the offset is constant across the sensor's range.
  • Many sensors have temperature-dependent offset.
  • Linearity errors are not visible at calibration endpoints.
iotclass.org

Deck summary

Key takeaways

Calibration is the moment a sensor reading becomes accountable.

  • Sensor calibration compares readings with known references and can correct modeled offset and scale errors.
  • Calibration: the process of comparing a sensor's output against a known reference standard and applying correction factors to make readings accurate.
  • Calibration is like setting your bathroom scale to zero before weighing yourself.
  • Even the best sensors have manufacturing variations.
iotclass.org

Retrieval practice

Recall check 1 of 2

Physics Phoebe says: answer from memory, then check your reasoning.

Q1Your sensor always reads 2.3°C too high at any temperature. What calibration do you need?

AOne-point calibration (offset correction only)
BTwo-point calibration (offset + gain)
CMulti-point calibration (polynomial fit)
DNo calibration - sensor is broken
Show answer

Answer: A A constant error at all temperatures indicates pure offset (bias) error.

Q2A temperature sensor reads 2.3°C in ice water (reference 0°C) and 98.5°C in boiling water (reference 100°C). The application requires ±0.5°C accuracy at both references. What calibration is needed?

ATwo-point calibration (both offset and gain errors present)
BOne-point calibration (only offset error)
CNo calibration needed -- errors are within tolerance
DMulti-point calibration with at least 5 reference points
Show answer

Answer: A see answers page

iotclass.org

Retrieval practice

Recall check 2 of 2

Physics Phoebe says: answer from memory, then check your reasoning.

Q3Why should calibration coefficients be stored in non-volatile memory (EEPROM/flash)?

AThe memory reads faster than RAM during calibration lookup.
BThe coefficients are too large to fit in ordinary RAM.
CThe coefficients persist across reset and power loss.
DThe memory improves the numerical precision of coefficients.
Show answer

Answer: C Non-volatile memory retains data when power is removed.

Q4What pairs each raw calibration reading with a known reference across the intended range?

ACollect Measurement Pairs
BSelect Reference Standards
CCompute Calibration Curve
DValidate with Test Points
Show answer

Answer: A Measurement pairs bind each raw reading to a known reference across the intended range.

iotclass.org

Print reference

Answers

Answer key.

  1. A · A constant error at all temperatures indicates pure offset (bias) error.
  2. A · The sensor has both an offset error (reads 2.3 instead of 0 at the low end) and a gain error (the span is 96.2 degrees instead of 100). One-point calibration only fixes offset; two-point calibration fixes both by calculating scale = (100-0)/(98.5-2.3) = 100/96.2 = 1.0395 and offset = 0 - 2.3 × 1.0395 = -2.39.
  3. C · Non-volatile memory retains data when power is removed.
  4. A · Measurement pairs bind each raw reading to a known reference across the intended range.
iotclass.org
With the corrected answer frame visible, compare the four decisions. A constant bias suggests a one-point offset. Different errors at two endpoints call for scale and offset fitting. Store coefficients so they survive power loss. Then test the correction at a reference point withheld from fitting. The greenhouse’s 1.68-degree miss shows why that final test can reject a neat-looking line.