Menu Close

Arduino – LM 35 Temperature Sensor

This tutorial explain to use LM 35 Temperature sensor on Arduino Platform. This tutorial has got two example both of the example reads temperature, one displays it on LCD where as other one displays at serial monitor.

1. Introduction:

This tutorial deals with LM 35 Temperature sensor. It has two examples both read temperature through LM 35 Temperature sensor, one display the temperature on LCD where as other examples displays at serial monitor.

1.2 LM 35 Temperature sensor

It is a 3 pin IC, Operated on 4 to 20 volt. It gives output in voltage according to the temperature. 10 mili volt per degree Celsius is the output format of this sensor.

1.3 Pinout of LM 35 Temperature Sensor

2. Required Hardware

Following Hardware will be required to perform this LED fade in and fade out circuit.

S.No.ItemQuantity
1.R-Board with FTDI or Arduino Board1
2.Bread Board1
3.Male to male Jumpers 24
4.16×2 LCD1
51K Potentiometer1
6.LM-35 Temperature Sensor1

3. Building Circuit – 1 (Displays Temperature on LCD)

To run these practical examples make following circuit with the help of above mentioned components.

3.1 You may go with Robo India’s R-Board(UNO Compatible)-

here is the schematic:

or

3.2 You may go with original Arduino UNO Board-

here is the schematic:

4. Programming – 1 (To display temperature on LCD):

Once we are done with circuit part, here is our programme to this circuit. All of the commands are explained in the comment section. Output video is attached at the last of this tutorial, This example will be clear after watching the video.

You may download code (Arduino Sketch) from here.

/*
Temerature on 16X2 LCD Tutorial by ROBO INDIA
LM 35 Temp. IC is used.
http://roboindia.com/
*/

#include <LiquidCrystal.h> //includes LCD library.


LiquidCrystal MyLCD(12, 11, 5, 4, 3, 2); // Defining LCD.
int temp_pin = A0;  // LM 35 is connected to A0 Pin.
float temp;         // Variable to store temperature value.

void setup() {
   MyLCD.begin(16, 2); // Initializing 16X2 LCD.
   MyLCD.home(); // Home location : 0,0 
   MyLCD.print("Robo India"); // Print on LCD.
   MyLCD.setCursor(0, 1);
   MyLCD.print("LM 35 Tutorial");
   delay(4000);  
}

void loop() {
  
  MyLCD.clear();     // Clearing LCD
  MyLCD.home();      // Cursor set to 0,0
  temp = ReadTemp(); // Reading Temperature. 
  MyLCD.print("Temperature is-");
  MyLCD.setCursor(0,1);
  MyLCD.print(temp); // Printing Temperature of LCD.
  MyLCD.print(" Deg. C.");
  delay(1000);       // delay of 1 second.  
}

// Function to read temperature.
float ReadTemp(){
int ip_adc_val = 0;
float temp =0;
temp = (5.0 * analogRead(temp_pin) * 100.0) / 1024;
return temp;
}

5. Circuit -2 (Displays temperature on Serial Monitor):

You need to make following circuit to run this programme.

5.1. You may go with Robo India R-Board (Arduino UNO based)-

here is the schematic of above circuit:

5.2. or You may go with original Arduino Board –

here is the schematic of above circuit:

6. Programming – 2 (Displays temperature on Serial Monitor):

This is the programme for the above mentioned circuit -2. This sketch is written to read temperature from LM 35 Temperature sensor IC and to display the read temperature at serial monitor. After uploading this programme to the Arduino Board, you will need to start Serial Monitor to see the result. We have included Screen shot of output at serial monitor.

All of the commands used in this sketch is explained in comment section.

You may download this sketch from here.

/*
Temperature on serial monitor Tutorial by ROBO INDIA
LM 35 Temp. IC is used.
http://roboindia.com/
*/

int temp_pin = A0;  // LM 35 is connected to A0 Pin.
float temp;         // Variable to store temperature value.

void setup() {
   Serial.begin(9600); // Serial comm. starting.
   Serial.println("Robo India"); 
   Serial.println("LM 35 Tutorial");
   delay(2000);  
}

void loop() {
  
  temp = ReadTemp(); // Reading Temperature. 
  Serial.print("Temperature is-");
  Serial.print(temp); // Printing Temperature on serial port
  Serial.print(" degree celsius\n");
  delay(1000);       // delay of 1 second.  
}

// Function to read temperature.
float ReadTemp(){
int ip_adc_val = 0;
float temp =0;
temp = (5.0 * analogRead(temp_pin) * 100.0) / 1024;
return temp;
}

7. output:

Here is the output of this tutorial. Above code is implemented on Robo India R-Board and Arduino UNO Both.

8. Screenshot of Serial output:

Here is the screenshot of serial output. (For example -2 : Displays Temperature on serial Monitor) 

If you have any query please write us at support@roboindia.com

Thanks and Regards
Content Development Team 
Robo India
http://roboindia.com


Leave a Reply