Inquire: Call 0086-755-23203480, or reach out via the form below/your sales contact to discuss our design, manufacturing, and assembly capabilities.
Quote: Email your PCB files to Sales@pcbsync.com (Preferred for large files) or submit online. We will contact you promptly. Please ensure your email is correct.
Notes: For PCB fabrication, we require PCB design file in Gerber RS-274X format (most preferred), *.PCB/DDB (Protel, inform your program version) format or *.BRD (Eagle) format. For PCB assembly, we require PCB design file in above mentioned format, drilling file and BOM. Click to download BOM template To avoid file missing, please include all files into one folder and compress it into .zip or .rar format.
LM35 Temperature Sensor Arduino: Complete Analog Sensing Guide
I’ve been working with analog temperature sensors for over a decade now, and the LM35 temperature sensor Arduino combination remains one of my go-to setups for prototyping thermal monitoring systems. Whether you’re building a DIY thermostat, monitoring server room temperatures, or just learning about analog-to-digital conversion, this guide covers everything you need to get accurate temperature readings.
What Makes the LM35 Temperature Sensor Special?
The LM35 is a precision integrated-circuit temperature sensor manufactured by Texas Instruments. Unlike thermistors that require complex calculations and calibration, the LM35 outputs a voltage directly proportional to temperature in Celsius. That 10mV per degree relationship makes your code cleaner and your debugging sessions shorter.
From a hardware design standpoint, the LM35 draws only 60µA from its supply. That’s practically nothing. I’ve used these sensors in battery-powered data loggers that ran for months without a recharge. The low self-heating (less than 0.1°C in still air) means you’re measuring ambient temperature, not the heat generated by the sensor itself.
LM35 Temperature Sensor Specifications
Before wiring anything up, you need to understand what you’re working with. Here’s the technical breakdown:
Parameter
Value
Operating Voltage
4V to 30V DC
Temperature Range
-55°C to +150°C
Accuracy at 25°C
±0.25°C typical
Accuracy (Full Range)
±0.75°C
Output Scale Factor
10mV/°C
Quiescent Current
60µA
Self-Heating
<0.1°C in still air
Output Impedance
<0.1Ω for 1mA load
Package Types
TO-92, TO-220, SOIC-8
The TO-92 package is what you’ll find in most hobby electronics kits. It looks like a small transistor with three pins.
LM35 Pinout Configuration
Getting the pinout wrong is the number one reason beginners get garbage readings. With the flat side facing you (the side with text printed on it), the pins from left to right are:
Pin Number
Pin Name
Function
1 (Left)
+Vs
Positive Supply Voltage (4V-30V)
2 (Center)
Vout
Analog Output (10mV/°C)
3 (Right)
GND
Ground Connection
Double-check this before powering up. Reversing Vs and GND won’t necessarily destroy the sensor immediately, but you’ll get nonsense readings and potentially damage the IC over time.
Wiring the LM35 Temperature Sensor to Arduino
The hardware setup is straightforward. You need three connections total. Here’s the wiring table for an Arduino Uno:
LM35 Pin
Arduino Pin
Wire Color (Suggested)
+Vs (Pin 1)
5V
Red
Vout (Pin 2)
A0
Yellow/Orange
GND (Pin 3)
GND
Black
That’s it. No pull-up resistors, no voltage dividers, no level shifters. The LM35’s output impedance is low enough to drive the Arduino’s ADC input directly.
Hardware Tips From the Bench
After building dozens of LM35 circuits, here are the practical lessons I’ve learned:
Keep your wires short. Anything over 6 inches and you’ll start picking up noise from nearby digital signals, power supplies, and even fluorescent lights. If you need longer runs, use shielded cable with the shield connected to ground.
Add a 100nF (0.1µF) ceramic capacitor between Vout and GND as close to the sensor as possible. This simple low-pass filter knocks out most high-frequency interference. For really noisy environments, some engineers recommend adding an 80kΩ to 100kΩ resistor between Vout and GND to prevent the output from floating.
Don’t mount the LM35 directly on your PCB near heat-generating components. That voltage regulator running at 40°C will skew your ambient temperature readings significantly.
Arduino Code for LM35 Temperature Sensor
Let’s start with the basic code that reads temperature and displays it on the Serial Monitor:
Understanding the Math Behind Temperature Conversion
The Arduino Uno’s ADC converts the analog voltage into a 10-bit digital value (0-1023). With a 5V reference, each ADC step represents approximately 4.88mV. The LM35 outputs 10mV per degree Celsius, so the calculation chain looks like this:
Read ADC value (0-1023)
Convert to millivolts: ADC × (5000 / 1024)
Convert to temperature: millivolts ÷ 10
At room temperature (25°C), the LM35 outputs 250mV, which translates to an ADC reading of about 51.
Improving LM35 Accuracy With Internal Reference
Here’s a technique that many tutorials skip: using the Arduino’s internal 1.1V reference instead of the 5V rail. The 5V supply can vary between boards and with load changes. The internal reference is more stable.
// LM35 with Internal 1.1V Reference for Better Accuracy
#define SENSOR_PIN A0
#define ADC_VREF_mV 1100.0
#define ADC_RESOLUTION 1024.0
void setup() {
Serial.begin(9600);
analogReference(INTERNAL); // Switch to internal 1.1V reference
This approach limits your maximum measurable temperature to about 110°C (1100mV / 10mV per degree), but for most indoor applications that’s more than sufficient. The resolution improves from roughly 0.5°C per ADC step to about 0.1°C per step.
Filtering Noisy LM35 Readings
Real-world analog signals are messy. Here are three software filtering techniques I use regularly:
Moving Average Filter
#define SENSOR_PIN A0
#define NUM_SAMPLES 10
float readFilteredTemperature() {
long sum = 0;
for (int i = 0; i < NUM_SAMPLES; i++) {
sum += analogRead(SENSOR_PIN);
delay(10); // Small delay between readings
}
float avgADC = sum / NUM_SAMPLES;
float milliVolts = avgADC * (5000.0 / 1024.0);
return milliVolts / 10.0;
}
Exponential Moving Average (Recursive Filter)
This filter uses less memory and responds faster to actual temperature changes:
For most projects, I combine hardware filtering (capacitor) with a simple moving average. Belt and suspenders.
Displaying LM35 Temperature on I2C LCD
Standalone thermometer projects need a display. Here’s how to connect an I2C LCD (16×2) along with the LM35:
Component
Arduino Pin
LM35 Vout
A0
LM35 +Vs
5V
LM35 GND
GND
LCD SDA
A4
LCD SCL
A5
LCD VCC
5V
LCD GND
GND
#include <LiquidCrystal_I2C.h>
#define SENSOR_PIN A0
LiquidCrystal_I2C lcd(0x27, 16, 2);
void setup() {
lcd.init();
lcd.backlight();
lcd.setCursor(0, 0);
lcd.print(“Temperature:”);
}
void loop() {
int adcValue = analogRead(SENSOR_PIN);
float milliVolts = adcValue * (5000.0 / 1024.0);
float tempC = milliVolts / 10.0;
lcd.setCursor(0, 1);
lcd.print(tempC, 1);
lcd.print(” C “);
delay(500);
}
Common LM35 Problems and Solutions
Problem: Readings Are Stuck at Zero or Very Low
This usually indicates reversed polarity or a bad ground connection. Check your wiring against the pinout diagram. Also verify that 5V is actually reaching the sensor with a multimeter.
Problem: Readings Jump Around Erratically
Noise on the analog input. Add that 0.1µF capacitor between Vout and GND. Also try adding a 10µF electrolytic capacitor across the power supply pins of the LM35.
Problem: Temperature Reads Too High
Self-heating from excessive current draw on the output, or the sensor is picking up heat from nearby components. Check that nothing is loading the Vout pin heavily (the Arduino’s ADC input impedance should be fine). Move the sensor away from voltage regulators and power transistors.
Problem: Can’t Read Negative Temperatures
The basic circuit configuration only measures temperatures above 0°C. For negative temperature measurement, you need a dual-polarity power supply or a bias circuit. Consider switching to the LM36 if you need sub-zero readings in a single-supply configuration.
LM35 vs Other Arduino Temperature Sensors
How does the LM35 stack up against alternatives? Here’s my honest comparison:
Sensor
Output Type
Accuracy
Temperature Range
Price
Complexity
LM35
Analog
±0.5°C
-55°C to +150°C
~$1.50
Low
DS18B20
Digital (1-Wire)
±0.5°C
-55°C to +125°C
~$3.00
Medium
DHT22
Digital
±0.5°C
-40°C to +80°C
~$4.00
Medium
TMP36
Analog
±2°C
-40°C to +125°C
~$1.50
Low
Thermistor
Analog (Resistance)
Varies
-55°C to +150°C
~$0.50
High
The LM35 wins on simplicity and cost for projects that don’t need negative temperature measurement. DS18B20 is better when you need multiple sensors on one wire or digital noise immunity. DHT22 adds humidity sensing. TMP36 handles negative temperatures without extra circuitry but is less accurate.
Practical LM35 Arduino Project Ideas
Once you’ve mastered the basics, here are some projects worth building:
Temperature-Controlled Fan: Read the LM35, compare against a threshold, and switch a relay or MOSFET to control a cooling fan. Simple and useful for equipment enclosures.
Data Logger: Add an SD card module and RTC (real-time clock). Log temperature readings every minute for environmental monitoring or server room auditing.
Thermostat Controller: Combine with a relay module to control a heater or air conditioner. Add hysteresis to prevent rapid cycling.
Multi-Zone Monitor: Use multiple LM35 sensors on different analog pins (A0-A5) to monitor temperatures at various locations. Display on LCD or send to a web dashboard.
Overtemperature Alarm: Trigger a buzzer or LED when temperature exceeds a safe threshold. Useful for 3D printer enclosures or battery charging stations.
Useful Resources and Downloads
Here are the official resources and tools that I reference regularly:
What voltage does the LM35 temperature sensor require?
The LM35 operates on any DC voltage between 4V and 30V. Most Arduino projects use the 5V output from the board. Don’t try to run it from the 3.3V pin—it’s below the minimum operating voltage and will give unreliable readings or no output at all.
Why are my LM35 readings unstable or jumping around?
Analog sensors pick up electromagnetic interference from nearby digital circuits, power supplies, and even building wiring. Add a 0.1µF ceramic capacitor between the Vout pin and GND to filter high-frequency noise. Keep your signal wires short and away from motor drivers or switching power supplies. Software averaging helps too.
Can the LM35 measure temperatures below 0°C?
Yes, but not with the basic single-supply configuration. The LM35’s output voltage goes to zero at 0°C and cannot output negative voltages. To measure negative temperatures, you need to either use a dual-polarity power supply (like ±5V) or add a negative voltage bias circuit. For simpler sub-zero measurements, consider the TMP36 sensor which has a 500mV offset at 0°C.
How accurate is the LM35 compared to digital sensors like DS18B20?
Both sensors offer similar accuracy specifications (±0.5°C typical at room temperature). The practical difference comes down to noise immunity. The DS18B20’s digital output is less affected by electrical interference on long cable runs. The LM35’s analog output requires more care with filtering and shielding for the same accuracy in noisy environments.
Can I connect multiple LM35 sensors to one Arduino?
Absolutely. The Arduino Uno has six analog inputs (A0-A5), so you can connect up to six LM35 sensors directly. Each sensor needs its own analog pin for the output, but they can share the 5V and GND connections. Just read each pin in sequence with analogRead(A0), analogRead(A1), and so on. For more than six sensors, consider using an analog multiplexer IC like the CD4051.
Wrapping Up
The LM35 temperature sensor Arduino pairing remains a solid choice for temperature measurement projects that don’t require humidity sensing or extreme precision. The linear 10mV/°C output, wide operating voltage range, and rock-bottom current consumption make it easy to integrate into both battery-powered and AC-powered systems.
Start with the basic wiring and code examples here, add filtering as needed for your environment, and scale up to displays or data logging as your project demands. The fundamentals don’t change whether you’re reading one sensor or six.
Got questions about implementing the LM35 in your specific project? Drop them in the comments below. I check back regularly and enjoy helping fellow engineers work through hardware debugging challenges.
Inquire: Call 0086-755-23203480, or reach out via the form below/your sales contact to discuss our design, manufacturing, and assembly capabilities.
Quote: Email your PCB files to Sales@pcbsync.com (Preferred for large files) or submit online. We will contact you promptly. Please ensure your email is correct.
Notes: For PCB fabrication, we require PCB design file in Gerber RS-274X format (most preferred), *.PCB/DDB (Protel, inform your program version) format or *.BRD (Eagle) format. For PCB assembly, we require PCB design file in above mentioned format, drilling file and BOM. Click to download BOM template To avoid file missing, please include all files into one folder and compress it into .zip or .rar format.