Measuring temperature with an arduino and an NTC thermistor

This method to measure the temperature is very cheap and precise enough to be utilized in many applications.

A thermistor is a type of resistor whose resistance is dependent on temperature, more so than in standard resistors. There are two types of thermistors NTC(negative temperature coefficient) and PTC(positive temperature coefficient).

If resistance increase with increasing temperature we have a PTC thermistor, if resistance decreases with increasing temperature we have a NTC thermistors.

For our temperature mesurements we will use a NTC thermistor(more details about informations and aplications for each type of thermistors here).

For aplications we need to know a dependence of themperature with resistance. So we can use the Steinhart-Hart equation  , but we need to know parameters a,b,c wich are specified for each thermistor.

But when we buy a thermistor the most of times it has specified the B parameter so we will use the B parameter equation 1/T=1/T0 +1/Bln(R/R0). T represent the temperature in kelvin, T0 represent 25oC or 298.15K, R0 represent the resistance at T0, in our case for model (NTCM HP 50k 1%) R=50k.  Also for our model B parameter is B=3950K.

Because the thermistor is a variabile resistor we can measure the  value with a voltage divider.

In the picture below you can see how we have  mounted the thermistor and how we have calculated his resistance value:


arduino thermistor


The entire circuit without BCD 7 segments to display the temperature made in fritzing is in the image below and you can download it from here.




RT represent the thermistor resistance and R1 has a 10k value. For better precision in the program instead a 10kohms value for R1 , measure it for real value(in our case 9940 ohms).

The program for thermistor with displaying the temperature in serial monitor is below or you can download it from here:

int R1=9940; // the resistor from voltage divider
float Bt=3950.0;// B parameter
float Tc=0;// temperature in celsius
void setup(void) {
void loop(void) {
void updatetemp()// function which generates temperature
int x=analogRead(A1);//reading the value from Analog pin 1
float Vout=x*(5/1023.0);// transform it in voltage
float Rt=R1*Vout/(5.0-Vout);// the resistance of thermistor from the voltage divider
//this value cance with temperature
float a1=1/298.15;//298.15 represent 25 degrees celsius in kelvin
//and 1/298.15 represent 1/To in equation
float b1=1/Bt;// 1/Btsecond parameter in equation
float c1=log(Rt/50000.0);//third parameter, 50000 ohms are Ro at zero degrees celsius
float y1=a1+b1*c1;// the result of equation
float T=1/y1;// temperature in kelvin
Tc=T-273.15;//temperature in celsius
Serial.println(Tc);// display temperature in serial monitor

A little more complex program is to display this temperature on a four digits 7 segments BCD display

You can download it from here.


Please let us in the comment zone any suggestions that you think will improve the article!

If you like the article click the follow button from social media to stay in touch with us!


Also a short video is below:



Related posts

Leave a Comment

Show Buttons
Hide Buttons