 # Arduino LM35 Temperature in degrees Celsius and Fahrenheit with LCD

In this project, we’ll show you how to lm35 interfacing with Arduino and how to program it. Once we successfully lm35 interface with Arduino, We’ll use an Arduino and an LCD 16×2 module to construct a temperature display. The display constantly monitors the temperature surrounding the LM35 measuring field and shows it on the LCD module display in degrees Celsius and Fahrenheit. So, let’s get started on the project!

LM35 Sensor is an analog temperature sensor having an analog output voltage proportional to the temperature. It shows the output voltage in degrees Centigrade (Celsius).  No external calibration circuit is required.

## What is LM35 Temperature Sensor?

LM35 sensor is a precision integrated-circuit temperature sensor, with an output voltage linearly proportional to the Centigrade temperature. The LM35 device has an advantage over linear temperature sensors calibrated in Kelvin, as the user is not required to subtract a large constant voltage from the output to obtain convenient Centigrade scaling. The LM35 device does not require any external calibration or trimming to provide typical accuracies of ± ¼ °C at room temperature and ± ¾ °C over a full −55°C to 150°C temperature range. Lower cost is assured by trimming and calibration at the wafer level.

The low output impedance, linear output, and precise inherent calibration of the LM35 device make interfacing to readout or control circuitry especially easy. The device is used with single power supplies, or with plus and minus supplies. As the LM35 device draws only 60 μA from the supply, it has very low self-heating of less than 0.1°C in still air. The LM35 device is rated to operate over a −55°C to 150°C temperature range, while the LM35C device is rated for a −40°C to 110°C range (−10° with improved accuracy).

## LM35 Temperature Calculation

When you use a 5V Arduino and directly connect the sensor into an analog pin, you can use the following formula to convert the 10-bit analog reading to a temperature:
This formula converts the ADC number 0-1023 to 0-5000mV (= 5V).

When you use a 3.3V Arduino, you need to use the following formula:
This formula converts the ADC number 0-1023 to 0-3300mV (= 3.3V)

Convert the millivolts into the temperature in degrees Celsius and Fahrenheit:
Centigrade temperature = (analog voltage in mV) / 10

## Features of LM35

• Calibrated Directly in Celsius (Centigrade)
• Output proportional to °C
• Linear + 10-mV/°C Scale Factor
• Operates From 4 V to 30 V
• Less Than 60 μA Current Drain
• Low-Impedance Output, 0.1 Ω for 1 mA Load
• Low-Cost Due to Wafer-Level Trimming
• Accuracy 0.5°C (at 25°C)
• LM35 range temperature −55°C to 150°C
• Low Self-Heating, 0.08°C in Still Air
• Non-Linearity Only ±¼°C Typical
• Suitable for Remote Applications

## LM35 Applications

• Temperature measurement in a specific environment
• Battery Temperature Monitoring
• Providing a circuit/component to thermal shutdown
• Temperature measurement for HVAC applications

## LM35 Temperature Sensor Circuit Diagram

Here LM35’s out pin goes to A0.

## LM35 Temperature Sensor Code

By clicking the button in the top right corner of the code field, you can copy the code. Copy and paste it into Arduino IDE.

```/*** www.arduinopoint.com ***/
/*** Arduino LM35 Temperature Sensor Project***/
// Define to which pin of the Arduino the output of the LM35 is connected:
#define sensorPin A0

void setup() {
// Begin serial communication at a baud rate of 9600:
Serial.begin(9600);
}

void loop() {
// Get a reading from the temperature sensor:

// Convert the reading into voltage:
//Convert digital data into analog by multiplying by 5000 and dividing by 1024
float voltage = reading * (5000 / 1024.0);
// Convert the voltage into the temperature in degree Celsius:
float temperatureC = voltage / 10;
float temperatureF=(temperatureC*1.8)+32; // Converting to Fahrenheit

// Print the temperature in Celsius into the Serial Monitor:
Serial.print("Temperature in Celsius    = ");
Serial.print(temperatureC);
Serial.print(" \xC2\xB0"); // shows degree symbol
Serial.println("C");

// Print the temperature in Celsius into the Serial Monitor:
Serial.print("Temperature in Fahrenheit = ");
Serial.print(temperatureF);
Serial.print(" \xC2\xB0"); // shows degree symbol
Serial.println("F");

Serial.print("\n");
delay(1000); // wait a second between readings
}```

You should see the following output in the Serial Monitor:

## Arduino Temperature Sensor LM35 with LCD Circuit Diagram Arduino Temperature Sensor LM35 with LCD Circuit Diagram

Most LCDs include a series resistor for the LED backlight. It should be connected to pin 15 on the back of the LCD (Anode). If your display doesn’t come with one, you’ll need to add one between 5 V and pin 15. A 220 resistor should be fine, but it may make your display a little dim. Check the datasheet for the maximum current rating of the backlight and use that to choose an appropriate resistor value.
You need to adjust the contrast of the LCD display. Turning the 10 kΩ potentiometer clockwise or counterclockwise accomplishes this.

## Arduino Temperature Sensor LM35 LCD Code

```/*** www.arduinopoint.com ***/
/*** Arduino LM35 Temperature Sensor Project with LCD ***/
// Define to which pin of the Arduino the output of the LM35 is connected:
#define sensorPin A0
#include<LiquidCrystal.h> //To include a library to write data on the 16*2 lcd device
LiquidCrystal lcd(8,9,10,11,12,13); //we have connected LCD pins to these pins on Arduino
byte degree =
{
0b00011,
0b00011,
0b00000,
0b00000,
0b00000,
0b00000,
0b00000,
0b00000
}; // These lines are to create a custom Degree sign
void setup()// this will run only on either on start-up or when arduino is reset
{
lcd.begin(16,2);
lcd.createChar(1, degree); //we assign a number 1 to the degree sign created above
lcd.setCursor(2,0);
lcd.print("Arduino Point");
lcd.setCursor(3,1);
lcd.print("Thermometer");
delay(2000); // Keep the words on screen for two seconds
lcd.clear(); // clear the screen for writing anything else
// Begin serial communication at a baud rate of 9600:
Serial.begin(9600);
}
void loop()// this function will keep on running
{
// Get a reading from the temperature sensor:

/*---------Temperature-------*/
// Convert the reading into voltage:
//This formula converts the ADC number 0-1023 to 0-5000mV (= 5V).
float voltage = reading * (5000 / 1024.0);
// Convert the voltage into the temperature in degree Celsius:
float temperatureC = voltage / 10;
float temperatureF=(temperatureC*1.8)+32; // Converting to Fahrenheit
delay(10);

/*------Display Result in Serial Monitor------*/
// Print the temperature in Celsius into the Serial Monitor:
Serial.print("Temperature in Celsius    = ");
Serial.print(temperatureC);
Serial.print(" \xC2\xB0"); // shows degree symbol
Serial.println("C");

// Print the temperature in Celsius into the Serial Monitor:
Serial.print("Temperature in Fahrenheit = ");
Serial.print(temperatureF);
Serial.print(" \xC2\xB0"); // shows degree symbol
Serial.println("F");

Serial.print("\n");

/*------Display Result in LCD------*/
lcd.clear();
lcd.setCursor(2,0); // Setting Curser on First character of first line
lcd.print("Temperature"); // printing the word Temperature on the display
lcd.setCursor(0,1); // setting curser on First character on 2nd line
lcd.print(temperatureC);  // printing temperatureC value we got from the Sensor on the LCD
lcd.write(1); // Write the custom charecter we created (degree sign)
lcd.print("C");

lcd.setCursor(8,1); // setting curser on Second First character on 2nd line
lcd.print(temperatureF); // printing temperatureF value we got from the Sensor on the LCD
lcd.write(1); // Write the custom charecter we created (degree sign)
lcd.print("F");
delay(1000); // refresh every one second
}```

### Result

You should see your display constantly monitors temperature surrounding the LM35 and shows it on the LCD module display in degree Celsius and Fahrenheit. If you cannot see the desired output, ensure the circuit has been properly assembled, and verified and uploaded the code to your board.

Applications:
1. Make Arduino thermometer using LM35.
2. You can make a Mini weather station using Arduino and LM35.