Temperature Seniors
LM35, Thermistors, interfacing.
Temperature sensing is one of the most fundamental requirements in embedded systems, industrial control, and IoT applications. Choosing the right sensor and correctly interfacing it to a microcontroller determines both the accuracy and reliability of the entire system. This article covers the two most widely used approaches: the LM35 analog temperature sensor and thermistors, along with practical interfacing details.
Core Concept Explanation
The LM35 is a precision integrated circuit temperature sensor whose output voltage is linearly proportional to temperature in degrees Celsius. Its output is 10 mV per degree Celsius, meaning at 25°C the output pin gives exactly 250 mV. This makes interfacing extremely straightforward: connect Vcc (4V to 30V) to pin 1, ground to pin 3, and read the analog voltage from pin 2 directly into the microcontroller ADC. No calibration equation is needed.
A thermistor is a temperature-sensitive resistor whose resistance changes significantly with temperature. There are two types: NTC (Negative Temperature Coefficient) where resistance decreases as temperature rises, and PTC (Positive Temperature Coefficient) where resistance increases. NTC thermistors are far more common in temperature sensing because of their high sensitivity and low cost. However, their resistance-temperature relationship is nonlinear, governed by the Steinhart-Hart equation or the simpler beta (B) parameter model.
To convert thermistor resistance to a voltage suitable for ADC input, a voltage divider is formed with a fixed series resistor R0 (typically equal to the thermistor's resistance at 25°C). The junction voltage varies with temperature and is read by the ADC. The firmware then applies the beta equation to compute temperature from the ADC reading.
Mathematical Expression
For the LM35, the temperature conversion is simply T (°C) = Vout (mV) / 10. In terms of ADC reading, if the ADC has n bits and Vref volts reference, Vout = (ADC_count / 2^n) x Vref, and T = Vout x 100 (since 10 mV/°C means 100°C per volt).
For an NTC thermistor using the beta parameter model: 1/T = 1/T0 + (1/B) x ln(R/R0), where T and T0 are in Kelvin, R0 is the resistance at reference temperature T0 (usually 298.15 K = 25°C), and B is the beta constant (typically 3000 to 4000 K). This equation requires the measured resistance R to be calculated first from the voltage divider output, and then the temperature is computed. Firmware implementations often use a pre-computed lookup table instead of the full logarithm calculation for speed.
Practical Understanding
The LM35 is self-calibrated and requires no external components for basic operation. Its linearity means the ADC reading maps directly to temperature without correction. The main limitation is its analog output: long wiring can pick up noise, and the output impedance at low temperatures may cause ADC loading errors if the ADC input impedance is low. A 100 ohm series resistor and a 10 nF decoupling capacitor from output to ground are standard protective measures.
NTC thermistors offer much higher sensitivity than the LM35, making them useful in narrow temperature ranges requiring fine resolution. However, the nonlinear response requires software compensation. In a typical 10k NTC thermistor circuit, the series resistor is also 10k. The ADC voltage at 25°C is approximately Vcc/2. As temperature rises, NTC resistance falls and ADC voltage rises. As temperature drops, NTC resistance rises and ADC voltage falls.
Self-heating is a practical concern for thermistors. Passing too much current through the thermistor raises its temperature above ambient. Keeping the excitation current below 0.1 mA is a common guideline. This limits the series resistor minimum value to Vcc / 0.1 mA = 33k at 3.3V. In practice, thermistors in divider circuits with 10k to 100k series resistors at 3.3V supply are within safe limits.
Given:
LM35 output voltage Vout = 310 mV
ADC: 10-bit, Vref = 3.3V
Why this formula applies:
LM35 gives 10mV per degree Celsius.
Formula:
T = Vout_mV / 10
ADC_count = (Vout / Vref) x 2^10
Substitution:
T = 310 / 10 = 31°C
ADC_count = (0.310 / 3.3) x 1024 = 96.2 ≈ 96
Calculation:
Expected ADC reading at 31°C = 96 counts
Verify: (96 / 1024) x 3.3 x 1000 = 309.4 mV ≈ 310 mV
Final Answer:
Temperature = 31°C, ADC count = 96Exam Tip: LM35 outputs 10 mV per °C and is always linear. Thermistors are nonlinear. In GATE and university exams, LM35 temperature calculation is straightforward: T = Vout(mV)/10. For thermistors, always expect the beta equation or a lookup table to be involved.
Mechanism and Key Points
- LM35 internal bandgap reference maintains accurate 10 mV/°C slope from -55°C to +150°C without any external calibration or trimming.
- NTC thermistor voltage divider midpoint voltage increases when temperature rises because NTC resistance falls, pulling more current through the fixed R0 and raising the divider output.
- ADC firmware for LM35: T = (ADC_count x Vref x 100) / 2^n. For 10-bit ADC at 3.3V reference, T = (count x 3300) / (1024 x 10).
- For NTC thermistor firmware, first compute R = R0 x (Vcc/Vout - 1) or R = R0 x ADC_count / (2^n - ADC_count), then apply beta equation or lookup table.
- LM35 negative temperature measurement (below 0°C) requires a small negative bias on the GND pin using a resistor to a negative supply, as the output cannot go below GND.
Quick Revision
- LM35: 10 mV per °C, linear, direct ADC connection, no calibration needed. Range: -55°C to +150°C.
- NTC thermistor: resistance decreases with temperature. High sensitivity, nonlinear, needs voltage divider and beta equation.
- Beta equation: 1/T = 1/T0 + (1/B) x ln(R/R0). T and T0 must be in Kelvin.
- LM35 temperature from ADC: T = (count x Vref x 100) / 2^n. At 3.3V 10-bit: T = count x 0.322°C per count.
- Self-heating in thermistors: keep excitation current below 0.1 mA. Use series resistors in 10k to 100k range.
- Exam trap: LM35 output is in mV, not volts. Dividing raw ADC voltage in volts by 10 gives wrong answer. Always convert to mV first.
Temperature Sensors Quiz
Test your understanding of LM35, thermistors, and their interfacing characteristics.
Q1.The LM35 temperature sensor produces an output voltage of 10 mV per degree Celsius. If the LM35 output reads 0.85 V, what is the measured temperature?
Related Articles
ADC Interfacing
Sampling rate, resolution, reference voltage.
6 min read
ADC Types
SAR, Flash, Sigma-Delta architectures.
10 min read
Interfacing Keypad
Matrix keypad scanning.
12 min read
Interfacing LCD
16x2 Character LCD 4-bit mode.
5 min read
Equivalent Noise Temperature
System temperature, antenna temperature.
8 min read