Ever wonder how you can detect temperature in your projects? You can do so by using temperature sensor such as LM35 Precision Centrigrade Temperature Sensor. LM35 is a temperature whose voltage is linearly propotional to Celsius temperature. If you need other units such as Kelvin or Fahrenheit, you can apply some conversion from Celsius.

Image
Temperature conversion from Celsius taken from Wikipedia.

Lets us look at the LM35 now. Some of the features of LM35:

– Calibrated directly in Celcius

– Linear +10mV/Celsius scale factor

– Operates from 4V to 30V

Image
Pin for LM35

We can also get the connection diagram from datasheet. Take note that this is the bottom view of LM35. (I had mistakenly connect it as top view, my LM35 gets very hot immediately >.<)

Image
Connection Diagram from Datasheet.
temp9
Schematic Diagram

The output from LM35 is analog output. Analog output means your output will be a voltage in the range of 0V to 5V (in this case), instead of just 0V(LOW) and 5V(HIGH). So to read an analog reading from Arduino, you need to use analogRead(pin).

The sample code on Arduino:


#include <LiquidCrystal.h>
#define sensor A1
float volt;

LiquidCrystal lcd(5,6,7,8,9,10);

void setup()
{
 lcd.begin(16,2);
 pinMode(sensor,INPUT);
}

void loop()
{
 float reading=analogRead(sensor);
 volt=(reading/1023)*5;
 lcd.setCursor(0,0);
 lcd.print("ADC :");
 lcd.setCursor(9,0);
 lcd.print((int)reading);
 lcd.setCursor(0,1);
 lcd.print("Voltage:");
 lcd.setCursor(9,1);
 lcd.print(volt);
 lcd.setCursor(13,1);
 lcd.print("V");
 delay(500);
}

Some photos of the circuit.

Image

Image

Image

A video demonstration for this sensor, enjoy.

Drop me a comment if you have any questions on LM35, I will try my best to answer. 🙂

Advertisements