Lesson 10 Thermistor

Share for us

Introduction

A thermistor is a type of resistor whose resistance varies significantly with temperature.

Components

– 1 * SunFounder Uno board

– 1 * USB data cable

– 1 * Breadboard

– 1 * Thermistor

– Several jumper wires

– 1 * Potentiometer (50KΩ)

– 1 * Resister (10KΩ)

– 1 * LCD1602

Experimental Principle

The resistance of the thermistor varies significantly with ambient temperature. It can detect surrounding temperature changes in real time. Send the temperature data to analog I/O port of SunFounder Uno board. Next we only need to convert sensor output to Celsius temperature by simple programming and display it on the LCD1602.

Experimental Procedures

Step 1: Build the circuit

The schematic diagram

Step 2: Program (Please refer to the example code in LEARN -> Get Tutorials on our website)

Step 3: Compile the code

Step 4: Upload the sketch to the SunFounder Uno board

Now, you can see current temperature displayed on LCD1602 both in Celcius and Fahrenheit degrees.

Code

// include the library code:
#include <LiquidCrystal.h>
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(4, 5, 10, 11, 12, 13);#define analogPin A0 //the thermistor attach to
#define beta 4090 //the beta of the thermistor
#define resistance 10 //the value of the pull-up resistorvoid setup()
{
// set up the LCD’s number of columns and rows:
lcd.begin(16, 2);
lcd.clear();
}void loop()
{
//read thermistor value
long a =analogRead(analogPin);
//the calculating formula of temperature
float tempC = beta /(log((1025.0 * 10 / a – 10) / 10) + beta / 298.0) – 273.0;
float tempF = 1.8*tempC + 32.0;
lcd.setCursor(0, 0); // set the cursor to column 0, line 0
lcd.print(“Temp: “);// Print a message of “Temp: “to the LCD.
// Print a centigrade temperature to the LCD.
lcd.print(tempC);
// Print the unit of the centigrade temperature to the LCD.
lcd.print(char(223));//print the unit” ℃ “
lcd.print(“C”);
// (note: line 1 is the second row, since counting begins with 0):
lcd.setCursor(0, 1); // set the cursor to column 0, line 1
lcd.print(“Fahr: “);
lcd.print(tempF);// Print a Fahrenheit temperature to the LCD.
lcd.print(” F”); // Print the unit of the Fahrenheit temperature to the LCD.
delay(200); //wait for 100 milliseconds
}

Video