Tutorial: Using NTC Thermistors With Arduino

 

 

Hello folks!!!

In this tutorial we will use a 10K NTC thermistor with the Arduino and the Thermistor library to obtain the temperature in Celsius. This library uses the Steinhart-Hart equation to convert the values of resistance to values of temperature. In a second demonstration, we show how to do the same but this time we will use the Beta Factor method (example based on Adafruit).

List of Materials

1 x Arduino Uno Rev 3

1 x 10K NTC Thermistor

1 x 10K Resistor

1 x Protoboard Mini

Some jumpers

 

The Thermistor

To read the temperature we will use a thermistor. This is a special type of resistance that changes values depending on the ambient temperature.

Two types of thermistors exist, NTC and PTC

Thermistor PTC (Positive Temperature Coefficient): This type of thermistor has a positive temperature coefficient, in other words, its resistance increments as temperature increases.

Thermistor NTC (Negative Temperature Coefficient): This is the inverse of the PTC, it has a negative temperature coefficient. Its resistance decrements as temperature increases.

 

The nominal value of the thermistor is normally 25 degrees Celsius, in this case we will use a 10K thermistor. It can read temperatures between -40 and +125 degrees Celsius.

 

Determining the Temperature

To determine the temperature two methods exist, one is using a formula from Stenhart-Hart or we can use the equation for the Beta factor.

Bellow you will see the two methods to calculate the temperature:

 

Steinhart-Hart Method

  Steinhart-Hart Equation

The Steinnhart- Hart method is implemented by a library that we modified to keep compatibility with the Arduino IDE. 

You can download the library with this link : Thermistor.zip

We did some tests with this sensor along with the values from the library and the thermistor responded with values very close to the desired ones (same without having done alterations to the temperature coefficient values)

You can use the circuit and sketch bellow to recreate the test:

 

Circuit for the Steinhart-Hart Method

Sketch


#include <Thermistor.h>
Thermistor temp(0);
void setup() {
Serial.begin(9600);
}
void loop() {
int temperature = temp.getTemp();
Serial.print("The sensor temperature is: ");
Serial.print(temperature);
Serial.println("*C");
delay(1000);
}

 

 

Beta Factor Method

 Equation for the Beta Factor

The Beta Factor method cam be implemented using a code example for adafruit ( we did a few modifications since the Thermistor we used is an NTC)

The following is the circuit for the Beta Factor method:

 

Circuit for the Beta Factor Method

 

According to the datasheet for our thermistor, the beta factor for it is 3977 we use the Sketch bellow:


// Pin that the thermistor is connected to
#define PINOTERMISTOR A0
// Nominal temperature value for the thermistor
#define TERMISTORNOMINAL 10000
// Nominl temperature depicted on the datasheet
#define TEMPERATURENOMINAL 25
// Number of samples
#define NUMAMOSTRAS 5
// Beta value for our thermistor
#define BCOEFFICIENT 3977
// Value of the series resistor
#define SERIESRESISTOR 10000

int amostra[NUMAMOSTRAS];
int i;
void setup(void) {
Serial.begin(9600);
analogReference(EXTERNAL);
}

void loop(void) {
float media;

for (i=0; i< NUMAMOSTRAS; i++) {
amostra[i] = analogRead(PINOTERMISTOR);
delay(10);
}

media = 0;
for (i=0; i< NUMAMOSTRAS; i++) {
media += amostra[i];
}
media /= NUMAMOSTRAS;
// Convert the thermal stress value to resistance
media = 1023 / media - 1;
media = SERIESRESISTOR / media;

//Calculate temperature using the Beta Factor equation
float temperatura;
temperatura = media / TERMISTORNOMINAL; // (R/Ro)
temperatura = log(temperatura); // ln(R/Ro)
temperatura /= BCOEFFICIENT; // 1/B * ln(R/Ro)
temperatura += 1.0 / (TEMPERATURENOMINAL + 273.15); // + (1/To)
temperatura = 1.0 / temperatura; // Invert the value
temperatura -= 273.15; // Convert it to Celsius

Serial.print("The sensor temperature is: ");
Serial.print(temperatura);
Serial.println(" *C");

delay(1000);
}

We hope that you liked the tutorial and that you all use these sensors, this is a simple to build, and cost effective alternative to measure ambient temperature. If you liked the tutorial or have any questions please leave your comments below.

Views: 68158

Comment

You need to be a member of GarageLab (arduino, electronics, robotics, hacking) to add comments!

Join GarageLab (arduino, electronics, robotics, hacking)

Latest Activity

Profile Iconjames essien and Chow HP joined GarageLab (arduino, electronics, robotics, hacking)
Friday
Profile IconPerry Duvall, Irayya Mathad and wiley milam joined GarageLab (arduino, electronics, robotics, hacking)
Thursday
Profile IconAlan Powell and Chuck Nolan joined GarageLab (arduino, electronics, robotics, hacking)
Feb 9
Profile Iconpavan lakhe and Olive Liao joined GarageLab (arduino, electronics, robotics, hacking)
Feb 6
pin is now a member of GarageLab (arduino, electronics, robotics, hacking)
Feb 3
Valcke Marc updated their profile
Feb 2
Bede Domokos is now a member of GarageLab (arduino, electronics, robotics, hacking)
Feb 1
Profile IconToshiyuki Akashi and Valcke Marc joined GarageLab (arduino, electronics, robotics, hacking)
Jan 31
korte is now a member of GarageLab (arduino, electronics, robotics, hacking)
Jan 30
Profile IconRobert Broedel, Al calaguin and Allan joined GarageLab (arduino, electronics, robotics, hacking)
Jan 26
HUZEFA ESSAJI is now a member of GarageLab (arduino, electronics, robotics, hacking)
Jan 20
karthikeyan is now a member of GarageLab (arduino, electronics, robotics, hacking)
Jan 19
Lou Rabinski is now a member of GarageLab (arduino, electronics, robotics, hacking)
Jan 18
iftekhar Mobin is now a member of GarageLab (arduino, electronics, robotics, hacking)
Jan 16
Profile IconLeicester Hibbert and Michael Young joined GarageLab (arduino, electronics, robotics, hacking)
Jan 9
Profile IconThorsten Schwarz and Dana Custer joined GarageLab (arduino, electronics, robotics, hacking)
Jan 2
Aqeel munir updated their profile
Dec 31, 2016
Todd Enger updated their profile
Dec 29, 2016
FRANK KWABENA is now a member of GarageLab (arduino, electronics, robotics, hacking)
Dec 28, 2016
Ayhan Chaplan commented on GarageLab's blog post How to use a Peltier with Arduino
"Hi! Will this setup work with a 3,8V / 2,5A Peltier element? Or do I have to reduce the resistance…"
Dec 26, 2016

© 2017   Created by Marcelo Rodrigues.   Powered by

Badges  |  Report an Issue  |  Terms of Service