0% found this document useful (0 votes)
15 views7 pages

Experiment 4 - Temperature Sensor

temperature sensor
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
Download as pdf or txt
0% found this document useful (0 votes)
15 views7 pages

Experiment 4 - Temperature Sensor

temperature sensor
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
Download as pdf or txt
Download as pdf or txt
You are on page 1/ 7

Experiment No 4 Student ID

Date Student Name

Temperature measurement using LM35 and Arduino Genuino UNO

Aim/Objective: The main objective of this experiment is to interface Temperature


sensor LM35 with Arduino to measure the temperature.

Components required:

Software Hardware
Arduino UNO Board
Arduino UNO Cable
Tinkercad Temperature Sensor
Arduino IDE (To be installed in Laptop) LED (Red-1, Green-1, Blue-1)
LCD Display (16*2)
Resistors – 5 (220Ω each)
Jumper wires

Pre-Requisites:

 Basics of Arduino Uno


 Basics of temparature sensor

Pre-Lab:

1. What is a thermistor and how does it work?

A thermistor is a type of temperature sensor that changes its resistance with temperature
variations. Specifically, we will be using an NTC (Negative Temperature Coefficient)
thermistor, which has a higher resistance at lower temperatures and lower resistance at
higher temperatures. By measuring the resistance of the thermistor, we can determine
the temperature.
2. How is the thermistor connected to the Arduino Genuino UNO?

The thermistor is connected to the Arduino Genuino UNO using two wires. One end of
the thermistor is connected to the 5V pin of the Arduino, and the other end is connected
to an analog input pin (e.g., A0). Additionally, a resistor (typically 10k ohms) is
connected in parallel with the thermistor, with one end connected to the analog input
pin and the other end connected to ground.
3. How can we convert the analog reading from the thermistor into temperature
values?

We can convert the analog reading from the thermistor into temperature values using
either the Steinhart-Hart equation or a lookup table. The Steinhart-Hart equation is a
mathematical formula that relates the resistance of the thermistor to temperature. A
lookup table, on the other hand, maps specific resistance values to corresponding
temperature values.
4. What is the purpose of the resistor connected in parallel with the thermistor?

The resistor connected in parallel with the thermistor forms a voltage divider circuit. It
helps to create a known reference voltage for the analog input pin of the Arduino. This
allows us to accurately measure the voltage across the thermistor and calculate its
resistance, which is then used to determine the temperature.

5. How can we improve the accuracy of temperature measurements using the


thermistor and Arduino Genuino UNO?

To improve accuracy, we can calibrate the thermistor by comparing its readings with a
known temperature source. This allows us to create a more accurate mapping between
resistance and temperature. Additionally, ensuring a stable power supply and
minimizing noise interference can also improve the accuracy of temperature
measurements.

In-Lab:

Program:

void setup()
{
Serial.begin(9600);
pinMode(A0, INPUT);
pinMode(2,OUTPUT);
pinMode(3,OUTPUT);
pinMode(4, OUTPUT);
}

void loop()
{
int baselineTemp = 30;
int sensor_data = analogRead(A0);
float voltage = sensor_data * (5.0 / 1024.0);
float celsius = (voltage - 0.5) * 100;
float fahrenheit = ((celsius*9) / 5 + 32);
Serial.print(celsius);
Serial.print(" C, ");
Serial.print(fahrenheit);
Serial.println(" F");
if (celsius < baselineTemp)
{
digitalWrite(2, LOW);
digitalWrite(3, LOW);
digitalWrite(4, LOW);
}

if (celsius >= baselineTemp && celsius < baselineTemp + 10)


{
digitalWrite(2, HIGH);
digitalWrite(3, LOW);
digitalWrite(4, LOW);
}
if (celsius >= baselineTemp + 10 && celsius < baselineTemp + 20)
{
digitalWrite(2, HIGH);
digitalWrite(3, HIGH);
digitalWrite(4, LOW);
}
if (celsius >= baselineTemp + 20)
{
digitalWrite(2, HIGH);
digitalWrite(3, HIGH);
digitalWrite(4, HIGH);
}
delay(1000);
}

Procedure:
 Give the connections to the Arduino board as shown in the connection diagram.
 Open Arduino IDE in the computer
 Create new file File_--→ New
 Type your program and Save it in appropriate location in your computer.
 Compile your program by clicking Verify option in the menu.
 Once the program compiled successfully, connect the Arduino board to the computer
using USB cable.
 After connecting, go to Tools ----→Board ---→ Select Arduino/Genuino Uno option
 After selecting board, go to Tools ----→Port ---→ Select Arduino Uno COM port 3
 (name may appear differently for other computers).
**Note: that this port option will be displayed only when board is connected to computer
 Now upload the program to the Arduino board by clicking Upload option.
 Observe the output.
Connection Diagram:

Results:

Analysis and Inferences:


VIVA-VOCE Questions (In-Lab):

1. What is a thermistor?
A thermistor is a type of temperature sensor that changes its resistance with temperature
variations.

2. How is the thermistor connected to the Arduino Genuino UNO?


Answer: The thermistor is connected to the Arduino Genuino UNO using two wires.
One end of the thermistor is connected to the 5V pin of the Arduino, and the other end
is connected to an analog input pin (e.g., A0).

3. How can we convert the analog reading from the thermistor into temperature
values?

We can convert the analog reading from the thermistor into temperature values using
either the Steinhart-Hart equation or a lookup table.

4. How can we improve the accuracy of temperature measurements using the


thermistor and Arduino Genuino UNO?

We can improve the accuracy of temperature measurements by calibrating the


thermistor using a known temperature source and ensuring a stable power supply and
minimizing noise interference.

5. What are some applications of temperature measurement using a thermistor and


Arduino Genuino UNO?

Some applications of temperature measurement using a thermistor and Arduino


Genuino UNO include environmental monitoring, home automation, industrial process
control, and temperature-based alarms or safety systems.
Post-Lab:
Temparature measurement using thermistor and Display on LCD Screen
This program reads the analog value from the thermistor connected to pin A0 of the
Arduino Genuino UNO. It then calculates the voltage across the thermistor, the resistance
of the thermistor, and finally, the temperature using the Steinhart-Hart equation. The
temperature is displayed on the Serial Monitor.

Program:

// include the library code for LCD display:


#include <LiquidCrystal.h>

// initialize the library with the numbers of the interface pins


LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

// Defining pin
#define temp A5
#define led 13

void setup()
{
// set up the LCD's number of columns and rows:
lcd.begin(16, 2);
pinMode(led, OUTPUT);
pinMode(temp, INPUT);
Serial.begin(9600);
lcd.clear();
lcd.print("Temperature: ");
}
//Global Variable
float pre_temp = 0;
void loop()
{
float temperature = 0;
temperature = (analogRead(temp) * 0.48828125) - 49.95;
if(pre_temp != temperature)
{
lcd.setCursor(0,1);
lcd.print(" ");
}
lcd.setCursor(0,1);
lcd.print(temperature);
lcd.print(" C");
pre_temp = temperature;
}

Results:

Evaluator Remark (if Any):


Marks Secured: out of 50

Signature of the Evaluator with Date

You might also like