Monday, December 12, 2016

Temperature Monitor Using Arduino and LM35

Good evening. This is the continuation of the Arduino series and this particular one is about how to make a simple temperature monitor using the LM35 precision temperature sensor.

This will a very small project as the part it needs is the LM35. Reason behind that is this small chip is already calibrated in centigrade so it is just as simple as reading it's output value, do a small conversion and show it on display or use it in somewhere. LM35 is a linear temperature sensor and it's output voltage is proportional to the temperature. It's output is 10mV/Degree Centigrade. So if you rise temperature by 1 Degree Centigrade, output will increase by 10mV. So all you have to do is read that through Analog input pin of your Arduino and done. There are couple different positive things about using this. It has wide voltage range, it is a very small device so it is suitable for pretty much any application where temperature reading is needed.


So let's go over the parts list:

1. Arduino, again for basic projects like this I use UNO.
2. LM35.
3. USB A to B cable and Jumper Wires.
4. Arduino IDE on computer
5. Practice Board.


 
Procedure and Connections:

As there will be no other parts other than the LM35, the connection is pretty simple. LM35 has three pins. Pin1 takes in positive voltage which can be anything from 4V to 30V and Pin3 is the ground pin. I have just powered it directly from the Arduino 5V and GND pin.

Pin2 is the output pin of LM35 which needs to be connected to any of the analog input pins of the Arduino. You might have to change the code if you use anything other than 5 because that's what I'm using.

After connecting upload the code provided, code has all the necessary explanation and how you can modify it. Then open up the serial monitor to see the temperature reading.


The Code:

// declare variables.

int value;
int tempPin = 5;

void setup()
{
  Serial.begin(9600);
}
void loop()
{
  // taking in the value from input pin.
  value = analogRead(tempPin);

  // convert the voltage information, as LM35 is already calibrated in celcius to get the celcius output not much code is needed.
  float mv = ( value / 1023.0) * 5000;
  float cel = mv / 10;

  // convert the celcius value to farenhite
  float farh = (cel * 9) / 5 + 32;

  Serial.print("Temperature = ");
  Serial.print(cel);
  Serial.print("*C");
  Serial.println();
  delay(1000);

  /* uncomment this and comment the previous 5 lines to get temperature in farenhite
    Serial.print("Temperature = ");
    Serial.print(farh);
    Serial.print("*F");
    Serial.println();


  */
}



Here is the project:



How does it work? 

I have talked about LM35 earlier on this post, so you get the idea of what happens with different temperature, it gives different output voltage which is analog. Hence we put that in the analog input of Arduino. Now we have to convert it to digital in a way that it represents the proper temperature value.


Result:


 You can check for the accuracy using a source with known temperature.


Applications:

This one might be a very simple project but you can use it in many different things like battery over temperature protection or any kind of over temperature protection. It can also be used to control devices based on temperature. 

Hope you have enjoyed it.


Links:

No comments:

Post a Comment