IoT Fundamentals · Study deck

Sensor Linearization Methods

Picture a water tank whose level sensor is correct near empty and near full but bends through the middle.

Physics Phoebe is your guide for this deck.

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

After studying this chapter

Learning objectives

You will be able to:

  • Explain: A better workflow is to collect reference points across the shipping range, fit a Steinhart-Hart equation or a lookup table, then compare the converted temperatures against held-out reference readings.
  • Explain: The loop in Figure: Validation uses independent holdout points and range guards checks holdout residuals after the fit; notice why a range failure calls for new evidence or a simpler model.
  • Explain: The ADC code may change quickly near freezing and slowly at warmer temperatures, so a single slope can make the freezer end look acceptable while the room-temperature end drifts.
iotclass.org

Major section

In 60 Seconds

A smooth conversion can still give the wrong depth where the pump decision matters.

  • An analog-to-digital converter is a part that turns a changing electrical signal into numbered steps.
  • This trial does not prove every sensor or fitting method.
  • Linearization turns a curved sensor response into physical units, but it must not hide uncertainty.
iotclass.org

Major section

Start With the Story

You will choose a sensor correction method and check where calibration evidence supports its use.

  • The mathematical gist: A 90 s excursion is a transient, not a single 0.0111 Hz tone: a 200 s sampling interval can miss it altogether.

You will choose a sensor correction method and check where calibration evidence supports its use. Start with measured reference points and the range over which the corrected values must remain reliable.

iotclass.org

Major section

Turn a Curved Response Into Correct Units

Many sensors do not produce an output that is proportional to what they measure.

  • A thermistor's resistance, for example, changes steeply and nonlinearly as temperature changes.
  • Linearization is the step that converts that curved raw response into the correct physical units.
  • Linearization is that conversion for a sensor.

Key terms

If the held-out residuals
If the held-out residuals are still larger than the product's tolerance, the display should not imply more accuracy than the calibration proves.
Linearization is valid only where calibration evidence supports the correction.
Linearization is valid only where calibration evidence supports the correction.
iotclass.org

Major section

Turn a Curved Response Into Correct Units (continued)

If the held-out residuals are still larger than the product's tolerance, the display should not imply more accuracy than the calibration proves.

  • The pointer still moves, but not evenly, so you need a conversion that knows the spring's curve to read true weight.
  • Making the numbers come out smooth is not the same as making them accurate.
  • If this gives you the core principle, you can stop here.
iotclass.org

Major section

Turn a Curved Response Into Correct Units (continued)

The calibrated region bounds the supported correction; values beyond it need a flag or clamp instead of extrapolation.

  • The ADC code may change quickly near freezing and slowly at warmer temperatures, so a single slope can make the freezer end look acceptable while the room-temperature end drifts.
  • A better workflow is to collect reference points across the shipping range, fit a Steinhart-Hart equation or a lookup table, then compare the converted temperatures against held-out reference readings.
  • Beginner ExamplesA nearly linear sensor over a small range may need only a straight-line fit with an offset and a slope.
iotclass.org

Major section

Apply It: Choose a Method From the Evidence

The practical job is to choose the simplest linearization method whose residuals meet the accuracy target within the device's limits, then prove it on held-out data and protect against out-of-range inputs.

  • The sensor runs in a narrow band near a known point.
  • Error grows quickly away from that point.

Key terms

If your job
If your job is to select and validate a conversion, you can stop here.
Method choice starts with range, residual behavior, and maintainability, not with the smoothest-looking formula.
Method choice starts with range, residual behavior, and maintainability, not with the smoothest-looking formula.
iotclass.org

Major section

Apply It: Choose a Method From the Evidence (continued)

Memory use and table density set accuracy.

  • One smooth equation fit to calibration data.
  • The model and its coefficients are trustworthy.
  • Piecewise segments can follow moderate curvature; a lookup table trades memory for a fast, repeatable conversion.
  • A polynomial gives one smooth equation but can overfit.
iotclass.org

Major section

Apply It: Choose a Method From the Evidence (continued)

Small scattered residuals support the fit; a pattern or out-of-range input calls for more points, another method, or a narrower claim.

  • Segments extend coverage, tables provide fixed breakpoints, and polynomial fits need residual checks.
  • Quantify nonlinearity and range: A nearly straight, narrow-range sensor needs far less than a steeply curved, wide-range one.
  • Piecewise-linear, denser where curvature is high.
iotclass.org

Major section

Apply It: Choose a Method From the Evidence (continued)

Guard the range and validate at release: Clamp or flag inputs outside the calibrated range, and re-validate against references before shipping and after any sensor or firmware change.

  • The record in Figure: A releaseable conversion keeps the raw code keeps raw codes and fit proof together; check the release gate.
  • The sequence makes A releaseable conversion keeps the raw code, reference value, fit choice, residuals, and gate decision together auditable for: Walkthrough: From Sensor Curve to Validated Conversion.
  • Incremental PracticeBeginner For a near-linear sensor over a small range, justify using a simple slope-and-offset fit.
A releaseable conversion keeps the raw code, reference value, fit choice, residuals, and gate decision together.
A releaseable conversion keeps the raw code, reference value, fit choice, residuals, and gate decision together.
iotclass.org

Major section

Under the Hood: How Each Method Fails

Local (Taylor) LinearizationA local linearization keeps the first-order term of a series expanded around an operating point, which is the local slope, and discards the rest.

  • Those discarded higher-order terms are the error, and they grow roughly with the square of the distance from the expansion point.

Key terms

Passing through the points
Passing through the points is not accuracy.
Accuracy
Accuracy is therefore bought with more breakpoints or table entries, which costs memory.

Why it matters

The deeper layer explains the error behavior behind each method, because choosing well means knowing how each one breaks.

A quadratic sensor response converts a zero-mean sinusoidal disturbance into DC bias before comparison with white and one-over-f noise floors.
A quadratic sensor response converts a zero-mean sinusoidal disturbance into DC bias before comparison with white and one-over-f noise floors.
iotclass.org

Major section

Under the Hood: How Each Method Fails (continued)

Polynomial Fit and OverfittingA polynomial of degree n has n + 1 coefficients and can pass exactly through n + 1 points.

  • Passing through the points is not accuracy.
  • Prefer the lowest degree whose held-out residuals are acceptable.
  • The error inside a segment depends on the curve's bend and the segment width.
iotclass.org

Major section

Under the Hood: How Each Method Fails (continued)

Residual AnalysisResiduals are the differences between the model and held-out calibration points.

  • High-degree fits, especially with equally spaced calibration points, can swing far above and below the true curve between the points, a behavior known as the Runge phenomenon, and they diverge quickly outside the calibrated range.
  • Accuracy is therefore bought with more breakpoints or table entries, which costs memory.
  • If the reference is uncertain, every converted value inherits that uncertainty.
iotclass.org

Major section

Under the Hood: How Each Method Fails (continued)

Piecewise-Linear and Lookup TablesBoth approximate the curve with straight segments, and a lookup table is essentially a piecewise-linear model stored as data.

  • Small, randomly scattered residuals suggest a good fit, while a systematic pattern, such as a consistent smile or trend, means the model is missing real structure.
  • Residuals measured on the same points used to fit understate the true error, so always check against points the model did not see.
  • The loop in Figure: Validation uses independent holdout points and range guards tests the fit on held-out points; revise it if they fail.
iotclass.org

Major section

Under the Hood: How Each Method Fails (continued)

Common PitfallsEquating fit with accuracy: Passing through every calibration point can be overfitting, not correctness.

  • The loop in Figure: Validation uses independent holdout points and range guards checks holdout residuals after the fit; notice why a range failure calls for new evidence or a simpler model.
  • Extrapolation Is UnboundedEvery method is valid only inside the calibrated range.
  • Reporting more precision than the calibration supports: The converted value cannot beat its reference.
Validation uses independent holdout points and range guards; failing residuals send the method back for better evidence or a simpler fit.
Validation uses independent holdout points and range guards; failing residuals send the method back for better evidence or a simpler fit.
iotclass.org

Major section

Under the Hood: How Each Method Fails (continued)

Outside it, polynomial terms explode and tables have no data, so out-of-range inputs must be clamped or flagged rather than silently converted into confident, wrong numbers.

  • Raising polynomial degree to chase residuals: It can oscillate and worsen accuracy between and beyond the points.
  • Extrapolating beyond the calibrated range: Error there is unknown and can be large.
  • At this depth, linearization is a trade among model flexibility, compute, memory, and honesty about uncertainty.
iotclass.org

Deck summary

Key takeaways

A smooth conversion can still give the wrong depth where the pump decision matters.

  • You will choose a sensor correction method and check where calibration evidence supports its use.
  • Many sensors do not produce an output that is proportional to what they measure.
  • If the held-out residuals are still larger than the product's tolerance, the display should not imply more accuracy than the calibration proves.
  • The calibrated region bounds the supported correction; values beyond it need a flag or clamp instead of extrapolation.
iotclass.org

Retrieval practice

Recall check 1 of 3

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

Q1A converted temperature is displayed to six decimal places and looks very smooth. What does that tell you about its accuracy?

AIt proves six-decimal accuracy because the display rounded the converted value that way
BIt proves the sensor response was linear before any calibration curve was applied
CIt proves only numeric formatting; calibration residuals still set accuracy
DIt proves no reference check is needed once the conversion equation looks smooth
Show answer

Answer: C Numeric precision and visual smoothness are not the same as measurement accuracy.

iotclass.org

Retrieval practice

Recall check 2 of 3

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

Q2A steeply nonlinear sensor must be converted quickly on a small microcontroller with little spare compute but some free memory, across a wide range. Which method is the most reasonable starting point?

AA high-degree polynomial evaluated at every sample
BA single Taylor expansion around one operating point
CNo linearization; report the raw codes
DA lookup table with interpolation
Show answer

Answer: D A table converts quickly with little compute and follows the curve as densely as memory allows, giving repeatable conversion across the range.

iotclass.org

Retrieval practice

Recall check 3 of 3

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

Q3A high-degree polynomial passes through all the calibration points exactly, but between them it swings far from the true curve, and outside the range it diverges. What modeling problem is happening?

AA broken sensor that must be replaced.
BOverfitting, specifically the Runge phenomenon.
CToo few calibration points at the same polynomial degree.
DA floating-point precision failure in storage.
Show answer

Answer: B The data fits, but a too-flexible model oscillates between points and diverges outside the range.

iotclass.org

Print reference

Answers

Answer key.

  1. C · Numeric precision and visual smoothness are not the same as measurement accuracy.
  2. D · A table converts quickly with little compute and follows the curve as densely as memory allows, giving repeatable conversion across the range.
  3. B · The data fits, but a too-flexible model oscillates between points and diverges outside the range.
iotclass.org