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

Comment

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

Join GarageLab (arduino, electronics, robotics, hacking)

Latest Activity

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."
Thursday
Profile IconWesenachin Asfaw and Muhammad Basil joined GarageLab (arduino, electronics, robotics, hacking)
Thursday
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…"
Thursday
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
Thursday
Profile IconDan Urbauer, Bjorn and Jiaming Zhao joined GarageLab (arduino, electronics, robotics, hacking)
Wednesday
FiniousFingers is now a member of GarageLab (arduino, electronics, robotics, hacking)
Monday
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
Edward Evans updated their profile
Mar 15
Edward Evans replied to GarageLab's discussion Serious claims against BeagleBone's manufacturer CircuitCo
"Hi Marcelo, I am curious if you have had any resolution on this?  We may be in the same boat…"
Mar 15
Celso Eiju Ito left a comment for Mrs. Priscilla Bonneval
"I just accept your invitation. Thank You for contact me. Sincerelly,   'Eiju"
Mar 15
Mohasin Ahamed Chinnapattan commented on Mauro Assis's blog post How to hack a remote control (and a flying shark) I
"You mentioned collector is set to ground but emitter is set to ground in your diagram "
Mar 14
Profile Iconbadrkhan mijbas khalifa, Bethany Cruz, Mrs. Priscilla Bonneval and 1 more joined GarageLab (arduino, electronics, robotics, hacking)
Mar 13
Edward Evans is now a member of GarageLab (arduino, electronics, robotics, hacking)
Mar 9
Profile IconAllan Zilkowsky, Shubham Dewangan, FAUSTO PEREIRA ROMANO and 4 more joined GarageLab (arduino, electronics, robotics, hacking)
Mar 1
Dave Lewing is now a member of GarageLab (arduino, electronics, robotics, hacking)
Feb 27
Profile Iconjames essien and Chow HP joined GarageLab (arduino, electronics, robotics, hacking)
Feb 17
Profile IconPerry Duvall, Irayya Mathad and wiley milam joined GarageLab (arduino, electronics, robotics, hacking)
Feb 16
Profile IconAlan Powell and Chuck Nolan joined GarageLab (arduino, electronics, robotics, hacking)
Feb 9

© 2017   Created by Marcelo Rodrigues.   Powered by

Badges  |  Report an Issue  |  Terms of Service