Build Digital Thermometer using LM35 and Arduino

Build Digital Thermometer using LM35 and Arduino Build Digital Thermometer using LM35 and Arduino

Have you ever worried about the heat generated by some electronic components in your circuit projects? If the heat still raises then the components on your circuits will get damaged.  So to avoid this we are going to but a digital thermometer through which you can monitor temperature or you can make a power cut off when heat exceeds above limits.

So before getting started let’s check what are the required components for this project.

Requirements:

Hardware components required:

  • Arduino UNO R3
  • LM35 temperature sensor
  • LCD Display – JHD162A 16×2
  • I2C adapter for LCD (optional)
  • Green LED light
  • Red LED light
  • 2 X 100 ohm resistors.
  • Connecting wires.

Software requirements:

  • Arduino IDE

LM35 Temperature sensor

The LM35 is a good performance temperature sensor at a low price. It has a working range from -55ºC to 150ªC. Its output is analog and linear type with a slope of 10mV / ºC. The sensor is factory calibrated to an accuracy of 0.5ºC.

It is a very popular sensor for its easy use and varied applications. It does not need any additional circuit to be used. It is powered directly from a 5V source and delivers an analog output between 0V to 1.5V. This analog voltage can be read by the ADC from a microcontroller like PIC or Arduino. Among its applications we can find thermometers, thermostats, monitoring systems and more.

Features of LM35

  • Operating Voltage: 4V – 30V (5V recommended)
  • Working Range: -55 ℃ to + 150 ℃
  • Accuracy in the range from -10 ° C to + 85 ° C: ± 0.5 ° C
  • Slope: 10mV / ºC
  • Low energy consumption: 60uA
  • No need for additional components
  • Pins: + VCC, V output, GND
  • Low output impedance

Circuit diagram interfacing LM35 with Arduino

Let’s connect all the components as shown in the schematic diagram image below

Build Digital Thermometer using LM35 and Arduino circuit diagramIn above picture we connected lm35 temperature sensor to Arduino as first pin for power source is connected to 5V on the Arduino and the second pin is connected to A2 of Arduino analogue pin and the third one is connected to GND of Arduino UNO.

We connected 16 X 2 LCD display with the help of I2C adapter, all the connection pins are given in the image which has two pins for power and ground and another two for SDA and SCL.

We connected two small Red and Green 5mm LED light to digital pins 6 and 7 and we connected 100 ohms resistors along the ground of LED lights.

If you want to connect the LCD with out I2C adapter follow the instructions here.

Code to Upload:

If you use the I2C adapter you need to use a library.

we will use the LiquidCrystal_I2C library. Download here.

#include <LiquidCrystal_I2C.h> //If you use I2c adapter.

#define LM35 A2
#define RED 7
#define GREEN 6

byte degree[8] =
{
0b00011,
0b00011,
0b00000,
0b00000,
0b00000,
0b00000,
0b00000,
0b00000
};

float lm_value;
float tempc;

// Create the lcd object address 0x3F and 16 columns x 2 rows 
LiquidCrystal_I2C lcd (0x3F, 16,2);  //

void setup() {
  Serial.begin(9600);
 // Initialize the LCD connected 
  lcd. init ();
// Turn on the backlight on LCD. 
  lcd. backlight ();
  pinMode(RED, OUTPUT);
  pinMode(GREEN, OUTPUT);

lcd.createChar(1, degree);
lcd.setCursor(0,0);
lcd.print(" Digital ");
lcd.setCursor(0,1);
lcd.print(" Thermometer ");
delay(2000);
lcd.clear();

}

void loop() {
  lm_value = analogRead(LM35);
  tempc = (lm_value * 500) / 1023;
  Serial.println(tempc);//Temperature in Celcius

/*------Display Result------*/

lcd.setCursor(2,0);
lcd.print("Temperature");
lcd.setCursor(4,1);
lcd.print(tempc);
lcd.write(1);
lcd.print("C");


  //Condition
  if (tempc > 60) {    // here you can change the temperature threshold value of led changes
    digitalWrite(RED, HIGH);
    digitalWrite(GREEN, LOW);
  }
  else {
    digitalWrite(GREEN, HIGH);
    digitalWrite(RED, LOW);
  }
  delay(1000);
}

Working of Digital thermometer using Arduino:

After uploading the code you will notice the live temperature for the sensor is displayed on the 16 X 2 LCD display. If the temperature raised above 60 the red LED will light up and if the temperature is below 60 Green LED will light up.  You can adjust the threshold temperature in the above code to make the lights change at what temperature you want.

Build Digital Thermometer using LM35 and Arduino outputAdvantages and Applications:

  • Monitor the components temperature but putting sensor beside them
  • Sensor is small so it can be used in wide variety of application.
  • It gives nearly accurate results with only ±0.5 C error .
  • Can be used to measure skin temperature
  • Can be used to measure liquids temperature but we need to cover the pins with water proof material.