How to Use LM35 Temperature Sensor with Arduino: A Beginner’s Guide (2025)

How to Use LM35 Temperature Sensor with Arduino: A Beginner’s Guide (2025)
The LM35 temperature sensor stands out as one of the most reliable and beginner-friendly components for anyone starting their journey in electronics and Arduino projects. Whether you’re building a simple room thermometer or developing a complex weather monitoring system, this versatile sensor delivers accurate temperature readings with minimal setup.
In fact, many students and hobbyists choose the LM35 for their first Arduino projects because of its straightforward three-pin design and direct Celsius output. From basic temperature displays to automated cooling systems, this sensor opens up countless possibilities for practical applications.
This comprehensive guide walks you through everything you need to know about using the LM35 with Arduino. We’ll cover the basics of sensor operation, proper wiring techniques, code implementation, and several practical projects you can build today.
Understanding the LM35 Temperature Sensor
When exploring temperature sensing options for electronic projects, the LM35 emerges as a standout choice due to its precision and simplicity. This integrated circuit temperature sensor offers reliable performance across a wide range of applications, from hobbyist projects to industrial monitoring systems.
What is the LM35 sensor?
The LM35 is a precision integrated-circuit temperature device manufactured by Texas Instruments that produces an analog output voltage directly proportional to Celsius temperature. Unlike many other temperature sensors, the LM35 generates a linear electrical response that precisely correlates with temperature changes, providing straightforward readings without complex calibration requirements.
The sensor operates on a simple principle: for every degree Celsius rise in temperature, the output voltage increases by 10mV . For instance, if the ambient temperature is 25°C, the LM35 will output 250mV. This linear relationship makes temperature calculations remarkably straightforward when connecting to microcontrollers like Arduino.
Key features and specifications
The LM35 temperature sensor boasts impressive technical specifications that make it suitable for various temperature monitoring applications:
Specification | Value |
---|---|
Temperature Range | -55°C to +150°C |
Output Scale Factor | 10mV/°C |
Accuracy | ±0.5°C at room temperature |
Operating Voltage | 4V to 30V |
Current Draw | 60μA (typical) |
Self-heating | Less than 0.1°C in still air |
Package Types | TO-92, TO-220, SOIC |
The sensor requires no external calibration or trimming to achieve typical accuracies of ±¼°C at room temperature and ±¾°C over its full temperature range. Additionally, its low output impedance and precise inherent calibration simplify integration with readout or control circuitry.
Advantages over other temperature sensors
The LM35 offers several significant advantages compared to alternative temperature sensing technologies:
First, the LM35 has a distinct edge over linear temperature sensors calibrated in Kelvin, as users don’t need to subtract a large constant voltage from the output to obtain convenient Celsius scaling. This direct Celsius output simplifies calculations and code implementation.
Furthermore, the sensor delivers greater precision than many alternatives, with ±0.5°C accuracy compared to the ±2°C accuracy of sensors like the TMP36. The LM35 also outperforms thermistors in terms of output precision.
Another advantage lies in its minimal power consumption—drawing only 60μA from the supply—resulting in negligible self-heating of less than 0.1°C in still air. This characteristic ensures that the sensor accurately measures ambient temperature without influencing its readings.
Nevertheless, it’s worth noting that while the LM35 excels in many aspects, it does require negative voltages to represent negative temperatures and has a minimum supply voltage of 4V, which limits its use in strictly 3.3V environments.
Pinout explanation
The LM35 features a straightforward three-pin configuration that resembles a standard transistor package:
Vcc (Pin 1): This is the power supply pin that accepts input voltages between 4V and 30V, though typically powered with 5V in Arduino applications.
Output (Pin 2): This pin produces the analog voltage output proportional to temperature. The voltage increases by 10 mV for every 1°C rise in temperature, ranging from -1V (-55°C) to 6V (150°C) 2.
Ground (Pin 3): This pin connects to the circuit’s ground, completing the electrical circuit.
This simple pinout configuration makes the LM35 exceptionally easy to integrate into various electronic projects, particularly those utilizing microcontrollers with analog-to-digital conversion capabilities.
Setting Up Your First Arduino-LM35 Circuit
Now that you understand the capabilities of the LM35 temperature sensor, it’s time to connect it to your Arduino and start measuring temperatures. Creating a reliable temperature sensing circuit is straightforward, yet attention to detail ensures accurate readings.
Required components
For this basic temperature monitoring setup, you’ll need:
- Arduino Uno or Nano board
- LM35 temperature sensor
- Breadboard for prototyping
- Jumper wires (approximately 3-5)
- USB cable to connect Arduino to your computer
- Optional components for stability:
- 100μF capacitor
- 0.f μF/104 pf bypass capacitor
These optional components can help eliminate reading fluctuations, especially in environments with electromagnetic interference.
Step-by-step wiring guide
Connecting the LM35 to an Arduino is remarkably simple with just three connections required:
First, place the LM35 on your breadboard with the flat side facing you.
Connect the leftmost pin (Pin 1, +VS) of the LM35 to the 5V output on your Arduino.
Connect the middle pin (Pin 2, VOUT) to any analog input on your Arduino—typically A0 is used for simplicity.
Connect the rightmost pin (Pin 3, GND) to the GND (ground) pin on your Arduino.
At room temperature (approximately 25°C), the sensor should output about 0.25V (250mV) when correctly wired.
For improved stability, especially if readings fluctuate, consider adding an R-C damper circuit:
- Connect a 100μF resistor between the output pin and ground
- Add a 0.1μF /104 pf bypass capacitor between power and ground
Common wiring mistakes to avoid
Even with such a simple circuit, several issues can prevent accurate readings:
Incorrect pin orientation: The most frequent mistake is misidentifying the LM35 pins. Always remember: with the flat side facing you, pins are arranged as +VS (left), VOUT (middle), and GND (right).
Unstable power supply: The Arduino’s USB power can sometimes be unreliable. If you notice erratic readings, consider using an external power supply for your Arduino.
Missing stabilization components: The LM35 can be sensitive to electromagnetic interference. If readings fluctuate significantly (jumping 5°C or more between readings), add the R-C damper circuit mentioned above.
Poor connections: Loose wires on the breadboard can cause intermittent connections. Ensure all wires are firmly seated in the breadboard.
Inadequate grounding: Without proper grounding, the LM35 may produce inaccurate readings. Double-check that the ground connection is secure.
Heat transfer from nearby components: Placing the LM35 too close to heat-generating components on the breadboard can affect readings. Position it away from other components.
After completing your circuit, you’re ready to write the code that converts the sensor’s voltage output into meaningful temperature readings—a process we’ll cover in the next section.
Writing Your First Temperature Monitoring Code
After assembling your Arduino-LM35 circuit, it’s time to bring it to life with code. Converting the voltage output from the LM35 into meaningful temperature readings requires just a few lines of code, making it ideal for student projects and beginners alike.
Basic code structure explained
The foundation of any Arduino temperature monitoring sketch consists of two main functions: setup()
and loop()
. Initially, in the setup()
Function, we establish serial communication to display readings on your computer:
#define sensorPin A0 // Define which analog pin the LM35 is connected to
void setup() {
Serial.begin(9600); // Initialize serial communication at 9600 baud rate
}
Subsequently, in the loop()
function, we read the sensor value, convert it to temperature, and display the results:
void loop() {
int reading = analogRead(sensorPin); // Read raw analog value
float voltage = reading * (5.0 / 1024.0); // Convert to voltage
float temperatureC = voltage * 100; // Convert to Celsius
Serial.print(“Temperature: “);
Serial.print(temperatureC);
Serial.println(” °C”);
delay(1000); // Wait a second between readings
}
Understanding the temperature conversion formula
The conversion from analog reading to temperature follows a straightforward three-step process:
- Analog to Digital Conversion: Arduino reads values between 0-1023, representing 0-5V.
- Digital to Voltage Conversion: Multiply by (5.0/1024.0) to convert to volts.
- Voltage to Temperature Conversion: The LM35 outputs 10mV per degree Celsius, so multiplying voltage by 100 gives the temperature.
This relationship is captured in the formula: Temperature (°C) = [Analog Reading × (5000mV/1024)] ÷ 10mV
For improved precision, some versions use alternative calculations:
temp = (reading * 5.0 * 100.0) / 1024
temp = milliVolt / 10
(where milliVolt is first calculated from reading)
Uploading and testing your code
Once your code is ready, follow these steps to upload it:
- Connect your Arduino to your computer via USB
- Select the correct board and port from the Arduino IDE’s Tools menu
- Click the upload button (right arrow icon)
- Open the Serial Monitor (magnifying glass icon) with baud rate set to 9600
Within seconds, you should see temperature readings appearing in the Serial Monitor, updating once per second. At room temperature, expect readings around 25°C.
Troubleshooting code issues
If your temperature readings seem incorrect, consider these common issues:
Erratic or unstable readings: Typically caused by electrical noise. Adding a delay between readings (at least 500ms) can help stabilize output.
Consistently incorrect values: Check your conversion formula. The most common mistake is using incorrect voltage reference values.
Increased precision needed: For more precise measurements, change the analog reference voltage with:
analogReference(INTERNAL); // Use internal 1.1V reference instead of 5V
When using the internal reference, adjust your conversion formula:
float voltage = reading * (1100.0 / 1024.0);
This modification improves temperature resolution from 0.48°C to approximately 0.1°C but limits the maximum measurable temperature to about 110°C.
Remember that even small code adjustments can significantly improve the accuracy of your LM35 temperature sensor projects, making them more reliable for practical applications.
Displaying Temperature Data Beyond Serial Monitor
Moving beyond basic serial monitoring opens up exciting possibilities for your LM35 temperature sensing projects. Once you’ve mastered reading temperature values, displaying this data through visual interfaces creates more practical and interactive applications.
Using an LCD display
An LCD display transforms your temperature monitor into a standalone device that doesn’t require a computer connection. This makes it perfect for permanent installations or portable temperature gages.
To connect a standard 16×2 I2C LCD display to your Arduino:
I2C LCD Pin | Arduino Connection |
---|---|
GND | GND |
VCC | 5V |
SDA | A4 |
SCL | A5 |
First, install the LiquidCrystal_I2C library through the Arduino IDE (Tools > Manage Libraries). Search for “liquidcrystal_i2c” and install the library by Frank de Brabander.
The basic code structure for displaying temperature on an LCD includes:
#include "LiquidCrystal_I2C.h"
LiquidCrystal_I2C lcd(0x27, 16, 2); // Set LCD address to 0x27, 16 columns, 2 rows
void setup() {
lcd.init();
lcd.backlight();
}
void loop() {
float tempC = (analogRead(A0) * 5.0 * 100.0) / 1024;
float tempF = (tempC * 9.0 / 5.0) + 32.0;
lcd.clear();
lcd.setCursor(0, 0);
lcd.print(tempC);
lcd.print(” C”);
lcd.setCursor(0, 1);
lcd.print(tempF);
lcd.print(” F”);
delay(1000);
}
This code displays both Celsius and Fahrenheit readings simultaneously.
Adding LED indicators for temperature thresholds
LED indicators provide quick visual feedback about temperature conditions without requiring you to read exact values. This approach works well for monitoring systems where you need to know if temperatures exceed certain thresholds.
For a basic three-LED temperature indicator:
- Connect LEDs through appropriate resistors to Arduino pins (typically pins 2, 3, and 4)
- In your code, set temperature thresholds and control LEDs accordingly:
if (tempF < cold) { // If temperature is cold
digitalWrite(2, HIGH); // Blue LED on
digitalWrite(3, LOW);
digitalWrite(4, LOW);
} else if (tempF >= hot) { // If temperature is hot
digitalWrite(2, LOW);
digitalWrite(3, LOW);
digitalWrite(4, HIGH); // Red LED on
} else { // If temperature is comfortable
digitalWrite(2, LOW);
digitalWrite(3, HIGH); // Green LED on
digitalWrite(4, LOW);
}
This creates a simple traffic light system where blue indicates cold temperatures, green shows comfortable ranges, and red warns of excessive heat.
Creating a simple temperature gage
Alternatively, you can create dynamic temperature visualizations using the Arduino Serial Plotter or external graphing tools.
To use the Arduino Serial Plotter:
- Ensure your code outputs only numeric values (without text)
- Open Tools > Serial Plotter in the Arduino IDE
- Watch as temperature changes create real-time graphs
For more advanced visualization options, consider connecting your Arduino to platforms like:
- Arduino Cloud for customizable dashboards accessible from anywhere
- Processing IDE for creating custom graphical interfaces
- Mobile apps that connect to Arduino via Bluetooth or WiFi
These visualization methods transform raw temperature data into meaningful displays that make your Arduino LM35 projects more practical for real-world applications such as home automation systems, weather stations, or educational demonstrations.
Building Practical Temperature Monitoring Projects
Now that you’ve mastered the basics, let’s put your knowledge into practice with four real-world LM35 projects that showcase the versatility of this remarkable sensor.
Simple room thermometer
The LM35 sensor excels at monitoring ambient room temperatures over extended periods. You can build a 24-hour temperature monitor that displays current, maximum, and minimum temperatures on an LCD panel. This project uses the LM35’s ability to sense temperatures ranging from -55°C to 150°C with an impressive accuracy of ±0.5°C at room temperature.
The code structure involves sampling the analog voltage every second and interpreting temperature variations throughout the day. This creates a practical device for maintaining comfortable living spaces or monitoring temperature-sensitive environments like server rooms.
Temperature-controlled fan
Automatic cooling systems demonstrate how the LM35 can trigger mechanical responses based on temperature readings. For this project, connect your LM35 sensor with Arduino and a relay to control an AC fan that activates when temperatures exceed a set threshold (typically 40°C).
The implementation requires:
- LM35 connected to Arduino’s analog input (A0)
- Relay module connected to digital pin 2
- Simple conditional code that activates the relay when temperatures rise
For advanced implementations, you can even create proportional control where the fan speed increases as temperatures rise, using PWM signals through a transistor switch.
Plant soil temperature monitor
For gardening enthusiasts, monitoring soil temperature is crucial for plant health. The LM35 can be adapted to measure soil conditions by waterproofing the sensor and placing it at root level for more relevant readings.
This project works best when combined with other sensors like soil moisture monitors to create a comprehensive plant health system. The data helps determine optimal planting times and growth conditions, especially valuable for temperature-sensitive plants.
Weather station integration
Moreover, your LM35 can serve as the temperature component in a complete weather monitoring station. By combining the LM35 with humidity sensors (like DHT22), light sensors, and pressure monitors, you can build a comprehensive environmental monitoring system.
The Arduino processes readings from multiple sensors simultaneously, enabling you to track weather patterns or create automated environmental control systems. This multi-sensor approach provides deeper insights than temperature alone, making it ideal for educational demonstrations or home automation applications.
Conclusion
Temperature sensing with the LM35 offers endless possibilities for both beginners and experienced makers. This reliable sensor proves its worth through accurate readings, straightforward implementation, and adaptability across various projects. Whether building a basic room thermometer or developing complex environmental monitoring systems, the LM35 delivers consistent performance.
Starting with simple Arduino connections allows quick success, while advanced display options and multi-sensor integrations open doors to sophisticated applications. The sensor’s precision makes it ideal for critical temperature monitoring tasks, from controlling cooling systems to tracking soil conditions for optimal plant growth.
The LM35’s combination of accuracy, affordability, and ease of use makes it an excellent choice for anyone interested in temperature monitoring projects. Armed with the knowledge from this guide, you can confidently tackle temperature sensing challenges and create practical solutions for real-world applications.
Remember that successful temperature monitoring often requires attention to proper wiring, careful code implementation, and strategic sensor placement. These fundamentals, paired with your creativity, will help you develop increasingly complex and useful temperature-based systems.
Where to Buy Your Electronics Components
Looking for affordable components for this Arduino project? Check out QKZee Technologies, an online shop in Lahore, Pakistan, offering the best components for students and DIY projects. Whether you’re looking for sensors, modules, or other electronics at a cheap price, they’ve got it all. Visit them at QKZeeTech.
What is the LM35 temperature sensor?
The LM35 is a precision temperature sensor that outputs an analog voltage proportional to the ambient temperature in Celsius, making it ideal for Arduino-based monitoring systems.
How do I connect the LM35 sensor to Arduino?
Simply connect the LM35’s VCC pin to 5V, GND to GND, and OUT pin to an analog input (like A0) on the Arduino for data reading.
Can I use LM35 in my final year project?
Yes! LM35 is widely used in student and final year projects for temperature-based automation, data logging, or safety systems.
What are the real-life applications of the LM35 sensor
It’s used in climate control systems, greenhouses, IoT temperature monitoring, weather stations, and lab automation.
What libraries are required to use LM35 with Arduino?
No external libraries are required. You can use the analogRead()
function directly to read the sensor's data and convert it to temperature in Celsius using simple math.
Where can I buy these components in Lahore?
visit Hall Road Lahore, or contact QKZee Technologies for genuine parts and student-friendly prices