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: 72407

Comment

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

Join GarageLab (arduino, electronics, robotics, hacking)

Latest Activity

Marco is now a member of GarageLab (arduino, electronics, robotics, hacking)
yesterday
Muhammad Ali commented on Marcelo Rodrigues's blog post Arduino generated VGA (color) signal - Complete!
"Thanks for the advice. I will persist with the code till I get it done. thanks once again."
Apr 18
Marcelo Rodrigues commented on Marcelo Rodrigues's blog post Arduino generated VGA (color) signal - Complete!
""The output waveforms on oscilloscope for Hsync and Vsync and for that matter RGB pins are not…"
Apr 17
Muhammad Ali commented on Marcelo Rodrigues's blog post Arduino generated VGA (color) signal - Complete!
"Hi  Marcelo I am trying to make this code work with Attiny 44a operating @ 20 MHz. I have…"
Apr 17
Profile IconReal NOiseux, Muhammad Ali, bob v and 1 more joined GarageLab (arduino, electronics, robotics, hacking)
Apr 17
baiqian is now a member of GarageLab (arduino, electronics, robotics, hacking)
Apr 10
Profile IconDavide and Almas Amandossov joined GarageLab (arduino, electronics, robotics, hacking)
Apr 6
Profile Iconvamoalrenga and John Ferrell joined GarageLab (arduino, electronics, robotics, hacking)
Apr 3
Marcelo Rodrigues replied to FiniousFingers's discussion New to group
"Yes, please share your progress here. Thanks and good"
Mar 27
FiniousFingers replied to FiniousFingers's discussion New to group
"Thanks, good to know someone is out there. I will be…"
Mar 27
Edward Evans replied to GarageLab's discussion Serious claims against BeagleBone's manufacturer CircuitCo
"Have you moved forward with any action?  I would be interested in discussing your…"
Mar 27
Marcelo Rodrigues replied to GarageLab's discussion Serious claims against BeagleBone's manufacturer CircuitCo
"Ed, No, they didn't deliver yet.  :( Good luck for us all."
Mar 23
Profile IconWesenachin Asfaw and Muhammad Basil joined GarageLab (arduino, electronics, robotics, hacking)
Mar 23
Marcelo Rodrigues replied to FiniousFingers's discussion New to group
"Hey man! A good point to start is reading basic tutorials on Arduino coding and wiring. Then, you…"
Mar 23
FiniousFingers posted a discussion

New to group

Couple quick things,I am just starting to learn, or wanting to learn, how to use the Arduino UNO…See More
Mar 23
Profile IconDan Urbauer, Bjorn and Jiaming Zhao joined GarageLab (arduino, electronics, robotics, hacking)
Mar 22
FiniousFingers is now a member of GarageLab (arduino, electronics, robotics, hacking)
Mar 20
Erva updated their profile
Mar 16
Erva and Mrs. Priscilla Bonneval are now friends
Mar 16
Profile IconSamantha Dorr, Lee Robinson and Celso Eiju Ito joined GarageLab (arduino, electronics, robotics, hacking)
Mar 16

© 2017   Created by Marcelo Rodrigues.   Powered by

Badges  |  Report an Issue  |  Terms of Service