TEMPERATURE SENSOR AND ARDUINO

LM35 is an analog type temperature sensor, whose output voltage varies linearly with change in temperature; LM35 is a three terminal sensor. Here we will see how to interface temperature sensor and arduino to display output on LCD.

It is capable of measuring temperature from –55 degree Celsius to +150 degree Celsius. The output voltage of the LM35 increases 10mV per degree Celsius rise in temperature. LM35 operate with a 5V supply. The pin diagram of LM35 is shown in the figure below.

LM35 Temperature Sensor Pinout

Note: LM35 is available in the market in 3 series variations – LM35A, LM35C and LM35D series. The main difference between these 3 versions of LM35 IC is in their range of temperature measurements.

  1. The LM35D series is designed to measure from 0 degree Celsius to 100 degree Celsius, where as
  2. LM35A series is designed to measure a wider range of –55 degree Celsius to 155 degree Celsius.
  3. The LM35C series is designed to measure from –40 degree Celsius to 110 degree Celsius.

We are using the LM35Dz sensor which is category 1

WORKING TEMPERATURE SENSOR AND ARDUINO

Arduino Uno and LM35 can be connected as shown in circuit diagram.

Interfacing of Temperature Sensor and Arduino Output on LCD

LM35 is an analog sensor, so the output of LM35 is an analog signal. Microcontrollers are not capable of reading analog signals as their input directly. We need to convert this analog signal to digital before we can feed it to a microcontroller’s input. For that, we can use an ADC chip (Analog to Digital Converter).

How to convert analog value to digital ADC Conversion 

If we are using a microcontroller like 8051 etc., we need to use an external ADC to convert analog output of LM35 to digital. Then, we feed the output of ADC (converted digital value) to input of 8051. But modern day development boards like Arduino and most modern day microcontrollers come with inbuilt ADC.

Our Arduino Uno has an in built 10 bit ADC (6 channel). We can make use of this in built ADC of arduino to convert the analog output of LM35 (or other device/sensor) to digital output.As Arduino Uno has a 6 channel inbuilt ADC, there are 6 analog input pins numbered from A0 to A5. You can connect analog out of LM35 to any of these analog input pins of arduino but we are using A0 for now.

Required Hardware

S.No. Item Quantity
1 LM35 temperature sensor 1
2 POT 10K 1
3 LCD 1
4 Arduino Board 1
5 Breadboard 1
6 Battery 5V / 9V 1
7 Male to Female jumper 14
8 Male to Male 3

Here we connected Pins describe below

Arduino pin LCD POT
GND 1 – VSS  
+ 5V 2 – VDD/VCC  
  3 – VEE POT
2 4 – RS (Reset)  
3 5 – RW (Read/Write)  
GND 6 – E (Enable)  
7 – D0  
8 – D1  
9 – D2  
10 – D3  
4 11 – D4  
5 12 – D5  
6 13 – D6  
7 14 – D7  
+ 5V 15 – Anode (+)  
GND 16 – Cathode (–)  

 

Arduino pin LM35 temperature Sensor
+5V VCC
GND GND
A0 VOUT

TEMPERATURE SENSOR ARDUINO CODE

#include<LiquidCrystal.h>
LiquidCrystal lcd(2, 3, 4, 5, 6, 7); //(RS,RW,D4, D5, D6, D7)
int pin, t, r;

void setup() {
  lcd.begin(16, 2);
  pinMode(13, OUTPUT);
  pinMode(11, OUTPUT);
}

void loop() {
  pin = analogRead(A0);

  /*output of 1 degree C Temp is 0.01, Maximum input to MCU is 10 bit i.e 1023 in decimal, Input reference voltage to LM35 is 5 V => (0.01 * 1023)/5 = 2.046
  */
  t = pin / 2.046;
  lcd.setCursor(0, 0);
  lcd.print(t);
  delay(1000);

  if (t >= 25) {
    lcd.setCursor(0, 0);
    lcd.print(t);
    digitalWrite(10, HIGH);
    delay(1000);
    lcd.clear();
  }

  else if (t < 25) {
    lcd.setCursor(0, 0);
    lcd.print(t);
    digitalWrite(10, LOW);
    delay(1000);
    lcd.clear();
  }
}

OUTPUT

As temperature goes higher than 25 then pin number 10 will be set as high so if we connect buzzer on that it will make alarming sound.

OUTPUT LM35 TEMPERATURE SENSOR

Leave a Reply

avatar
  Subscribe  
Notify of

Arduino Tutorials with Basic Electronics: CONTENT

Translate »