Lesson 10 Analog Temperature Sensor

Share for us
Share on facebook
Share on twitter
Share on pinterest
Share on whatsapp


A thermistor is the core component of an analog temperature sensor (as shown below).


– 1 * SunFounder Uno board

– 1 * USB data cable

– 1 * Analog Temperature Sensor module (thermistor)

– 1 * LCD1602

– 1 * Potentiometer

– Several jumper wires

Experimental Principle

This module is based on thermistor principle, whose resistance varies significantly with ambient temperature changes. It can detect surrounding temperature changes in real time and send the temperature data to analog I/O port of the SunFounder Uno board. You only need to convert the output to Celsius temperature by simple programming and display it on an LCD.

Experimental Procedures

Step 1: Build the circuit

                     Analog Temperature Sensor Module          SunFounder Uno

                                                  S —————————————-A0

                                                – —————————————- GND

                                                  + ————————————— 5V

LCD1602 connection: connect pin RS to digital pin 4; R/W to GND; E to digital pin 5; D4~D7 to digital pin 9 to 12; VSS to GND; VDD to 5V; A to 3.3V; K to GND

Potentiometer connection: Connect the middle pin to VO of LCD1602 and any other pin to GND

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

Step 3: Compile

Step 4: Upload the sketch to SunFounder Uno

Now, touch the thermistor and you can see the current temperature displayed on the LCD in both Celcius and Fahrenheit degrees.


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