LM35 Sensor Tutorial

Measure Temperature with an LM35 Sensor

Introduction

The LM35 is a popular analog temperature sensor known for its high accuracy and simple interface. It provides temperature readings in Celsius with minimal calibration required. In this tutorial, you'll learn how to wire an LM35 sensor, write Arduino code to read temperature values, and use these readings in practical applications.

This project is perfect for beginners looking to explore sensors and data logging with Arduino.

Required Components

Ensure all components are in good condition to avoid potential troubleshooting issues during the project.

Wiring Instructions

Follow these steps to connect the LM35 temperature sensor to your Arduino:

  1. VCC: Connect the VCC pin of the LM35 sensor to the 5V or 3.3V pin on the Arduino board. Ensure the power level matches the specifications of the LM35.
  2. Output: Connect the Output pin of the LM35 sensor to an analog input pin on the Arduino, such as A0.
  3. GND: Connect the GND pin of the LM35 sensor to the GND pin on the Arduino.

Once connected, double-check the wiring to ensure proper connections before powering up the Arduino.

Arduino Code


const int lm35Pin = A0; // Analog pin connected to LM35
void setup() {
    Serial.begin(9600); // Start the serial communication
}
void loop() {
    int analogValue = analogRead(lm35Pin); // Read analog value from LM35
    float voltage = analogValue * (5.0 / 1023.0); // Convert to voltage
    float temperatureC = voltage * 100; // Convert voltage to temperature (Celsius)
    float temperatureF = (temperatureC * 9.0 / 5.0) + 32.0; // Convert to Fahrenheit
    Serial.print("Temperature (C): ");
    Serial.print(temperatureC);
    Serial.print(" °C | Temperature (F): ");
    Serial.print(temperatureF);
    Serial.println(" °F");
    delay(1000); // Wait for 1 second before next reading
}
            

Upload this code to your Arduino and open the Serial Monitor to see real-time temperature readings in both Celsius and Fahrenheit.

Calibration

For the most accurate results, calibrate the LM35 sensor by comparing its output with a known accurate thermometer:

Troubleshooting

If you encounter issues, check the following:

Applications

The LM35 sensor is commonly used in:

Further Experiments

Expand your project by trying these ideas:

Conclusion

By completing this tutorial, you’ve learned how to wire and program an LM35 temperature sensor with an Arduino. With these skills, you can create a variety of temperature monitoring and control projects. Experiment further to take your project to the next level!