You are on page 1of 4

Temperature Detection using Temperature Sensor [LM35]

Aim:
To write a program for detecting the temperature using a temperature sensor(LM35) in
Arduino – UNO 3 board and verifying the output.
Requirement:
S. No Apparatus Quantity

1. Arduino UNO 3 board 1


2. Temperature sensor[LM35] 1
3. USB connector 1
4. Male-to-male As required
5. Bread board 1

Project Explanation:
Temperature Sensor LM35:
LM35 is a temperature-measuring device having an analog output voltage proportional to the
temperature. It provides output voltage in Centigrade (Celsius). It does not require any
external calibration circuitry. The sensitivity of LM35 is 10 mV/degree Celsius. As
temperature increases, the output voltage also increases. It is a 3-terminal sensor used to
measure surrounding temperatures ranging from -55 °C to 150 °C.LM35 gives temperature
output that is more precise than thermistor output.
Arduino UNO board:
A microcontroller board is based on the ATmega328P. It has 14 digital input/output pins (of
which 6 can be used as PWM outputs), 6 analog inputs, a 16 MHz quartz crystal, a USB
connection, a power jack, an ICSP header and a reset button. ,Connect it to a computer with
a USB cable or power it witan h AC-to-DC adapter or battery to get started.
Procedure for Connection:
Step 1 : Connect temperature sensor LM35 to the bread board.
Step 2 : Connect Arduino 5V to Sensor pin 1( Vcc)
Step 3 : Connect Arduino Ground pin to Sensor pin (GND pin)
Step 4 : Connect Arduino analog pin 0 to sensor pin 2
Step 5 : Upload the code and open the serial monitor to note readings of the
temperature.
Step 6: Set the serial monitor in 9600bauds.
Program Code:
int val;
int tempPin = 1;
void setup()
{
Serial.begin(9600);
}
void loop()
{
val = analogRead(tempPin);
float mv = ( val/1024.0)*5000;
float cel = mv/10;
float farh = (cel*9)/5 + 32;
Serial.print("TEMPRATURE = ");
Serial.print(cel);
Serial.print("*C");
Serial.println();
delay(1000);
/* uncomment this to get temperature in farenhite
Serial.print("TEMPRATURE = ");
Serial.print(farh);
Serial.print("*F");
Serial.println();
*/
}

Program Code Explanation:


The two first lines of the code are variables. It shows which pin the wire connects to. They
are integers and which proves that they do start with int. The void setup is really simple. Start
a serial connection with the Arduino at 9600 bauds. The four first lines of void loops are for
calculating what the Arduino will do to determine the temperature. It's the equations for
Celsius and farenheit . The five other lines, in void loop, will print the required words for the
temperature readings to print in serial monitor. The words are temperature, cel and C. The
other second half will print the same thing except for cel, which will be farh and C, which
will be F (it's optional).
Avinashilingam Institute for Home Science and Higher Education for Women (Deemed
to be University Estd. u/s 3 of UGC Act 1956, Category A by MHRD) Re-accredited
with A ++ Grade by NAAC. CGPA 3.65/4, Category 1 by UGC Coimbatore – 641043,
Tamil Nadu, India.
School of Engineering
(Approved by AICTE)
Ayya Avinashilingam Nagar, Varapalayam, Thadagam post, Coimbatore-641 108
Department of Electronics and Communication Engineering

Subject Code with Title: 20BELE21 - Fundamentals of IoT


Assignment Title : Temperature Detection using Temperature Sensor [LM35]
Name : Rakshana M, Priyatharshini A
Reg.No. : 20080UEL07, 20079UEL07
Degree : BE
Year : IIIrd year ECE
Semester : V

Submitted to

Mrs.R.Chitra (AP (SS))


Department of ECE

You might also like