A temperature sensor is a component that senses temperature and converts it into output signals. By material and component features, temperature sensors can be divided into two types: thermal resistor and thermocouple. Thermistor is one kind of the former type. It is made of semiconductor materials; most thermistors are negative temperature coefficient (NTC) ones, the resistance of which decreases with rising temperature. Since their resistance changes acutely with temperature changes, thermistors are the most sensitive temperature sensors.

There are two kinds of thermistor module in this kit (as shown below).

Components

-1 * Raspberry Pi

-1 * Breadboard

- 4 * Jumper wires (Male to Male, 2 red and 2 black)

- 1 * Network cable (or USB wireless network adapter)

- 1 * Analog-temperature Sensor module

- 1 * Thermistor module

- 1 * PCF8591

- 1 * 3-Pin anti-reverse cable

- 1 * 4-Pin anti-reverse cable

- Several Jumper wires (Male to Female)

Experimental Principle

This module is based on the principle of the thermistor, whose resistance varies significantly with ambient temperature. When the ambient temperature increases, the resistance of the thermistor decreases; when decreases, it increases. It can detect surrounding temperature changes in a real-time manner.

In this experiment, we use an analog-digital converter PCF8591 to convert analog signals into digital ones.

The schematic diagram for analog temperature sensor is as shown below:

The schematic diagram for the thermistor module is as shown below:

Experimental Procedures

Step 1: Build the circuit

Raspberry Pi

T-Cobbler

PCF8591 Module

SDA

SDA1

SDA

SCL

SCL1

SCL

3V3

3V3

VCC

GND

GND

GND

For thermistor module:

Thermistor Module

T-Cobbler

PCF8591 Module

SIG

*

AIN0

VCC

3V3

VCC

GND

GND

GND

For analog temperature sensor module：

Analog Temperature Module

T-Cobbler

PCF8591 Module

DO

GPIO17

*

AO

*

AIN0

VCC

3V3

VCC

GND

GND

GND

For C language users:

Step 2: Change directory

cd /home/pi/SunFounder_SensorKit_for_RPi2/C/18_thermistor/

Step 3: Compile

gcc thermistor.c –lwiringPi -lm

Step 4: Run

sudo ./a.out

For Python users:

Step 2: Change directory

cd /home/pi/SunFounder_SensorKit_for_RPi2/Python/

Step 3: Run

sudo python 18_thermistor.py

Now touch the thermistor and you can see the value of current temperature printed on the screen change accordingly.

Temperature alarm setting:

If you use the Analog Temperature Sensor module, uncomment the line under 1:

You can still see temperature value printed on the screen constantly. If you pinch the thermistor for a while, its temperature will rise slowly. "Too Hot!" will be printed on the screen. Release your fingers, and let it stay in the open air for a while, or blow on the module. When the temperature drops down slowly, "Better" will be printed.

Note:

The analog temperature sensor adjusts alarm temperature by the potentiometer on the module. The thermistor changes the alarm temperature by program.