loading

“Arduino can sense the environment by receiving input from a variety of sensors and can affect its surroundings by controlling lights, motors, and other actuators. The microcontroller on the board is programmed using the Arduino programming language”. Using the Arduino I will show you how to get the analog input from the LM35 temperature sensor and display the information in the serial window as raw data, celsius and fahrenheit.

For the purpose of the post I will assume that you already know how to download and install the Arduino software and load a sketch onto it.

Step 1: What You Need

What you will need:

Arduino UNO, Leonardo or equivalent

Breadboard

Jumper Wires

USB Cord

LM35 temperature sensor Data Sheet

Step 2: Wiring:

Wire up the breadboard as depicted in this picture.

Step 3: Code

The code can be downloaded here.

or Copy and paste this into the arduino sketch.

/*<br>Simple Temperature uses the lm35 in the basic centigrade temperature configuration
*/
float temp;
int tempPin = 2; // analog input pin
int sampleTime = 1000; // 1 second dafault 
void setup()
{
  Serial.begin(9600);
}
void loop()
{
  //gets and prints the raw data from the lm35
  temp = analogRead(tempPin);
  Serial.print("RAW DATA: ");
  Serial.print (temp);
  Serial.println(" ");
  //converts raw data into degrees celsius and prints it out
  // 500mV/1024=.48828125
  temp = temp * 0.48828125;
  Serial.print("CELSIUS: ");
  Serial.print(temp);
  Serial.println("*C ");
  //converts celsius into fahrenheit 
  temp = temp *9 / 5;
  temp = temp + 32;
  Serial.print("FAHRENHEIT: ");
  Serial.print(temp);
  Serial.println("*F");
  delay(sampleTime);

}

Load the code into to your board and open the serial monitor you should see both fahrenheit and celsius.

<p>can we use this for body temperature measurement?</p>
<p>Hi, so depending on the temperature, the voltage output changes am I correct? Is it possible to know the correlationship between voltage and temperature? I'm trying to add a fan to run above certain voltage(temperature.) Thanks!</p>
<p>LM35 is a linear temperature sensor whose output voltage is <br>proportional to degree centigrade. LM35's output is 10mv/Degree C which <br>means for every degree rise in temperature the output of LM35 will rise <br>by 10mv. So if the output of LM35 is 220mv/0.22V the temperature will be<br> 22&deg;C. So if room temperature is 32&deg;C then the output of LM35 will be <br>320mv i.e. 0.32V.</p><p>For detailed information check out <a href="http://www.dnatechindia.com/LM35-Temperature-Sensor-Basics.html" rel="nofollow">basic's of LM35 Temperature Sensor</a></p>
<p>I would just do some testing. To find the voltage = temp you want. </p>
<p>Can someone give me the difference between a temperature sensor like the one used here, and a thermister.</p><p>Thanks</p>
<p>I gues that termister is simple <strong>THERM-ally sensitive res-ISTOR</strong>, but LM35 has some amplifying element inside. Read this artile: <a href="http://www.electronics-tutorials.ws/io/io_3.html" rel="nofollow">http://www.electronics-tutorials.ws/io/io_3.html</a></p>
<p>Hallo , i dont know why but I just tried to copy this program but I faced problem :<br><br>could someone help ? Using arduino mini pro and Voltage for me is 5V<br>checked wiring, plus , GND , and output are set correctly </p><p>I kept serial.println only for celsius ... there are 21 degrees in room</p><p>thanks for any idea. </p>
<p>I am confused about the 500mV number constant?</p><p>According to the datasheet even in the basic setup (which is used in this article) there is a range of 1480mV w/ 2degC being 0mV &amp; 150degC being 1480mV w/ each degree C linear at 10mV.</p><p>TY :-)</p>
<p>it measures board or human body temp?</p>
<p>Its an ambient temp, more for like a room. </p>
<p>Nice instructable,</p><p>but i have a problems to get the correct celsius. The value isn&acute;t constant. Do you have a hint what could be the problem?</p>
<p>Hey sorry I never responded, were you able to get it working?</p>
Nope. The data is freaking out....i&acute;ve no clue what could be the problem. Degree spans between 6&deg; aren&acute;t very convincing i think...;-)
<p>Looks like I had my Fritzing drawing wrong swap the +5v and GND. </p>

About This Instructable

61,945views

70favorites

License:

Bio: As a young lad Tom spent most of his days at the heels of his father, working in their shop, also known as the basement ... More »
More by innovativetom:Control Stuff From the Internet, Create a WIFI Switch.  Wemos ESP8266 Getting Started Guide With Arduino IDE Making Scented Soy Wax Candles for Beginners.  
Add instructable to: