In this article, I’ll explain how thermistors work, then I’ll show you how to set up a basic thermistor circuit with an Arduino that will output temperature readings to the LCD.
Thermistors are simple, inexpensive, and accurate components that make it easy to get temperature data for your projects. Remote weather stations, home automation systems, and equipment control and protection circuits are some applications where thermistors would be ideal. They’re analog sensors, so the code is relatively simple compared to digital temperature sensors that require special libraries and lots of code.
Circuit Diagram:
Components Required
Arduino Uno - 1 no
LCD display 16x1- I2C- 1 no
Thermistor (NTC) KY-013 Module- 1 no
Thermistor NTC stands for “Negative Temperature Coefficient.
Thermistors are temperature-sensing elements made of semiconductor material that has been sintered in order to display large changes in resistance in proportion to small changes in temperature.
This resistance can be measured by using a small and measured direct current, or dc, passed through the thermistor in order to measure the voltage drop produced.
These solid state temperature sensors actually act like electrical resistors that are temperature sensitive. That is where the name, a clear combination of the words thermal and resistor, comes from.
Specifications
The temperature sensor is a NTC thermistor
Multi-point temperature measurement Measures temperatures: -55°C / +125°C
Accuracy: + / – 0.5°C
Material: mixed material
Dimensions: 3 x 1.5 x 0.6cm
Weight : 2g
Arduino Connection with KY-013 Temperature sensor
Arduino pin analog A0 to KY-013 Module S (Signal) Arduino pin GND to KY-013Module –Pin Arduino pin 5+ to KY-013 Module +Pin
Arduino Code for KY-013 Temperature sensor
The analog sensor acts as a variable resistor. As temperature increases, the sensor will decrease it’s voltage output. Once we can measure the voltage output, we can calibrate the sensor and convert the output in voltage to temperature.
The major problem NTC thermistor is the calibration, that is, to establish a function between electrical resistance and temperature. The variation in its electrical resistance with temperature is non-linear it may be seen as an exponential function according to equation Steinhart-Hart.
As the thermistor brings me some information on the data sheet can use the Beta parametter of the Steinhart-Hart equation to get the temperature reading on the sensor. This can be solved for the temperature: R (Rout) = read resistance in the sensor β = defines the temperature differential to calibrate the sensor using the initial temperature and final temperature T1, T2 and their resistances. R∞ = models the exponential function. It seems a little hard, but all the values we need are tabulated only fitting the micro controller to do the calculations and deliver the read temperature. Defining values (temperatures in Celsius C) To calibrate the sensor is used at the temperatures T1 (initial) = 0 ° C, T2 (end) = 100 °, T0 = 25 ° C this and ambient operating temperature, such T1 and T2 temperatures have been set to the environment to be used, since T0 is the thermistor resistance value by default 10Kohm, the RT1 and RT2 of value are in Datasheet sensor.
The code this commented, but follows some observations
The code shows the value of the temperature in Celsius (C) and Fahrenheit (F) put all the calculations are made with the temperature in Kelvin (K). not being recommended to calculate the value in C or F, so in the beginning of the code I insert the K values
TempK the variable returns the value of the temperature in K shortly after calculating. TempC converts K to C
((* TempC 9) / 5 + 32); this code converts C to F
Installing the Arduino Library
LiquidCrystal_I2C.h : you need to Downloadand install the LiquidCrystal_I2C library.
In your Arduino IDE, to install the libraries go to Sketch > Include Library > Add .ZIP library… and select the library you’ve just downloaded.
After installing the required libraries, copy the following code to your Arduino IDE.
Subscribe and Download code.
Arduino code:
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27,16,2);
float Vin=5.0; // [V]
float Rt=10000; // Resistor t [ohm]
float R0=10000; // value of rct in T0 [ohm]
float T0=298.15; // use T0 in Kelvin [K]
float Vout=0.0; // Vout in A0
float Rout=0.0; // Rout in A0
// use the datasheet to get this data.
float T1=273.15; // [K] in datasheet 0º C
float T2=373.15; // [K] in datasheet 100° C
float RT1=35563; // [ohms] resistence in T1
float RT2=549; // [ohms] resistence in T2
float beta=0.0; // initial parameters [K]
float Rinf=0.0; // initial parameters [ohm]
float TempK=0.0; // variable output
float TempC=0.0; // variable output
void setup() {
Serial.begin(9600);
lcd.begin(16,2);
lcd.init(); // initialize the lcd
// Print a message to the LCD.
lcd.backlight();
pinMode(0, INPUT);
//parâmetros
beta=(log(RT1/RT2))/((1/T1)-(1/T2));
Rinf=R0*exp(-beta/T0);
}
void loop()
{
Vout=Vin*((float)(analogRead(0))/1024.0); // calc for ntc
Rout=(Rt*Vout/(Vin-Vout));
TempK=(beta/log(Rout/Rinf)); // calc for temperature
TempC=TempK-273.15;
lcd.setCursor(0,0);
lcd.print("Temperature NTC");
lcd.setCursor(0,1);
lcd.print(TempC);
lcd.write(0xdf); // to display °
lcd.print("C ");
lcd.print((TempC * 9)/5 + 32); // C to F
lcd.write(0xdf);
lcd.print("F");
delay(1200);
}
Comments