Crea sito

## Measuring temperature with thermistor + Arduino

Leggi in ITALIANO

In this article we will see how to measure the temperature thanks to Arduino and a thermistor.

INGREDIENTS:

1x Arduino UNO

1x 4.7 kΩ resistor

The thermistors are sensors that vary its resistance according to the temperature to which they are subjected. Those of type NTC lowering its resistance as the temperature increases, while the PTC increases. Unfortunately, these sensors are not completely linear so do not just learn a simple proportion to their temperature depending on the resistor, but you must have some parameters and equations. In this article we use the equation with the B parameter. The formula is the following: Where R0 is the resistance at the T0 temperature (usually 25 ° C = 298.15 K), B is the beta coefficient , whereas R is the resistance value of the thermistor at the T temperature that we want to detect. The temperatures are expressed in Kelvin degrees . At this point the only data that we are missing is the value of R, which will we will find thanks to a voltage divider. The value of the unknown resistance R2 will be: the complete circuit the code for arduino:

 ``` 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23``` ```//Created by Mohamed Fadiga momodesine@hotmail.it double temp; void setup() { pinMode(A0,INPUT); Serial.begin(9600); } void loop() { temp=calcTemp(analogRead(A0), 3950, 2800); Serial.println(temp); } double calcTemp(int value, int B, int R0) { double V=(5/1023.00)*value; double R=((10000.00*5)/V)-10000; double T=B/log(R/(R0*pow(M_E,(-B/298.15)))); return T-273.15; } ```