12. Chapter Thermistor
In this chapter, we will learn about thermistors which are another kind of resistor
12.1. Project Thermometer
A thermistor is a type of resistor whose resistance value is dependent on temperature and changes in temperature. Therefore, we can take advantage of this characteristic to make a thermometer.
12.1.1. Component List
ESP32-S3 WROOM x1
|
GPIO Extension Board x1
|
||
Breadboard x1
|
|||
Thermistor x1
|
Resistor 10kΩ x1
|
Jumper M/M x3
|
|
12.1.2. Component knowledge
12.1.2.1. Thermistor
A thermistor is a temperature sensitive resistor. When it senses a change in temperature, the resistance of the thermistor will change. We can take advantage of this characteristic by using a thermistor to detect temperature intensity. A thermistor and its electronic symbol are shown below.
The relationship between resistance value and temperature of a thermistor is:
Where:
Rt is the thermistor resistance under T2 temperature;
R is the nominal resistance of thermistor under T1 temperature;
EXP[n] is nth power of E;
B is for thermal index;
T1, T2 is Kelvin temperature (absolute temperature). Kelvin temperature=273.15 + Celsius temperature.
For the parameters of the thermistor, we use: B=3950, R=10k, T1=25.
The circuit connection method of the thermistor is similar to photoresistor, as the following:
We can use the value measured by the ADC converter to obtain the resistance value of thermistor, and then we can use the formula to obtain the temperature value.
Therefore, the temperature formula can be derived as:
12.1.3. Circuit
The circuit of this project is similar to the one in the last chapter. The only difference is that the photoresistor is replaced by the thermistor.
Schematic diagram |
|---|
|
Hardware connection. If you need any support, please contact us via: support@freenove.com |
|
12.1.4. Sketch
12.1.4.1. Sketch_Thermometer
Download the code to ESP32-S3 WROOM, the terminal window will display the current ADC value, voltage value and temperature value. Try to “pinch” the thermistor (without touching the leads) with your index finger and thumb for a brief time, you should see that the temperature value increases.
If you have any concerns, please contact us via: support@freenove.com
The following is the code:
1/**********************************************************************
2 Filename : Thermomter
3 Description : Making a thermometer by thermistor.
4 Auther : www.freenove.com
5 Modification: 2022/10/21
6**********************************************************************/
7#define PIN_ANALOG_IN 1
8void setup() {
9 Serial.begin(115200);
10}
11
12void loop() {
13 int adcValue = analogRead(PIN_ANALOG_IN); //read ADC pin
14 double voltage = (float)adcValue / 4095.0 * 3.3; // calculate voltage
15 double Rt = 10 * voltage / (3.3 - voltage); //calculate resistance value of thermistor
16 double tempK = 1 / (1 / (273.15 + 25) + log(Rt / 10) / 3950.0); //calculate temperature (Kelvin)
17 double tempC = tempK - 273.15; //calculate temperature (Celsius)
18 Serial.printf("ADC value : %d,\tVoltage : %.2fV, \tTemperature : %.2fC\n", adcValue, voltage, tempC);
19 delay(1000);
20}
21
22
23
24
In the code, GPIO1 is connected to the thermistor circuit. ESP32-S3 reads the ADC value of GPIO1, calculates the voltage and resistance value of the thermistor according to Ohm’s law, and finally calculates the temperature value perceived by the thermistor according to the formula.







