# Interfacing LM-35 Temperature Sensor with evive

Description
Learn how to connect the LM-35 temperature sensor with evive and display the data on the evive screen. The tutorial covers the circuit diagram, Arduino code, and output of the temperature sensor.

# Introduction

In the scorching summer, the generally asked question is what is the temperature? So, what do we basically understand by temperature? Well, the answers to your question lie ahead.

Temperature is the degree (or intensity ) of heat present in a substance. Temperature is one of the most commonly measured parameters in the world, whether it is from Microwave or fridges, or AC. Now, to measure the temperature we will use a LM-35 temperature sensor.

LM-35 sensor is a thermocouple that gathers the temperature from the surrounding. The output voltage of the sensor is linearly proportional to its output temperature(in °C). It is a three pin temperature sensor that measures the temperature in the range of -40 °C to +120 °C. The output voltage of the sensor increase by 10 mV/°C.

## How does the LM-35 sensor work?

The LM-35 sensor gives a voltage in the range of 0 to +1V. Each step in the analog reading is equal to 1.0742 mV. If 10mV is equal to 1 degree Celcius, 10 / 1.0742 = 9.31. So, for every change of 9.31 in the analog reading, there is one degree of temperature change. Hence the factor or the conversion of the output signal becomes

## Interfacing LM-35 sensor with evive

### Circuit Diagram:

Follow the steps below to connect the LM-35 sensor with evive:

1. Take an LM-35 sensor and  3 male-to-male jumper wires. Insert the temperature sensor in the breadboard as shown in the figure. Insert the three male ends of the jumper wires on the breadboard in front of the three pins of the temperature sensor.
2. Connect the middle pin (yellow jumper wire) to the analog output A0 as shown in the circuit diagram.
3. Take another male-to-male jumper wire(red jumper wire) and connect the first pin of the temperature sensor. This pin goes to 5V of the evive board.
4. At last, connect the last pin of the sensor to the GND button on the evive. The setup is ready.

## Arduino Code:

The following Arduino code displays the data read by the sensor on the evive TFT screen.

``````/********************************************************************
* TITLE:Interfacing LM35 temperature sensor
*
* PURPOSE:In this tutorial we will interface LM35 temperature sensor
* with evive and display the data on the evive screen.The temperature
* is displayed in centigrade and fahanheit.
*
* CREATED BY:Chetan Vashishtha
*
* DATE:23 May 2018
*
* *****************************************************************/
#include<evive.h>
int tempPin=2;//defines pin 2 as sensorPin
int temp;//defines variable

void setup() {
Serial.begin(9600);
pinMode(tempPin,OUTPUT);
tft_init(INITR_GREENTAB2);
tft.setTextColor(ST7735_RED);
tft.fillScreen(ST7735_BLACK);
tft.setTextSize(2);
tft.setCursor(20,20);
tft.print("TEMPERATURE");
}

void loop() {

float celsius = (temp/9.31);
float farhanheit = (celsius*9)/5 + 32;//conversion into farhanheit

Serial.print("TEMPRATURE = ");
Serial.print(celsius);
Serial.print("C");
Serial.println();
Serial.print(farhanheit);
Serial.print("F");
Serial.println();
delay(1000);

tft.setTextColor(ST7735_GREEN);
tft.setTextSize(1);
tft.setCursor(35,40);
tft.println("IN CELSIUS");

tft.setTextColor(ST7735_WHITE,ST7735_BLACK);
tft.setTextSize(2);
tft.setCursor(35,60);
tft.println(celsius);

tft.setTextColor(ST7735_GREEN);
tft.setTextSize(1);
tft.setCursor(35,80);
tft.println("IN FAHRANHEIT");

tft.setTextColor(ST7735_WHITE,ST7735_BLACK);
tft.setTextSize(2);
tft.setCursor(35,100);
tft.println(farhanheit);
}``````

## Output

The Arduino setup is shown below.

Note: While making the connections with the LM-35 sensor make sure the pins are properly inserted in the breadboard. Sometimes the temperature sensor will show abnormal values. It may be due to irregularities in the jumper wires.

## Conclusion

In conclusion, the LM-35 temperature sensor is a three pin sensor that is used to measure temperature in the range of -40°C to +120°C with an accuracy of +-0.5°C. The output of the sensor is linearly proportional to its output temperature in °C and increases 10mV/°C. This sensor can be easily interfaced with an evive board using the Arduino code provided. The data read by the sensor is displayed on the evive TFT screen in both Celsius and Fahrenheit.