Phipps Electronics

Order within the next 

FREE SHIPPING OVER $199

50,000+ ORDERS

WORLDWIDE SHIPPING

SSL SECURED

Using the LM35DZ Temperature Sensor with Arduino

Contents

Let’s start off with a little background information on the LM35DZ Temperature Sensor. The LM35DZ is a transducer.

What is a Transducer and how do they work?

According to Wikipedia, “A transducer is a device that converts energy from one form to another. Usually, a transducer converts a signal in one form of energy to a signal in another”.  A transducer can detect changes in the physical world and response with the changes, so when a voltage is applied to it, it can indicate those changes through changes in voltage drop across it.

A thermistor is a type of resistor whose resistance is dependent on temperature, more so than in standard resistors. There are many kinds of temperature sensors and they all respond to temperature in different ways.

For our tutorial today we will be using a 3 pin device called LM35DZ. We have chosen this specific component because it outputs a liner value as a response to temperature, which makes it easier when working with Arduino.

LM35DZ Pinout

Pin 1 to be connected to your 5V power supply and pin 3 to ground.

Pin 2 is the output, the output voltage of the pin 2 changes by 10mV for each degree Celsius.

Circuit Diagram

Sample Code

				
					float tempPin = A0; 
void setup() {
    Serial.begin(9600); 
} 
void loop() { 
    float v = (5.0/1023.0) * analogRead(tempPin); 
    float cel = (v * 1000.0)/10.0; 
    float farh = (cel*9.0)/5.0 + 32.0; 
    Serial.print("TEMPRATURE = "); 
    Serial.print(cel); 
    Serial.print("*C"); 
    Serial.println(); 
    Serial.print(farh); 
    Serial.print("*F"); 
    Serial.println(); 
    delay(1000); 
}
				
			

After uploading the code, open your serial monitor, you should see it telling you your room temperature.

Code Explanation

We are setting the analog input pin A0 as input. There is an analog to digital converter working behind these input pins working out whatever input voltage these pins receive, the Arduino will divides it into 1023 pieces and present the output.

Therefore, 1 unit at the analog input reading = 0.0048876 volts

Now, we multiply the analog value with the input reading. The product gives us the value of the voltage at the analog pin. Now, we multiply it by 1000, the product gives the value of millivolts at the input pin. We then divide the value by 10 which gives us the room temperature.

SUBSCRIBE FOR NEW POST ALERTS

Subscribe to be the first to know when we publish a new article!
List Subscriptions(Required)

POPULAR POSTS

Scroll to Top