How do I calibrate a sensor with slope and intercept?
Updated 10 November 2026
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

- 1 (orange circle) Point 1: raw reading. What the sensor reports with the first known condition. Here, 4 (mA).
- 2 (blue circle) Point 1: real value. What it really is at that moment, from a reference you trust. Here, 0.
- 3 (green circle) Point 2: raw reading. The reading at a second condition. Here, 20.
- 4 (pink circle) Point 2: real value. What it really is then. Here, 100.
- 5 (purple circle) Optional: type any raw reading to see what it means. 12 means 50.
- 6 (red circle) The answer: slope 6.25 and intercept −25, so
real = raw × 6.25 − 25.
Choosing your two points
- Pick points far apart, near the bottom and top of the range you use. Points close together magnify any measuring error.
- Use a reference that is more accurate than the sensor: an ice bath (0 °C), a calibrated meter, a known weight or pressure.
- Let both readings settle before you write them down.
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
- Home Assistant: on the sensor,
scale:is the slope andoffset:is the intercept. The Home Assistant guide shows where the sensor lines live. - Other systems: look for gain/offset, scale/bias or slope/intercept fields. The formula is the same, but check whether the system applies the offset before or after the scale.
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.