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

Phoebe's Field Notes: Two Different Things Both Called "Gain"

The mathematical gist.: The DHT22's catalog-typical 0.100 °C step has $\\sigma_q=0.0289$ °C RMS.

  • Its 1.68 °C validation residual is about $58.2\\times$ the unrounded quantisation floor and exceeds the 0.5 °C HVAC tolerance, so rounding cannot explain the stated nonlinearity.

Numbers to remember

1.68 °CIts 1.68 °C validation residual is about $58.2\\times$ the unrounded quantisation floor
0.5 °Cand exceeds the 0.5 °C HVAC tolerance
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 corrected formula is corrected = raw * 1.034: 1.86.

  • At room temperature, a raw reading of 24.5°C becomes 23.5°C.
  • Without calibration, the 1.0°C error would violate many HVAC control requirements.

Numbers to remember

24.5°Ca raw reading of 24.5°C becomes 23.5°C.
23.5°Ca raw reading of 24.5°C becomes 23.5°C.
1.0°Cthe 1.0°C error would violate many HVAC control requirements.
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.
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

Scenario: You are deploying 20 DHT22 sensors in a commercial greenhouse.

  • Each sensor will trigger HVAC adjustments, so accuracy matters -- a 2°C error could stress plants or waste energy.
  • Your reference instrument is a NIST-traceable digital thermometer accurate to +/-0.1°C.
  • This exposes nonlinearity, so the sensor needs multi-point calibration or a better sensor.

Numbers to remember

-0.1°CYour reference instrument is a NIST-traceable digital thermometer accurate to +/-0.1°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

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.
iotclass.org

Major section

Common Calibration Pitfall

Temperature and humidity affect many sensor types beyond the one you are calibrating.

  • A pressure sensor calibrated in a heated lab may behave differently at outdoor deployment temperatures.
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).
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

The mathematical gist.: The DHT22's catalog-typical 0.100 °C step has $\\sigma_q=0.0289$ °C RMS.

  • Calibration is like setting your bathroom scale to zero before weighing yourself.
  • Even the best sensors have manufacturing variations.
  • The corrected formula is corrected = raw * 1.034: 1.86.
  • When to use: Sensor has nonlinear response that two-point calibration cannot correct (as demonstrated in the worked example below).
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 (should be 0°C) and 98.5°C in boiling water (should be 100°C). What type of 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

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)?

ANon-volatile memory is faster to read than RAM
BCalibration coefficients are too large for RAM
CThey survive resets and power loss
DNon-volatile memory provides better numerical precision
Show answer

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

Q4Place each calibration step where it lives so you can prove a fitted correction works beyond the points used to create it.

ASelect Reference Standards
BCollect Measurement Pairs
CCompute Calibration Curve
DValidate with Test Points
Show answer

Answer: A Place each calibration step where it lives so you can prove a fitted correction works beyond the points used to create it.

iotclass.org

Print reference

Answers

Answer key.

  1. A · A constant error at all temperatures indicates pure offset (bias) error.
  2. A
  3. C · Non-volatile memory retains data when power is removed.
  4. A · Place each calibration step where it lives so you can prove a fitted correction works beyond the points used to create it.
iotclass.org