LM35 and TMP36: pinout and wiring
The LM35 and TMP36 are three-pin analog temperature sensors: the output is a voltage proportional to heat. See the pinout, the formulas, how to improve resolution with the 1.1 V reference and try it in the simulator.
Specifications
- LM35 output
- 10 mV per °C (0 V at 0 °C)
- TMP36 output
- 10 mV per °C with 500 mV at 0 °C
- LM35 range (TO-92)
- 2 °C to 150 °C (0 to 100 °C on a single 5 V supply)
- TMP36 range
- -40 °C to 125 °C
- LM35 supply
- 4 V to 30 V
- TMP36 supply
- 2.7 V to 5.5 V
- Accuracy
- ± 0.5 °C (LM35), ± 1 °C (TMP36) at 25 °C
- Package
- TO-92 (3 pins)
Pinout
With the flat face of the TO-92 toward you and the pins down, the order is +Vs, Vout and GND, left to right. Both sensors share the pinout, but reversing the order burns the sensor, so check the package.
LM35 / TMP36 (3 pins)
| 1 | +Vs | Supply, 4 V to 30 V (LM35) or 2.7 V to 5.5 V (TMP36) |
| 2 | Vout | Analog output, proportional to temperature |
| 3 | GND | Ground |
LM35 and TMP36 simulator
Vary the temperature and the ADC reference to see the output voltage and what analogRead returns.
The voltage exceeds the reference: the ADC saturates at 1023. Use the 5 V reference or measure a lower temperature.
Every 10 mV of output equals 1 °C. The reading is limited to 1023 steps between 0 V and the reference, so a lower reference measures in more detail, until it saturates.
How to wire it
Connect +Vs to 5 V, GND to ground and Vout to an analog input such as A0 on the Arduino. A 100 nF capacitor between +Vs and GND, close to the sensor, reduces noise.
For the LM35: temperature (°C) = voltage (V) / 0.01. For the TMP36: temperature (°C) = (voltage (V) - 0.5) / 0.01. The TMP36 measures below zero because it has a 500 mV offset.
With the default 5 V reference, each ADC step is ≈ 4.9 mV, or ≈ 0.49 °C. To improve it, use analogReference(INTERNAL): the 1.1 V reference gives ≈ 0.11 °C per step, but limits the reading to 110 °C (LM35).
Average several readings to reduce ADC noise, and wait a few seconds for the sensor to reach ambient temperature.
The TO-92 LM35 does not measure below 2 °C on a single supply. For negative temperatures use the TMP36 or a digital sensor such as the DS18B20.
Example code (Arduino)
Sketch that reads the LM35 on A0 with the 1.1 V internal reference and prints the temperature in °C.
#define TEMP_PIN A0
void setup() {
Serial.begin(9600);
analogReference(INTERNAL); // 1.1 V reference: 0.11 °C resolution
}
void loop() {
long sum = 0;
for (int i = 0; i < 10; i++) {
sum += analogRead(TEMP_PIN);
delay(10);
}
float voltage = (sum / 10.0) * 1.1 / 1023.0;
float temperature = voltage / 0.01; // LM35: 10 mV per °C
Serial.print(temperature, 1);
Serial.println(" C");
delay(1000);
}
Common mistakes
- Swapping +Vs and GND: the sensor gets very hot and burns out. Check the flat face.
- Using the LM35 formula on a TMP36 or vice versa: the TMP36 has a 500 mV offset, so the result is 50 °C off.
- Using the 1.1 V reference and expecting readings above 110 °C: the reading saturates at 1023.
- Long wires without a filter: they add capacitance and cause oscillation. Use a 100 nF capacitor and short wires.
- Placing the sensor near the regulator or a chip: board heat changes the reading.
Always check the manufacturer's datasheet for your exact model: pin order can vary between modules.
Frequently asked questions
How do I connect the LM35 to Arduino?
+Vs to 5 V, GND to ground and Vout to A0. The temperature is the voltage divided by 0.01 V.
What is the difference between the LM35 and TMP36?
The LM35 outputs 0 V at 0 °C and cannot measure negatives on a single supply. The TMP36 outputs 500 mV at 0 °C and measures from -40 °C to 125 °C.
How do I improve LM35 accuracy on Arduino?
Use analogReference(INTERNAL), which switches the ADC reference to 1.1 V, and average several readings.
Does the LM35 work with ESP32?
Yes, but the ESP32 ADC accepts about 3.3 V at most and is not very linear. Power it from 5 V and read through a divider on ADC1, or prefer the DS18B20.