Easy Modbus Register maps →

How do I calibrate a sensor with slope and intercept?

Updated 10 November 2026

Short answer

A sensor's raw reading usually relates to the real value by a straight line: real = raw × slope + intercept. Measure two points you know to be true, enter them in the free slope and intercept calculator, and it gives you the slope and intercept. In Home Assistant and many other tools, the slope is the scale and the intercept is the offset.

In the picture, each numbered coloured circle matches a numbered step. The calculator is at the bottom of the word-order finder page.

Steps

The slope and intercept calculator for a 4 to 20 milliamp sensor
A 4 to 20 mA sensor that should read 0 to 100.
  1. 1 (orange circle) Point 1: raw reading. What the sensor reports with the first known condition. Here, 4 (mA).
  2. 2 (blue circle) Point 1: real value. What it really is at that moment, from a reference you trust. Here, 0.
  3. 3 (green circle) Point 2: raw reading. The reading at a second condition. Here, 20.
  4. 4 (pink circle) Point 2: real value. What it really is then. Here, 100.
  5. 5 (purple circle) Optional: type any raw reading to see what it means. 12 means 50.
  6. 6 (red circle) The answer: slope 6.25 and intercept −25, so real = raw × 6.25 − 25.

Choosing your two points

Another example: a temperature probe

A probe reads 2.0 in an ice bath (really 0) and 98.0 in boiling water (really 100). Enter 2.0 → 0 and 98.0 → 100. The calculator gives slope 1.04166667 and intercept −2.08333333. A raw reading of 50 then means 50 × 1.04166667 − 2.08333333 = 50.

Where to put the two numbers

If the value is off by a huge factor or looks random rather than slightly wrong, the problem is probably not calibration. See the word-order and scale guide.