Interfacing temperature of LM35 using arduino
AIM
To interface the LM35 temperature sensor with an Arduino Uno board to measure ambient
temperature in Celsius and display it using the Serial Monitor.
ALGORITHM
1. Start the Arduino and initialize serial communication.
2. Connect the LM35 sensor to the analog input pin (A0).
3. Read the analog value from the LM35 sensor.
4. Convert the analog value to voltage.
5. Convert the voltage to temperature in Celsius (LM35 outputs 10 mV per °C).
6. Display the temperature on the Serial Monitor.
7. Wait for a short period and repeat from step 3.
PROGRAM:
const int sensorPin = A0; // LM35 output connected to analog pin A0
void setup() {
Serial.begin(9600); // Start the serial communication
}
void loop() {
int sensorValue = analogRead(sensorPin);
float voltage = sensorValue * (5.0 / 1023.0);
float temperatureC = voltage * 100.0;
Serial.print("Temperature: ");
Serial.print(temperatureC);
Serial.println(" °C");
delay(1000);
Circuit Diagram:
OUTPUT:
Temperature: 28.54 °C
Temperature: 28.67 °C
Temperature: 28.76 °C
Result:
The above arduino program Interfacing temperature LM35 using arduino is successfully
executed and the output is verified.