13
\$\begingroup\$

I am looking for a cheap solution for sensing temperature with a MCU. My requirements are:

  • 2 channels
  • temp range: 30-35°C
  • temp resolution: 1-2 K
  • cable distance (MCU -> sensor) 10cm - 2m are acceptable
  • relative temperature between two channels is sufficient, no absolute temperature is required

My starting point is two thermocouples with thermocouple amplifiers, but this seems to be overkill for my application. Thermocouples run at 10$ at Radiospares, amps at 5$ which would cost 30$ just to estimate a temperature.

What is a good direction to look for a cheaper solution. NTCs?


Edit 18 July 2012

After stevenvh extended his answer to show the high degree of linearity that can be obtained with NTCs, I invested some time to reconsider whether NTCs are not a better solution.

I am not sure however that I am able to follow stevenvh in his reasoning on the error that can be obtained with NTCs on the cheap compared to semiconductor chips.

To get the temperature with an NTC the following functions come into play:

  1. transfer function \$ H_{T_a\rightarrow R_{NTC}}(R_{25},B_{25/85}) \$ converting the ambient temperature to a resistance
  2. the voltage produced by the voltage divider \$ H_{R_{NTC}\rightarrow V}(V_{excitation},R_{NTC}, R_{lin}) \$
  3. AD conversion \$ H_{V\rightarrow bits}(V, V_{ref}, \sigma_{conversion}) \$
  4. linear curve approximation: \$ H_{bits\rightarrow T_{est}}(bits, \sigma_{approx}) \$

The error sources the I see are thus:

  1. NTC value errors: 1% each for the \$ R_{25} \$ and the \$ B_{25-85} \$ values: total about 2%
  2. 1% for the linearisaton resistor value and let's say 0.5% for the excitation voltage source
  3. For a PIC16F1825 the internal reference voltage used for the ADC has 6% uncertainty. In addition, the ADC itself has integral, differential, offset and gain errors each of the order of 1.5 lsb. At 10 bits, the latter combined are at most 0.5%.
  4. As stevenvh demonstrated in his answer, the linear approximation has an error of merely 0.0015% in the range of interest.

The error in the estimation of the temperature will thus clearly be dominated by the error of the ADV voltage reference and the errors in the resistor values. It will clearly be in excess of the 6%. The error due to linear approximation is utterly negligible as stevenvh pointed out.

An uncertainty of 6% at 300 Kelvin is equivalent to an temperature error of 18K. The temperature chips have an error of about 1K. At 300K this corresponds to an uncertainty of 0.3%.

It would appear to me that it is out of the question to beat this with an NTC without extremely careful calibration and performance verification. The uncertainty in the linearisaton resistors, the excitation voltage or the ADC each viewsed in isolation push the uncertainty of the NTC solution above this. Or do I have a major mistake in my reasoning?

At the moment I am convinced that NTCs can be a high-precision temperature sensing solution but on the cheap it would appear to me that their performance will be a shot in the dark.

\$\endgroup\$

7 Answers 7

12
\$\begingroup\$

1-2 degrees is an easy resolution (even when you mean accuracy, which is not the same!). I would consider LM75 and it various clones, or a DS1820/18S20/18B20/1822. Microchip has a lot of temperature sensors, including LM75 clones for < $1. The voltage output versions are cheap, but I would prefer a digital one.

\$\endgroup\$
3
  • 1
    \$\begingroup\$ All the answers I received on this question were very helpful. I accepted this due to the ease of use of LM75 clones. Not having to worry about linearisation etc. is a great plus in my case. \$\endgroup\$
    – ARF
    Jul 13, 2012 at 8:32
  • \$\begingroup\$ Just curious: Why would you prefer a digital sensor? \$\endgroup\$
    – m.Alin
    Jul 13, 2012 at 15:36
  • 6
    \$\begingroup\$ No worries about references, linearisation, configuring the A/D converter, and the hardware is trivial. The downside is that you have to deal with the protocol. \$\endgroup\$ Jul 13, 2012 at 17:21
16
\$\begingroup\$

I'd say NTC, yes. This one is the cheapest I could find at Digikey. About half a dollar, that's much cheaper than temperature sensor ICs, which have about the same precision. The advantage of an NTC is that it only needs a series resistor and an ADC input on your microcontroller, which most do have nowadays.

The low price has also a disadvantage: NTCs are anything but linear. You either have to use its transfer function (that's with an exponential in it, which you may not like, or use a lookup table, which for the given range may be the best solution.

edit dd. 2012-07-13
Bah, beaten by a miserable LM75. I'm not gonna let this pass. :-)

I'm going to use the *103*MT* from this NTC series. First the transfer function:

\$ R = 10 k\Omega \cdot \large{e^{-13.4096 + \frac{4481.80}T - \frac{150522}{T^2} + \frac{1877103}{T^3}}} \$ ,

where \$T\$ is in Kelvin.

Doesn't look promising, and indeed between 0 °C and 100 °C the curve looks like this:

enter image description here

anything but linear, like I said. We can try to linearize that, but remember that we're going to make a resistor divider with it, and they're not linear either, so any linearization now will be ruined by the series resistor. So let's start with the resistor and see what happens. I have a 3.3 V supply and pick a 5.6 kΩ resistor to Vcc, then the output becomes

enter image description here

Not bad at all! The purple curve is the tangent in our range of interest: 30 °C to 35 °C. I could plot the graph zoomed in on that, but that gives us two coinciding lines, so let's have a look at the error:

enter image description here

Doesn't look nice either, but you have to look at the vertical scale, which gives the relative error of the linear approximation compared to our NTC characteristic between 30 °C to 35 °C. The error is less than 15 ppm, or 0.0015 %.

Mathematica say the equation for our nearly perfect linear approximation is

\$ V_{OUT} = - 0.0308 \text{ }T \text{ }\cdot 1 V/°C + 2.886 \text{ }V \$

This will result in ADC readings of 609 and 561, resp. for a 10-bit ADC. That's a range of 48 for a 5 °C difference, or about 0.1 °C resolution. Just the NTC and a resistor.

Who needs an LM75!?



edit dd. 2012-08-13

Fact: the NTC solution needs calibration.

I promised Arik to get back on the error calculation, but it's a lot more complicated than I thought, and it can't be completed because of incomplete data. For instance, I have very precise numbers for the coefficients in the NTC's transfer function (the 7 significant digits numbers are already rounded!), but no information on their accuracy. A few comments though.

Arik adds errors, like 1% resistance tolerance + 1% on the \$\beta\$ = 2 % error. Well, it's not that easy, and that's part of the complication I referred to. A 1 % tolerance on the \$\beta\$ results in a 0.1 % error in the result, for instance.

Errors are not always expressed the same. Maxim's LM75 datasheet, for instance, doesn't mention minimum and maximum errors, but three-sigma and six-sigma values. On the other hand the Vishay NTC datasheet speaks of \$\pm\$ 1 % error. Is that six-sigma? Seven-sigma? Then it may turn out to be more accurate than the LM75, which is 2 °C accurate six-sigma, even 3 °C over temperature range. That's nothing to be ashamed of; few sensors will do much better without calibration. Question: how do you compare tolerance figures? And another one: how do you combine several bell curve functions to get a total error?

The PIC's ADC reference has a pretty bad 6 % tolerance. Arik says An uncertainty of 6% at 300 kelvin is equivalent to an temperature error of 18 K, which of course is preposterous and utterly absurd. I made a quick check: calculated the voltage divider's output for a temperature of 20 °C. Added 6 % to that, and calculated back to the NTC's resistance value, and the temperature that would be. The error is not 18 °C, but 1 °C, or less than 0.5 %, referred to 0 K.

Even so, the 6 % error is completely irrelevant! If you use the ADC's reference voltage for the resistor divider that voltage doesn't even appear in the calculations. I wouldn't care if the error was 50 %. Use another reference if the bad internal reference isn't available outside the controller. Like the 3.3 V power supply, or just any other DC voltage you have laying around.

The calibration is not what you want for a one-off project, but for mass-production it's no worry at all, and especially in consumer electronics, where every cent counts, you'll more likely find the NTC than an expensive LM75.

\$\endgroup\$
8
  • 3
    \$\begingroup\$ The nice thing about asking the experts is that you get every answer (analog versus digital), now Arik just needs an expert to choose between the experts :) \$\endgroup\$ Jul 11, 2012 at 17:58
  • 1
    \$\begingroup\$ About half a dollar? Isn't this the same item that you mention? It is $0.15/100pcs. And MCP9701A is about $0.25/100pcs. Wow, I thought the digital ones were so expensive, like $2 or $3 each! \$\endgroup\$ Jul 11, 2012 at 18:48
  • 3
    \$\begingroup\$ @abdullah - everything is relative. A great engineer would probably point at the series resistance 1 % tolerance, and its 100 ppm/°C temperature coefficient. In any case if we have reading errors it won't be due to the approximation! :-) \$\endgroup\$
    – stevenvh
    Jul 16, 2012 at 14:47
  • 2
    \$\begingroup\$ @stevenvh Your extended answer gave me reason to revise my original assessment. However, I am not sure I completely understand how you can arrive at a high-precision measurement with NTCs on the cheap. I would appreciate if you looked at my edited question and told me whether I have a flaw in my reasoning. Many thanks for your help! \$\endgroup\$
    – ARF
    Jul 18, 2012 at 18:13
  • 2
    \$\begingroup\$ @Arik - updated my answer. I felt especially the alleged 18 K error needed a response :-) \$\endgroup\$
    – stevenvh
    Aug 13, 2012 at 8:57
6
\$\begingroup\$

This sounds like a job for a thermistors, or two thermistors to be more precise. Since you only need to distinguish three different temperature states and you are only looking for relative temperature, you can connect the two thermistors together to make a single analog signal. That can then be measured with a A/D built into the micro. Most micros have A/Ds, so this won't cost anything more. I'd probably add a couple resistors and capacitors as a low pass filters to reduce noise.

One thermistor goes from ground to the analog signal and the other from power to the analog signal. You may need to do some calibration, but with your narrow temperature range and low resolution you don't need to get fancy. Probably just saving the zero-difference voltage and subtracting that from future reading is enough.

\$\endgroup\$
4
  • \$\begingroup\$ Thanks for the hint regarding using two thermistors in voltage divider configuration to measure a relative voltage. I would not have thought of that. \$\endgroup\$
    – ARF
    Jul 13, 2012 at 8:31
  • \$\begingroup\$ @Arik - the two thermistors in series only work if their resistance varies linearly with temperature, so be sure to check that. (I did in my answer.) \$\endgroup\$
    – stevenvh
    Jul 13, 2012 at 18:26
  • \$\begingroup\$ @stevenvh: Yes, you're right, but note the very narrow temperature range and the low resolution. Two thermistors once calibrated to the equal temperature case near the middle of the range should do well enough. One will never be off from the other by more than 5 degC. \$\endgroup\$ Jul 13, 2012 at 19:54
  • \$\begingroup\$ @Olin - All true. I guess I should have added "in case you ever want to measure over a much wider temperature range". \$\endgroup\$
    – stevenvh
    Jul 14, 2012 at 5:11
6
\$\begingroup\$

If you are not aware of the stepped diode current delta-Voltage method of temperature measurement and are interested in measuring temperature, you should read this - it may transform your ideas on temperature measurement.


I'm a little late to the party.
As the answer will have been utilised by now I'll largely just outline an alternative method which has considerable merits but which seems to be surprisingly little used in discrete form.

This method is commonly used in IC temperature measurement ICs but still seems less known than would be expected.

If a silicon (say) diode is alternately fed with two known currents, the delta voltage change with change in current is related to the absolute temperature.

This method is used in (at least) the TI LM82, LM83, LM84, LM87 & LTC3880, LTC3883 and LTC2974 sensors.

Note that this method is different from the usual method of measuring absolute diode forward voltage drop at a given current to infer temperature. This method is both substantially more accurate and does not require sensor-specific calibration.

Accuracies of around 0.1 degree C (or K) are achievable.
Resolutions are dependant on measurement method.

The result is device calibration free.
The result is dependent only on the basic diode type (eg silicon, germanium)
eg if you use a sub 1 cent 1N4148 signal diode, you can change one out for another 1N4148 and get the same accuracies without recalibration.

The accuracy of setting the two currents used obviously affects result accuracy, but as these can be chosen to suit available resources, the results can be very good.

This method is used by some but not all on-die processor temperature measurement systems. You will usually find that where this system is used, the technical descriptions are very light on detail and somewhat obfuscated - ie they seem to want to keep it secret even though the method probably dates back to work by Widlar in the mid 1960s.

This method rivals the accuracies achievable with reasonable care using NTC thermistors or PT100 etc Platinum resistors and similar, with a very competitive degree of complexity and difficulty.


This excellent 1999 Analog Devices application note Measuring temperatures on computer chips with speed and accuracy claims the technique is a new one. I'm not at all sure that they are correct - but it is certainly useful and less known that would be expected.

From the above paper (slightly rewritten) for currents of I and N.I and diode voltage drop Cv1 at current 1 and Vd2 at current 2:

Vd1 – Vd2 = DVd = (kT/q) ln (I/NI) = (kT/q) ln (1/N)

Since N, k, and q are all known constants,
T = (Constant)(DVd)

_

Excellent TI app note Multiple Remote Diode Temperature Sensing

Wikipedia - Silicon bandgap temperature sensor

[LT AN137 Accurate Temperature Sensing with an External P-N Junction] http://cds.linear.com/docs/Application%20Note/an137f.pdf
Used in eg LTC3880, LTC3883 and LTC2974.

\$\endgroup\$
4
\$\begingroup\$

Very simple Temperature (Celcius) measureent with Thermistor (10K) B25/100=4300 I got inspired from the above comment read in this article.

I bought thermistors from DigiKey 10K 5% at $1 each. I Wanted to get a fair temperature measurement without floating and complex math. Connecting to a Arduino as follow: Vref to 3.3v; analog-0 A0 through a 10K resistor and 3.3v. ; Thermistor A0 to ground. I get the temperature in Celcius as follow: Partial code: analogReference(EXTERNAL);
ADC = analogRead(0);
Th = 10000 / (1023 / ADC) -1; // 10000 is the fix resitor used in the divisor.
T = (775 - Th) / 10 ;

Accruacy is: +1 at 25C, +0 at 20C, -1 at 0C, +2 at -20C. You change the 775 constant to ajust closer to the desire range you want. For example, use 765 instead of 775 to get 0 error around 25C. As this is integer math, I added 5 to 770 before dividing by 10 to round off.

Showing relation between Thermistor, ADC, Temperature and Calculated result

\$\endgroup\$
1
  • \$\begingroup\$ Thanks for including some Arduino code! \$\endgroup\$ Jul 10, 2021 at 0:22
1
\$\begingroup\$

I'm using LM35DZ. Temperature ranged 0 Celsius to 100 Celsius, linear output and low impedance; I have been using it with direct connection to my PIC ADC input, works very well so far.

One unit cost around USD 3.

\$\endgroup\$
2
  • 3
    \$\begingroup\$ And he'll need two of them. Doesn't look like a cheap solution to me. Not compared to my great NTCs! :-) \$\endgroup\$
    – stevenvh
    Jul 16, 2012 at 6:31
  • \$\begingroup\$ I use the LM35 chips as well (and I like them), but I do think they are a little overkill for this question. \$\endgroup\$
    – Johan
    Jul 16, 2012 at 11:57
1
\$\begingroup\$

Very simple Temperature (Celcius) measureent with Thermistor ... at $1 each.

How about a STM32F0 chip? Its ADC module contains an internal temperature sensor AND calibrated values at two temperature points AND calibrated value for its internal Vref generator.

With all of that combined, you can use it as a very accurate temperature sensor - 12-bit adc, and sigma being just over 1 lsb - over a wide voltage range.

It can be also programmed as a dedicated tempearture sensor: mostly in sleep and wake up to read temperature and transmit data and then go back to sleep.

all of that for less a dollar in small quantities.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.