Obtaining better accuracy for LMT87 Temperature Sensor by using polynomial regression

Tarlan Ahadli
Nov 3 · 2 min read
Photo by Marc A on Unsplash

LMT87 is one of the cheapest as well as relatively well-performing general-purpose temperature sensors. One of the most considerable disadvantages of this sensor family is its negligible nonlinear transfer function between voltage and temperature. This nonlinearity can be easily seen by plotting the transfer table data which is provided in the datasheet of the sensor.

To address this issue, the datasheet offers an equation to get a better voltage-temperature relationship which should be implemented in the firmware side.

However, this equation requires high computational power which can be an issue when working with low-power implementations.


The good news is we can get rid of this complex equation by applying polynomial regression to the extracted data from the datasheet. The python library, numpy, provides a conducive function polyfit to deal with such type of problems.

After implementing polynomial regression, we got the equation below to convert output voltage to the temperature which requires less computational power and perfectly fits the derived data.


To view the full project code, please, visit the GitHub repo. If you think it is helpful please, don’t forget to clap.

Tarlan Ahadli

Written by

Automation Engineering Student (BE), Machine Learning Specialist, Software development enthusiast

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade