How to Use LM35 Temperature Sensor with Arduino

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.

LM35 temperature sensor — three-pin TO-92 package with pin labels

Key features and specifications

The LM35 temperature sensor boasts impressive technical specifications that make it suitable for various temperature monitoring applications:

SpecificationValue
Temperature Range-55°C to +150°C
Output Scale Factor10mV/°C
Accuracy±0.25°C typical at room temperature (±0.75°C over full range)
Operating Voltage4V to 30V
Current Draw60μA (typical)
Self-heatingLess than 0.1°C in still air
Package TypesTO-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.25°C typical 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:

  1. 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.
  2. 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 −0.55V (−55°C) to 1.5V (150°C).
  3. 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:

ComponentPurposePrice / link
Arduino Uno or NanoMain controllerArduino UNO R3 DIP — Rs 1,200
LM35 temperature sensorTemperature sensingAvailable on order — message us on WhatsApp
BreadboardPrototypingMB102 — Rs 250
Jumper wiresConnections (3–5 wires)Rs 180
USB cableConnect Arduino to your computerIncluded with the Arduino UNO
Optional: 100μF capacitor + 0.1μF bypass capacitorStability (R-C damper)Available on order — message us on WhatsApp
16×2 I2C LCDDisplay temperature without a computerRs 660

Step-by-step wiring guide

Connecting the LM35 to an Arduino is remarkably simple with just three connections required:

  1. First, place the LM35 on your breadboard with the flat side facing you.
  2. Connect the leftmost pin (Pin 1, +VS) of the LM35 to the 5V output on your Arduino.
  3. Connect the middle pin (Pin 2, VOUT) to any analog input on your Arduino — typically A0 is used for simplicity.
  4. 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 capacitor between the output pin and ground
  • Add a 0.1μF / 104 pF bypass capacitor between power and ground

LM35 temperature sensor connected to Arduino Uno on a breadboard with jumper wires – real-time temperature monitoring setup for student and final year projects blog qkzee

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

#define sensorPin A0  // Define which analog pin the LM35 is connected to

void setup() {
  Serial.begin(9600); // Initialize serial communication at 9600 baud rate
}

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:

  1. Analog to Digital Conversion: Arduino reads values between 0–1023, representing 0–5V.
  2. Digital to Voltage Conversion: Multiply by (5.0/1024.0) to convert to volts.
  3. 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:

  1. Connect your Arduino to your computer via USB
  2. Select the correct board and port from the Arduino IDE's Tools menu
  3. Click the upload button (right arrow icon)
  4. 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 gauges.

To connect a standard 16×2 I2C LCD display to your Arduino:

I2C LCD PinArduino Connection
GNDGND
VCC5V
SDAA4
SCLA5

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.

#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:

  1. Connect LEDs through appropriate resistors to Arduino pins (typically pins 2, 3, and 4)
  2. In your code, set temperature thresholds and control LEDs accordingly:
#define sensorPin A0

const float cold = 68.0;  // Below 68°F (20°C) = cold
const float hot = 86.0;   // Above 86°F (30°C) = hot

void setup() {
  Serial.begin(9600);
  pinMode(2, OUTPUT);  // Blue LED
  pinMode(3, OUTPUT);  // Green LED
  pinMode(4, OUTPUT);  // Red LED
}

void loop() {
  float tempC = (analogRead(sensorPin) * 5.0 * 100.0) / 1024;
  float tempF = (tempC * 9.0 / 5.0) + 32.0;

  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);
  }

  delay(1000);
}

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 gauge

Alternatively, you can create dynamic temperature visualizations using the Arduino Serial Plotter or external graphing tools.

To use the Arduino Serial Plotter:

  1. Ensure your code outputs only numeric values (without text)
  2. Open Tools > Serial Plotter in the Arduino IDE
  3. 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.25°C typical 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 module 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 the relay wiring and code, see our relay module guide. 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 – Why This Project Works

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.

For a temperature sensor that works over a wider range with digital output, see our 10k thermistor guide — it covers the thermistor version of this project — and for a temperature-controlled safety system that switches things off when it gets too hot, see our IoT geyser safety system.

Where to Buy the Parts

The Arduino UNO R3 DIP (Rs 1,200, USB cable included), MB102 breadboard (Rs 250), jumper wires (Rs 180), 16×2 LCD with I2C (Rs 660) and 1-channel relay module (Rs 155) are available at QKZee Technologies, Shop 20, 1st Floor, Al-Khalil Center, Hall Road, Lahore, and online at qkzeetech.com with delivery all over Pakistan — see the links above. The LM35 sensor and the capacitors are available on order — message us on WhatsApp and we will arrange them for you.

Still Stuck?

If the reading is 0°C, or the temperature jumps by 5°C or more between readings, message us — tell us what the Serial Monitor shows, whether the flat side of the LM35 faces you with +VS on the left, and whether the middle pin is on A0, and we will help you find the fault.

Message us on WhatsApp Watch on YouTube

FAQs

Why does the Serial Monitor show 0°C?

Check the wiring — the most common cause is the middle pin (VOUT) not connected to A0, or the LM35 inserted backwards. With the flat side facing you, the pins are +VS (left), VOUT (middle), GND (right).

Why do the readings jump by 5°C or more?

Electrical noise. Add the R-C damper (100μF capacitor between output and ground, 0.1μF bypass between power and ground), keep the wires short, and add a delay of at least 500ms between readings.

Why is my temperature consistently wrong by a fixed amount?

Check the conversion formula — the most common mistake is using the wrong voltage reference. With the default 5V reference, temperature = reading × (5.0 / 1024.0) × 100. If you switched to the internal 1.1V reference, use reading × (1100.0 / 1024.0) instead.

Can the LM35 measure negative temperatures?

Only with a negative supply voltage — the LM35 needs a negative rail to output a negative voltage, which a plain Arduino cannot provide. For below-zero measurements, use a digital sensor like the DS18B20 instead.

Why does the LM35 need 4V minimum?

The LM35's internal circuitry needs at least 4V to operate, so it cannot run from a 3.3V supply. On an Arduino, power it from the 5V pin — never from the 3.3V pin.

Can I use the LM35 with an ESP32?

Yes, but the ESP32's ADC is 12-bit (0–4095) and its default reference is 3.3V, so the conversion formula changes: voltage = reading × (3.3 / 4095.0), temperature = voltage × 100. And the LM35 still needs 5V for power (it cannot run from 3.3V).

Conclusion

An LM35 with an Arduino is one of the best first temperature projects: three wires, one formula, and the sensor gives you °C directly. Remember the three things that trip everyone up — the flat side faces you with +VS on the left, the output range is −0.55V to 1.5V (not −1V to 6V), and the accuracy is ±0.25°C typical at room temperature. That is the whole project, and it works.