Working Principle
The LM35 (Texas Instruments) and TMP36 (Analog Devices) are precision analog temperature sensors that output a voltage directly proportional to temperature. Unlike thermistors, they provide a linear voltage output without requiring external calibration or linearisation circuits.
Both use silicon bandgap temperature sensing: a pair of transistors operating at different current densities produces a voltage difference proportional to absolute temperature. On-chip signal conditioning amplifies this to a convenient scale.
- LM35: 10 mV/°C, referenced to 0 °C (0 °C = 0 V, 100 °C = 1.0 V)
- TMP36: 10 mV/°C with 500 mV offset (0 °C = 500 mV, 25 °C = 750 mV)
Electrical Characteristics
| Parameter | LM35 | TMP36 |
|---|---|---|
| Supply Voltage | 4–30 V | 2.7–5.5 V |
| Temperature Range | −55 to +150 °C | −40 to +125 °C |
| Accuracy (25 °C) | ±0.5 °C | ±1.0 °C (typ ±0.5) |
| Output Scale | 10 mV/°C (0 °C = 0 V) | 10 mV/°C (0 °C = 500 mV) |
| Output Type | Analog voltage | Analog voltage |
| Current Draw | 60 µA | 50 µA |
| Package | TO-92, SOIC | TO-92, SOT-23 |
Interfacing with an MCU
Both sensors have three pins: VS, VOUT, and GND. Connect VOUT to an ADC input. No pull-up resistors or bus protocols needed — just read the analog voltage.
Calibration
Both sensors are factory-calibrated, but ADC reference voltage accuracy is the weakest link:
- AREF calibration: Measure your Arduino’s actual 5 V rail with a multimeter; use the true value in calculations
- Averaging: Take 10–50 readings and average to reduce ADC noise (LSB jitter ≈ ±0.5 °C)
- Oversampling: Average 64 readings and right-shift by 3 for ~12-bit effective resolution
Code Example
/*
* LM35 & TMP36 Temperature — Arduino
* Wiring: VOUT → A0, VS → 5V, GND → GND
*/
#define SENSOR_PIN A0
#define AREF_VOLTAGE 5.0 /* Measure your actual 5V rail */
#define NUM_SAMPLES 20
void setup() {
Serial.begin(9600);
analogReference(DEFAULT);
}
void loop() {
long sum = 0;
for (int i = 0; i < NUM_SAMPLES; i++) {
sum += analogRead(SENSOR_PIN);
delay(10);
}
float avgADC = (float)sum / NUM_SAMPLES;
float voltage = avgADC * (AREF_VOLTAGE / 1023.0);
/* LM35: tempC = voltage / 0.01 */
float tempLM35 = voltage / 0.01;
/* TMP36: tempC = (voltage - 0.5) / 0.01 */
float tempTMP36 = (voltage - 0.5) / 0.01;
Serial.print("LM35: ");
Serial.print(tempLM35, 1);
Serial.print(" C | TMP36: ");
Serial.print(tempTMP36, 1);
Serial.println(" C");
delay(1000);
}
Real-World Applications
Educational Prototyping & Data Logging
The LM35 and TMP36 are the most widely used sensors in Arduino and electronics education. Their three-pin simplicity, linear output, and zero-component interfacing make them ideal for first sensor projects, science fair weather stations, and classroom data-logging experiments.
Limitations
- ADC resolution bottleneck: A 10-bit ADC on a 5 V reference gives ~4.9 mV/step ≈ 0.49 °C per LSB. Use 3.3 V AREF or an external 12+ bit ADC for finer resolution.
- Self-heating: Long leads or high supply voltage increase self-heating error. Keep VS as low as rated.
- No digital interface: Every reading requires an ADC — not suitable for long cable runs or multi-sensor buses (use DS18B20 instead).
- LM35 negative temps: Requires a negative supply or pull-down resistor circuit to read below 0 °C. TMP36 handles this natively.