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

Chapter01_00

GPIO Extension Board x1

Chapter01_01

Breadboard x1

Chapter01_02

Thermistor x1

Chapter13_00

Resistor 10kΩ x1

Chapter07_04

Jumper M/M x3

Chapter01_05

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.

../../../_images/Chapter13_01.png

The relationship between resistance value and temperature of a thermistor is:

../../../_images/Chapter13_02.png

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:

../../../_images/Chapter13_03.png

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:

../../../_images/Chapter13_04.png

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

Chapter13_05

Hardware connection

If you need any support, please contact us via: support@freenove.com

Chapter13_06

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

../../../_images/Chapter13_09.png

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

../../../_images/Chapter13_10.png

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.