LM35 is a temperature sensor that outputs an analog signal which is proportional to the instantaneous temperature. The output voltage can easily be interpreted to obtain a temperature reading in Celsius. The advantage of lm35 over the thermistor is it does not require any external calibration. Here the bar graph LED output is a very easy-to-understand level of output. We have used the LM35 three-pin temperature sensor and Arduino Uno to take input from LM35 and to control an array of LEDs. The LM35 temperature sensor is fairly precise, never wears out, works under many environmental conditions, and requires no external components to work. It provides a typical accuracy of ±0.5°C at room temperature and ±1°C over a full −55°C to +155°C temperature range.
Hardware Required
S.No | Components | Value | Qty |
---|---|---|---|
1 | Arduino Uno | – | 1 |
2 | Resistor | 220Ω,1KΩ | 1,1 |
3 | Temperature Sensor | LM35 | 1 |
4 | Connecting Wires | – | – |
5 | LED | – | 3 |
Circuit Diagram
LM35 Pinout
Temperature Level Bar Graph Arduino Sketch Code
int tempsensor = 0;
int firstled = 8;
int secondled = 9;
int thirdled = 10;
int fourthled = 11;
int fifthled = 12;
int buzzerpin = 7;
void setup()
{
Serial.begin(9600);
pinMode(firstled,OUTPUT);
pinMode(secondled,OUTPUT);
pinMode(thirdled,OUTPUT);
pinMode(fourthled,OUTPUT);
pinMode(fifthled,OUTPUT);
pinMode(buzzerpin,OUTPUT);
}
void loop()
{
tempsensor=analogRead(0);
if(tempsensor<=129)
{
digitalWrite(firstled,HIGH);
digitalWrite(secondled,LOW);
digitalWrite(thirdled,LOW);
digitalWrite(fourthled,LOW);
digitalWrite(fifthled,LOW);
digitalWrite(buzzerpin,LOW);
}
else if(tempsensor>=130&&tempsensor<155)
{
digitalWrite(firstled,LOW);
digitalWrite(secondled,HIGH);
digitalWrite(thirdled,LOW);
digitalWrite(fourthled,LOW);
digitalWrite(fifthled,LOW);
digitalWrite(buzzerpin,LOW);
}
else if(tempsensor>=155&&tempsensor<165)
{
digitalWrite(firstled,LOW);
digitalWrite(secondled,LOW);
digitalWrite(thirdled,HIGH);
digitalWrite(fourthled,LOW);
digitalWrite(fifthled,LOW);
digitalWrite(buzzerpin,LOW);
}
else if(tempsensor>=165&&tempsensor<180)
{
digitalWrite(firstled,LOW);
digitalWrite(secondled,LOW);
digitalWrite(thirdled,LOW);
digitalWrite(fourthled,HIGH);
digitalWrite(fifthled,LOW);
digitalWrite(buzzerpin,LOW);
}
else if(tempsensor>=180&&tempsensor<200)
{
digitalWrite(firstled,LOW);
digitalWrite(secondled,LOW);
digitalWrite(thirdled,LOW);
digitalWrite(fourthled,LOW);
digitalWrite(fifthled,HIGH);
digitalWrite(buzzerpin,LOW);
}
else if(tempsensor>200)
{
digitalWrite(firstled,HIGH);
digitalWrite(secondled,HIGH);
digitalWrite(thirdled,HIGH);
digitalWrite(fourthled,HIGH);
digitalWrite(fifthled,HIGH);
digitalWrite(buzzerpin,HIGH);
}
Serial.println(tempsensor);
delay(150);
}
Applications
- Measuring the temperature of a particular environment.
- Monitoring battery temperature
- Can be used in HVAC applications.