Chapter 12 Thermistor
In this chapter, we will learn about thermistors which are another kind of resistor
Project 12.1 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.
Component List
ESP32-WROVER x1
|
GPIO Extension Board x1
|
|
Breadboard x1
|
||
Thermistor x1
|
Resistor 10kΩ x1
|
Jumper M/M x3
|
Component knowledge
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:
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
|
Code
Move the program folder “Freenove_Super_Starter_Kit_for_ESP32/Python/Python_Codes” to disk(D) in advance with the path of “D:/Micropython_Codes”.
Open “Thonny”, click “This computer” -> “D:” -> “Micropython_Codes” -> “12.1_Thermometer” and double click “Thermometer.py”.
12.1_Thermometer
Click “Run current script” and “Shell” will constantly 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:
1from machine import Pin,ADC
2import time
3import math
4
5adc=ADC(Pin(36))
6adc.atten(ADC.ATTN_11DB)
7adc.width(ADC.WIDTH_12BIT)
8try:
9 while True:
10 adcValue=adc.read()
11 voltage=adcValue/4095*3.3
12 Rt=10*voltage/(3.3-voltage)
13 tempK=(1/(1/(273.15+25)+(math.log(Rt/10))/3950))
14 tempC=tempK-273.15
15 print("ADC value:",adcValue,"\tVoltage :",voltage,"\tTemperature :",tempC);
16 time.sleep_ms(1000)
17except:
18 pass
In the code, the ADC value of ADC module A0 port is read, and then it calculates the voltage and the resistance of Thermistor according to Ohms Law. Finally, it calculates the temperature sensed by the Thermistor, according to the formula.







