Wednesday, 22 October 2014

Temperature sensor Interfacing with Arduino

Temperature Sensor Interfacing with Arduino

Sensor is a transducer which converts one form of energy into another form. Sensor converts physical quantity into electrical signals (It can be regarded as electrical transducer converting non electrical quantity into electrical quantity). In temperature sensor temperature is converted into electrical signals.

Most widely used temperature sensors are-
LM 35
LM 34

In LM 34 the o/p voltage is linearly proportional to the Fahrenheit temperature. It does not require any external calibration since it is internally calibrated. Its o/p changes by 10 mV for each degree Fahrenheit temperature change.

In LM 35 the o/p voltage is linearly proportional to the Celcius temperature. It also does not require any external calibration since it is internally calibrated. Its o/p changes by 10 mV for each degree centigrade temperature change.

In some cases the o/p of the sensor is not in the form of voltage, so signal conditioning is done before giving the o/p of the sensor to the ADC (Analog to Digital Converter). The conversion of the o/p signal of sensor which is not of the voltage form into a voltage signal is commonly called signal conditioning. Signal conditioning can be a current to voltage conversion or signal amplification. 

Fig.below shows a pictorial view of LM 35 temperature sensor-


























After signal conditioning the analog voltage signal is given to the ADC which performs analog to digital conversion. Digital data o/p of the ADC is read by the micro-controller, which is programmed to display the temperature on the o/p display. O/P display can be LCD, seven segment display etc.

Block Diagram of temperature measurement system is shown below -

In this project I have used internal ADC of the arduino to perform A to D conversion. The o/p of LM 35 is in the form of voltage so as such there is no need for any signal conditioning.  The digital o/p of the temperature is shown on 16*2 LCD display.

Arduino Uno has 6 channel 10 bit A to D converter. It will map input voltages in the range of 0 and  5 volts into integer value b/w 0 and 1023. So resolution is-

5Volts/1024 = 4.9 mV per unit.

It takes about 100 microseconds to read an analog input.

The function which is used for converting analog quantity into digital is-

analogRead(pin)  

Syntax-

analogRead(pin)

Parameters
pin: the number of the analog input pin to read from (0 to 5 on Arduino Uno)

Returns
int (0 to 1023)

Note

If the analog input pin is not connected to anything, the value returned by analogRead() function will fluctuate based on a number of factors (e.g. the values of the other analog inputs, how close your hand is to the board, etc.).

Circuit diagram-


The o/p of LM 35 sensor is connected to analog channel A0. The analog o/p voltage of the sensor is converted into integer value by in built ADC using analogRead(A0) function. This integer value is caliberated in the program to display the correct temperature reading on the LCD dsplay.

Note -  Here 16*2 lcd is used in 4 bit mode.
 

Code-

float tempC;    //  temprature in celcius
#include <LiquidCrystal.h>    //lcd library
LiquidCrystal lcd(12, 11, 10, 9, 8, 7);    //lcd control & data pins

void setup ()
{
  lcd.begin(16, 2); //lcd with display of 16*2 
  lcd.print("TEMP:");   //display "TEMP:" on lcd screen
  delay(1000); //wait for 1 seconds
}                    
      
void loop()
{
  tempC = analogRead(A0);  // tempC is equal to data coming from lm35
  tempC = ((tempC * 5000)/1024)/10;  //program caliberation

  lcd.setCursor(5,0); 
  lcd.print((byte)tempC);  // print or diplays the data (temprature in celcius) on lcd screen
}

Snap shot of the proteus software o/p is shown below-



On the same pattern any sensor can be connected to arduino and the o/p data can be shown on the lcd display. The only change will be in terms of the caliberation factor that will be used in the program code.

THANKS FOR READING………
                                                                                                                UMESH DUTTA

No comments:

Post a Comment