Temperature Sensor Selection: NTC, DS18B20 vs LM56

Selection Guides and Comparisons Intermediate 10 min read Published:
Cover illustration showing NTC thermistor, DS18B20 and LM56 temperature sensors

The first question in choosing a temperature sensor is what you want at the end of the measurement. If your microcontroller has a free ADC input and you need a small glass-bead sensor glued to a surface, an NTC thermistor is the most flexible option. If you want to read several points over one cable with ±0.5 °C accuracy and no calibration, a digital sensor such as the DS18B20 saves work. If you need a threshold decision such as “turn the fan on above 45 °C” without any software, a thermostat IC such as the LM56 provides a logic output directly. This guide compares the three sensors using datasheet values and gives a connection and calculation example for each.

Three sensors, three different outputs

What sets these sensors apart is the form in which they report temperature. That difference determines the circuit design, the software effort and the error budget from the start.

  • An NTC thermistor is a passive component whose resistance decreases as temperature rises. Its output is a resistance: you need a voltage divider to turn it into a voltage, an ADC to read it and an equation to convert it to temperature. Example product: MF58-104J3950F (100 kΩ at 25 °C, B25/50 = 3950 K, glass bead).
  • The DS18B20 is a digital thermometer IC that measures temperature internally, converts it to a digital value and sends it over the 1-Wire bus. Its output is a number directly in °C.
  • The LM56 is a thermostat IC containing a temperature sensor, a 1.250 V reference and two comparators with hysteresis. It provides two open-collector logic outputs and an analog voltage (VTEMP) that varies linearly with temperature.

Comparison table

The values below are taken from the manufacturers’ datasheets. Because NTC accuracy depends on the circuit and the conversion method, the table lists the sensor’s own tolerances for the NTC.

Parameter MF58-104J3950F (NTC) DS18B20 LM56CIM
Output type Resistance Digital, 1-Wire 2 logic outputs + analog VTEMP
Operating temperature −55 … +250 °C −55 … +125 °C −40 … +125 °C
Accuracy / tolerance R25 ±5%, B value ±1% ±0.5 °C (−10 … +85 °C), ±2 °C (full range) Trip point accuracy ±3 °C (+25 … +85 °C), ±4 °C (−40 … +125 °C)
Supply None (current flows through the divider) 3.0 … 5.5 V or from the data line (parasite power) 2.7 … 10 V
Current Depends on the divider During conversion typ. 1 mA, max. 1.5 mA (VDD = 5 V) Max. 230 µA
Resolution / speed Depends on the ADC; thermal time constant ≤ 20 s (still air) 9–12 bits; 0.0625 °C at 12 bits, conversion max. 750 ms VTEMP 6.20 mV/°C; hysteresis typ. 5 °C
Package Glass bead, axial leads TO-92 (3 pins) SOIC-8
Software required ADC + conversion equation 1-Wire driver None

NTC thermistor: flexible, but it needs calculation

The resistance-temperature relationship of an NTC is not linear. In practice most designs use the Beta (B) equation:

R(T) = R25 · e^( B · (1/T − 1/298.15) )

Here T is in kelvin and R25 is the thermistor’s resistance at 25 °C. The MF58 series datasheet defines the B value from the slope between 25 and 50 °C (B25/50). The equation therefore works best around that range, and the deviation grows the farther you move from it. For better accuracy over a wide range, use the manufacturer’s resistance-temperature table if one is provided; otherwise use the Steinhart-Hart equation or calibration.

Voltage divider and example values

In the example below, the NTC is connected between 3.3 V and the ADC input, and a 100 kΩ fixed resistor is connected between the ADC input and ground. As temperature rises, the NTC’s resistance falls and the ADC voltage rises. Choosing the fixed resistor equal to R25 puts the output at exactly half the supply voltage (1.65 V) at 25 °C and gives the steepest slope around room temperature.

VADC = 3.3 V · 100 kΩ / (RNTC + 100 kΩ)

Voltage divider with a 100 kΩ NTC and a 100 kΩ fixed resistor, and the ADC voltage curve from 0 to 85 °C
Figure 1. NTC on top, 100 kΩ fixed resistor at the bottom: the ADC voltage rises with temperature. The curve is calculated from the Beta equation.

The resistance and voltage values in the table are estimates calculated from the Beta equation; the datasheet does not include a resistance-temperature table for this product.

Temperature RNTC (Beta estimate) VADC (3.3 V, 100 kΩ) 12-bit ADC code (V/3.3 · 4095)
0 °C 336.2 kΩ 0.757 V 939
25 °C 100.0 kΩ 1.650 V 2048
40 °C 53.0 kΩ 2.157 V 2676
50 °C 35.9 kΩ 2.429 V 3014
60 °C 24.9 kΩ 2.643 V 3280
85 °C 10.9 kΩ 2.977 V 3694

Around 25 °C the output changes by about 36.7 mV/°C. One step of a 12-bit ADC with a 3.3 V reference is about 0.8 mV, so the reading resolution is on the order of 0.02 °C. This value shows only the resolution; the accuracy is set by the tolerances in the next section.

NTC error budget

The sensor’s tolerances determine the accuracy. At 25 °C the NTC’s resistance changes by about 4.4% per degree (found from B/T²). Since the R25 tolerance is ±5%, this tolerance alone adds an uncertainty of about ±1.1 °C at 25 °C. At 85 °C the sensitivity drops to 3.1%/°C; the effect of the R25 tolerance rises to about ±1.6 °C, and the ±1% tolerance of the B value adds about ±0.7 °C. These figures are also estimates based on the Beta equation. The fixed resistor’s tolerance, the ADC reference and the deviation of the Beta model itself come on top of them. If you need to get below ±1 °C, calibrate the NTC at known temperatures.

Self-heating is not a problem in this divider. The power dissipated in the NTC peaks when the NTC resistance equals the fixed resistor: 3.3² / (4 · 100 kΩ) ≈ 27 µW. Since the datasheet gives a dissipation factor of at least 2 mW/°C, this power causes at most about 0.014 °C of heating. Redo this calculation when you use a lower-value NTC (e.g. 10 kΩ) on the same supply.

DS18B20: digital measurement without calibration

The DS18B20 is accurate to ±0.5 °C from −10 to +85 °C and ±2 °C from −55 to +125 °C. Resolution is selectable as 9, 10, 11 or 12 bits, corresponding to steps of 0.5, 0.25, 0.125 and 0.0625 °C respectively. The default resolution at power-up is 12 bits. Higher resolution takes time: the maximum conversion time is 93.75 ms at 9 bits and 750 ms at 12 bits.

Every DS18B20 contains a unique, laser-programmed 64-bit ID code (family code 28h). This lets many sensors share the same data line, and the microcontroller reads each one by its address. Monitoring several points in a storage room, an electrical cabinet or a greenhouse from a single GPIO pin is the main case where the DS18B20 has the edge over an NTC.

TO-92 pinout and pull-up resistor

In the TO-92 package, with the flat face toward you and the leads pointing down, the pins from left to right are 1 = GND, 2 = DQ (data), 3 = VDD. Because DQ is an open-drain output, the line needs a pull-up resistor; in the datasheet’s application figures this resistor is 4.7 kΩ.

Two DS18B20 sensors connected to a shared 1-Wire line with a 4.7 kΩ pull-up resistor, and the TO-92 pinout
Figure 2. DS18B20 with external power: all sensors share the same DQ line and a single 4.7 kΩ pull-up resistor.

There are two ways to power the sensor:

  • External power: the VDD pin is connected to 3.0–5.5 V. No MOSFET is needed for a strong pull-up, and the data line stays free for other traffic during conversion. This is the recommended approach for new designs.
  • Parasite power: the VDD pin is connected to ground and the sensor takes its energy from the data line. Because the pull-up resistor cannot supply the current drawn during conversion, the line must be pulled directly to the supply by a MOSFET within 10 µs after the Convert T command and held there for the whole conversion. No other communication can take place on the line during that time.

LM56: a thermostat without software

The LM56’s two trip temperatures (T1 and T2) are set by dividing the 1.250 V reference voltage with three resistors. When the temperature exceeds T1, OUT1 is pulled to logic 0; when it exceeds T2, OUT2 is pulled to logic 0. When the temperature falls about 5 °C below the threshold, the output is released again; this typical hysteresis is fixed inside the IC. At 25 °C the hysteresis is at least 3.5 °C and at most 6.5 °C.

The design equations in the datasheet are as follows (R1 is between VT1 and GND, R2 between VT1 and VT2, and R3 between VT2 and VREF):

  • VT = 6.20 mV/°C · T + 395 mV (550 mV at 25 °C)
  • R1 + R2 + R3 = 27 kΩ (so that VREF sources about 50 µA)
  • R1 = VT1 / 1.25 V · 27 kΩ, R2 = VT2 / 1.25 V · 27 kΩ − R1, R3 = 27 kΩ − R1 − R2

Worked example: fan at 45 °C, alarm at 75 °C

  1. For T1 = 45 °C, VT1 = 6.20 · 45 + 395 = 674 mV.
  2. For T2 = 75 °C, VT2 = 6.20 · 75 + 395 = 860 mV.
  3. R1 = 0.674 / 1.25 · 27 kΩ = 14.56 kΩ → standard value 14.7 kΩ.
  4. R2 = 0.860 / 1.25 · 27 kΩ − 14.56 kΩ = 4.02 kΩ → 4.02 kΩ.
  5. R3 = 27 − 14.56 − 4.02 = 8.42 kΩ → 8.45 kΩ.
  6. Check: total 27.17 kΩ, VREF current about 46 µA. The actual thresholds come out at 45.4 °C and 75.2 °C.
LM56CIM pinout, R1, R2, R3 resistor network for 45 and 75 °C thresholds, and 100 kΩ pull-up resistors
Figure 3. Two-threshold thermostat with the LM56: R1, R2 and R3 set the thresholds, and the open-collector outputs are pulled up with 100 kΩ.

This result does not change the LM56CIM’s own trip point accuracy (±3 °C from +25 to +85 °C). Resistor tolerance also shifts the threshold. In the datasheet’s two-resistor 82 °C example, ±1% resistors add about ±0.8 °C; in the three-resistor network here, the worst case for the 45 °C threshold is about ±1 °C. If threshold precision matters, use ±1% or better metal film resistors.

OUT1 and OUT2 are open-collector outputs; the logic 0 voltage is specified as max. 0.4 V at 50 µA. The datasheet states clearly that these outputs are not intended to drive a fan motor directly. Connect the output with a high-value pull-up resistor (100 kΩ in the datasheet example) to a microcontroller input or to a transistor or MOSFET stage. Because the output is pulled to 0 when hot, you need an inverting stage if you switch the fan low-side with an N-channel MOSFET; if the fan supply does not exceed the outputs’ 10 V limit, the output can be used without inversion in a high-side switch with a P-channel MOSFET. For details on driving loads with a MOSFET, see our article Using a MOSFET with Arduino.

Which one for which job?

Requirement Suitable choice Why
Reading many points over one line DS18B20 64-bit ID code, single data line
Hitting ±0.5 °C without calibration (−10 … +85 °C) DS18B20 Accuracy specified at the factory
Above 125 °C, winding or heatsink surface NTC Operating range up to +250 °C, small glass bead
Simple analog measurement, small sensor glued to a surface NTC Ø1.8 mm glass bead, read directly by an ADC
Over-temperature protection or fan threshold without software LM56 Two comparator outputs with hysteresis
Threshold + analog monitoring without a microcontroller LM56 VTEMP analog output alongside the threshold outputs

You can also make a threshold decision with an NTC: the divider output goes to a comparator and hysteresis is added with resistors. We walked through that calculation step by step in our article Comparator hysteresis calculation with the LM393. The LM56 does the same job in a single IC with fixed hysteresis.

Common mistakes

  • Constantly reading 85 °C from the DS18B20. The power-on value of the temperature register is +85 °C. This value usually means the reading was taken before the conversion finished, or that not enough energy was supplied for the conversion in parasite power mode.
  • Leaving VDD floating in parasite power mode. The datasheet requires the VDD pin to be grounded in parasite power mode.
  • Reversing the TO-92 pins. With the flat face toward you and the leads pointing down, the order from left to right is 1 = GND, 2 = DQ, 3 = VDD. Turn the package around and look from the back, and the order appears reversed.
  • Using the NTC’s B value outside its range. Because the B value is defined from the slope between 25 and 50 °C, the Beta equation’s error grows the farther you move from that range. If you will measure at very low or very high temperatures, use Steinhart-Hart coefficients or calibration.
  • Assuming the LM56 measures ambient air. According to the datasheet, the LM56 mainly measures the temperature of its leads and the copper area they are attached to. If you want to monitor a heatsink, place the IC on a copper area thermally bonded to that surface.
  • Increasing the LM56’s total resistance. If the total differs much from 27 kΩ, the VREF load current and the effect of the comparator input currents change, and the thresholds shift.

Frequently asked questions

Which is more accurate, an NTC or the DS18B20?

Without calibration, the DS18B20 is more accurate: it guarantees ±0.5 °C from −10 to +85 °C. An NTC with ±5% R25 tolerance carries an uncertainty of about ±1.1 °C at 25 °C from this tolerance alone. A calibrated NTC, however, can do better than that with a good ADC.

What pull-up resistor is used for the DS18B20?

The datasheet’s application figures use 4.7 kΩ. The resistor is connected between the data line (DQ) and the voltage that powers the sensors.

Can the LM56 drive a fan directly?

No. OUT1 and OUT2 are open-collector logic outputs, and the datasheet states that they are not intended to drive a fan motor directly. Use a transistor or MOSFET stage in between.

Should I choose a 100 kΩ or a 10 kΩ NTC?

A 100 kΩ NTC draws less current from the divider and has lower self-heating, which is an advantage in low-power circuits. In environments with long cables or high noise, a lower-impedance divider picks up less interference. Match the value you choose with the fixed resistor in the divider, and check your ADC’s input impedance requirement.

How long does a DS18B20 measurement take?

It depends on the resolution: max. 93.75 ms (9 bits), 187.5 ms (10 bits), 375 ms (11 bits) and 750 ms (12 bits).

Conclusion

Choosing a temperature sensor comes down to who evaluates the measurement. If the measurement will be evaluated in software and several points are monitored, start with the DS18B20; if it involves high temperature or a small surface and an ADC is available, start with an NTC; if the decision is made in hardware, start with the LM56. The datasheets of all three products are on their product pages; for other packages and ranges, browse the NTC thermistors and temperature sensor ICs categories.

DS18B20+Analog Devices Inc. · EE00652-1$12.3530 In StockView

MF58-104J3950FNanjing Shiheng Electronic · EE02468$0.107 In StockView

LM56CIMTexas Instruments · EE0669$2.4150 In StockView

References

Ask Claude or ChatGPT about the parts in this article and their alternatives: your assistant brings them from our catalog with stock and prices.

How do I connect?

Products in this article

More from Selection Guides and Comparisons

For AI assistants

Search our catalog with Claude or ChatGPT

You came here from an AI assistant. Connect Claude or ChatGPT to Entegreci once, and it searches our catalog for the parts you ask about and brings back products with their availability, current price and a link.

“Is the 1N5819 in stock, and what could I use instead?”

Free for members. The assistant only reads the catalog; it can't place orders or see your account details.