Home / Learn Embedded C / Calibrating an Analog Sensor

Calibrating an Analog Sensor

Correcting a sensor's raw-to-real-world conversion using one or more known reference points.

Bottom lineCorrecting a sensor's raw-to-real-world conversion using one or more known reference points.

Breaking it down

Single-point vs two-point calibrationSingle-pointCorrects a constant offsetonlySimple, needs one knownreferenceTwo-pointCorrects both offset and slopeMore accurate, needs two knownreferences
Single-point vs two-point calibration

Definition

Calibrating a sensor means adjusting its raw-to-real-world conversion formula using one or more known reference measurements, correcting for manufacturing variation, aging, or an imprecise generic datasheet formula.

Why you need this

Cheap sensors often vary unit-to-unit more than their datasheet's "typical" formula suggests — a simple calibration (measuring at one or two known points) can significantly improve real-world accuracy cheaply.

How it works

A single-point calibration shifts the whole curve by a constant offset; a two-point calibration also corrects its slope — more reference points generally allow correcting more complex, non-linear sensor behavior.

Where you'll see this

  • Sensor accuracy improvement
  • Production calibration routines
  • Compensating for unit-to-unit variation

Try it

Applying a simple two-point linear calibrationC: edit and run

This standard linear-interpolation formula is the core of most simple two-point sensor calibrations.

Try it: a simpler single-point offset calibration

Applying a single-point offset-only calibrationC: edit and run

This only shifts every future reading by a constant offset — it cannot correct the sensor's slope the way the two-point method below can.

Test what you just read

1. What does a two-point calibration correct that a single-point calibration cannot?