temperature sensor with arduino

Temperature Sensor with Arduino LM35

In the practical temperature sensor with Arduino, we will use LM35 as temperature sensor.

Here,we are going to make Temperature indicator project.

TEMPERATURE RANGELED INDICATOR
20<T<=22 DegreeBLUE
For 22<T<=24BLUE, GREEN
For 24< T <=26BLUE , GREEN & YELLOW
For26< T <=28BLUE , GREEN , YELLOW & ORANGR
For T> 28ALL LED ON

About LM35

It is Temperature sensor.

Components Required

I have provided the links from which i recommend to purchase for this project, you can buy same from electronics project shop too.

Circuit

temperature sensor with arduino
Temperature sensor with Arduino

Programming for Temperature sensor with Arduino

// Declare the LEDs in an array
int LED [5] = {2, 3, 4, 5, 6};
int sensorPin = A0; // Declare the used sensor pin
void setup(){
// Start the Serial connection
Serial.begin(9600);
// Set all LEDs as OUTPUTS
for (int i = 0; i < 5; i++){
pinMode(LED[i], OUTPUT);
}
}
void loop(){
// Read the value of the sensor
int val = analogRead(sensorPin);
Serial.println(val); // Print it to the Serial
// On the LM35 each degree Celsius equals 10 mV
// 20C is represented by 200 mV which means 0.2 V / 5 V * 1023 = 41
// Each degree is represented by an analogue value change of approximately 2
// Set all LEDs off
for (int i = 0; i < 5; i++){
digitalWrite(LED[i], LOW);
}
if (val > 40 && val < 45){ // 20 - 22 C
digitalWrite( LED[0], HIGH);
} else if (val > 45 && val < 49){ // 22 - 24 C
digitalWrite( LED[0], HIGH);
digitalWrite( LED[1], HIGH);
} else if (val > 49 && val < 53){ // 24 - 26 C
digitalWrite( LED[0], HIGH);
digitalWrite( LED[1], HIGH);
digitalWrite( LED[2], HIGH);
} else if (val > 53 && val < 57){ // 26 - 28 C
digitalWrite( LED[0], HIGH);
digitalWrite( LED[1], HIGH);
digitalWrite( LED[2], HIGH);
digitalWrite( LED[3], HIGH);
} else if (val > 57){ // Over 28 C
digitalWrite( LED[0], HIGH);
digitalWrite( LED[1], HIGH);
digitalWrite( LED[2], HIGH);
digitalWrite( LED[3], HIGH);
digitalWrite( LED[4], HIGH);
}
delay(100); // Small delay for the Serial to send
}

Result

As we increase the temperature around Sensor, its output voltage rises and consequently LED turns ON and we know what temperature range current prevails around us!

To do more practicals with arduino click here

Leave a Reply

Your email address will not be published. Required fields are marked *