How to interface LM35(Temperature Sensor) with Arduino - Ocean of Programming

Wednesday 21 February 2018

How to interface LM35(Temperature Sensor) with Arduino

       In this article, I am going to explain how to connect LM35 with Arduino. The LM35 series are precision integrated-circuit temperature devices with an output voltage linearly proportional to the Centigrade temperature. It operates from 4 V to 30 V and Calibrated Directly in Celsius (Centigrade). It Rated for Full −55°C to 150°C Range and low-Impedance Output, 0.1 Ω for 1-mA Load. 
        From Arduino ADC we read the analog value and then we will convert it to the °C. Arduino has 10bit ADC so we need to multiply the read value by 1024 and divide it by the voltage provided to LM35 to get the temperature in °C.

void setup() {
Serial.begin(9600); 
}
void loop()  
{
int analog = analogRead(A0);
float MV = (analog/1024.0) * 5000; //5000 is the voltage provided
float celsius = MV/10;
Serial.print("In Degree Celsius= ");
Serial.println(celsius);
delay(1000);
}
          In the above program, I am reading the analog value from A0 pin and multiplying it by 1024 and dividing it by 5000. Diving it by 5000 is necessary due to supplied voltage to LM35 is 5V and 5000 it is in millivolts. Change the value according to your power to LM35 but put the value in millivolts only.
         Consider instead of 5V you provided 3.3V then put the value as 3300 if you put wrong value then you will get the wrong result. It will continuously read the temperature at the interval of 1000ms. If you are simulating in Proteus then must connect TXD of Arduino to the RXD of the serial window.
           After dumping the program into Arduino start serial monitor to observe the values. I am adding a screenshot of Protus Simulation software.
           Please feel free to comment if you find anything incorrect or you want to share more information about the topic discussed above.

No comments:

Post a Comment