# How to improve resolution and precision of sensor reading?

I'm trying to measure temperature with an Arduino Uno and an LM335 temperature sensor.

The LM335 can provide differences in temperature between -40C to 100 with a resolution of 10mV. I read the sensor with the (onboard) AVR ADC which is 10-bit.

I use the following conversion to get Celsius from the Kelvin scale that the sensor provides:

$$\ ( \frac{M_s * V}{1024.0f} * \frac{1}{0.01f} ) - 273.15f\$$ where $$\M_s\$$ is the measured sample and $$\V\$$ is the Vvltage of my power supply.

I use the "uncalibrated" method of measurement. (I currently don't care about the calibration procedure.)

How can I improve the measurement perhaps to three decimal points? Is this possible with this sensor and ADC? Can I make multiple measurements perhaps with 2-3 units of sensors with different resistances or with a single unit connected with a multiplexer to different resistance networks so to get a better resolution? What is the common procedures in cases like this?

EDIT: I would further appreciate if the answers include some information about the difference between accuracy, precision and resolution.

For an example as I understand calibration of the sensor module would affect the accuracy of it. i.e. How close are the sensor readings to the "real" quantities but not its precision. My question was aimed at first to improve the "precision" (how close are the readings to the average value of readings.) I said that I don't care right now about the calibration scheme because I 'm not really interested if the temperature is 28.4 and I read in my measurement 29.4. I care if the temperature rises 0.1 C to be able to read it (so if I improve the precision of the readings then I will calibrate the sensor to get better accuracy.)

• "perhaps to three decimal points" easy, just throw away the stuff you currently have and buy metrology grade equipment for a couple of thousand bucks. Commented Jun 12, 2017 at 9:12
• One? oh, easy, just get a high precision pt1000 probe (none of the standard 0.3°C rubbish) and a system that easily measures the difference of resistance between 1085.750Ω and 1085.788Ω accurately (assuming you cancel out self heating effects) Commented Jun 12, 2017 at 9:18
• The LM335 has an accuracy of 1 degC so why do you need 0.001 degC resolution? Commented Jun 12, 2017 at 9:19
• You're forgetting 1mV is actually a pretty small voltage. And that'd only give you a single decimal point. It's a royal PITA to get a 16-bit resolution out of a 16-bit ADC, which would incidentally give you 3.3v / 65535 = 50µV accuracy. 50µV / 10mV = 0.005 so we're up to two digits. If you're getting 16 meaningful bits out of a 16-bit ADC without oversampling you can give yourself a hearty pat on the back. Commented Jun 12, 2017 at 12:33
• I implemented sub-ranging of the silicon-diode temp sensor inside a liquid-nitrogen cooler for IR camera. The principle investigator just wanted to view short-term temperature fluctuations, with no accuracy goal. I summed a DAC (16-bit settability) with silicon-diode output, and amplified the difference by 100X. We easily got 5 milliKelvins per quanta, using a 12-bit 0-5v ADC. Commented Jun 12, 2017 at 16:56

Sorry for my poor explanation and English.

There are a number of important terms in English. But these would have the same scientific meaning in any language. So you'll need to work out the mental "simulation" in your own way of thinking about the world. If you understand the terms well, you will have in your head what others have in theirs and if you apply the terms to some specific situation you will make similar predictions to others seeing the same specific situation, regardless of language, culture, fad, idiom, or century.

These are:

1. precision: (Sometimes called random error.) A measure of statistical variability of a group of measurements made on the same measurement circumstances. It is what remains after corrections are applied using extant science theory and mathematical modeling. The shape of the distribution may be meaningful, and is often left unstated. If measures about the shape are left unstated, it is usually taken to imply Poisson events surrounding some assumed true value in reality, with the usual Gaussian distribution (the integral of Poisson) and therefore the usual meaning of "standard deviation" and "variance" about that value.
2. trueness: (Sometimes called systematic error.) A measure of statistical bias: the difference between the mean of a group of measurements and the best-known "true" value of the measurement circumstances.
3. accuracy: (Sometimes, conflated together with trueness.) This term combines precision and trueness, so that it is worse than either of those individually. The reason trueness is often conflated with accuracy, is that if one knows any two of precision, accuracy, and/or trueness, then the other can be derived from it (so long as the random and systematic errors are Gaussian distributed, anyway.) So just be aware of the context to figure that out.
4. repeatability: The measurement variation that remains after attempting to keep measurement conditions constant (known variables in control) while also using the same instrument and operator and over some "short-enough" time period to avoid long term drift.
5. reproducibility: The measurement variation that remains after attempting to keep measurement conditions constant (known variables in control) but now using different instruments (of the same manufacturing batch or type, typically) and different operators with standardized training, and now over longer time periods where some long term drift may be present. Reproducibility is important in science, because if one researcher has described all of the circumstances needed to reproduce a result, another researcher must read the description and attempt to replicate the circumstances using their own instrumentation and capabilities. They won't have access to the same instruments. And the new researcher is obviously not the same individual, either, though it is reasonable to assume a standard training level between them. So reproducibility provides an idea of how well an experimental result might be replicated. (For example, the reproducibility of a pipette is typically considered to be one half of the smallest visible gradiations marked on it -- which takes into account precision and accuracy of the marks as well as the varying ability of different researchers to use the pipette to measure out a quantity of fluid.)
6. detectability: The smallest possible change in measurement statistics that can be used to distinguish one measurement from another measurement (sometimes, one of those measurements is simply "background fluctuations.) The exact meaning of "distinguished statistically" varies from field to field and may be more a matter of informed opinion. For example, in subatomic physics where statistics dominates discoveries, $$\3\sigma\$$ is considered "evidence for" and $$\5\sigma\$$ is usually considered "detectable." But don't expect the same standards in every field.
7. dynamic range: The ratio between the largest and smallest measurements.

Accuracy and trueness require references back to standards and needs traceability to those standards. Once calibrated against a standard (and this may require just a few calibration points or it may require hundreds or even thousands of them), an instrument will still include both time drift and temperature drift with respect to that calibration event and ambient temperature at calibration. So, the further away in time or the further away in ambient temperature that you use this instrument, the worse its accuracy and trueness becomes.

Even with an infinitely precise instrument, should that ever be considered possible, this fact alone helps you in no way in terms of accuracy and trueness for that instrument. It could still be way off the mark, just infinitely precise at being way off. Precision helps you when it comes to calibration, though, because it helps tell you just how precisely you are accurate or true (consistent with the precision of the accuracy standard, of course.)

Since you mentioned temperature and that happens to be an area where I've spent a little time, let me put of the above into context as well as talk a little about some of the ideas introduced already in other answers.

Accurate temperature measurement generally requires traceability to standards which can tell you the true value of a specific situation. In the US, this usually means being traceable to NIST's standards. (In Germany, DIN.)

Temperature happens to be quite difficult in terms of finding true values. For many decades, this was done using "freeze points," since the process of a pure material going from a melted state into a frozen state is sharper than the reverse transition (from frozen to melted) and because, when using very highly pure ingredients it is possible to make rather accurate theoretical predictions about the freeze point under a set of crafted conditions. These freeze points included copper, gold, and platinum, just to name a few. There are substantial limitations to using freeze points, though. One of them being the limited number of useful ones. The cheapest freeze point is, of course, water. And ice baths are commonly used in order to create one. But sadly, even under the best circumstances, that only provides one calibration point. And it is rarely enough, unless your needed dynamic range is quite narrow and near that freeze point.

NIST has replaced the use of freeze points as they now have better methods. But commercial companies usually use traceable methods, where they buy calibration of a device from NIST and then use it under the specified conditions and for the specified allowable duration before getting a new one or re-calibrating the old one. Tungsten strip lamps and radiation thermometers are examples of traceable standards. (A disappearing filament can often be used to make comparisons between a standard and a target situation to see if they are the same, but usually isn't used to make an absolute measurement.) Some companies will use a secondary standard -- one that is made and calibrated by a company that has purchased a NIST calibrated standard. (The number of "hops" from NIST to the actual calibration of an instrument is often related to its value as a product.)

A single ADC measurement, for example, includes both random and systematic errors. You can sum up ADC values (an average is the same thing as a sum, the only difference being a known factor used to multiply or divide) in order to improve the signal to noise ratio. But this really only works if the random error causes sufficient dithering near one or more ADC digitized values to cause different readings to occur. If the random error in the measurement process is too small, the ADC just reads the same value every time and this cannot be used to improve the signal to noise ratio. All it does is waste time. So if you intend on using this technique, you need to carefully arrange things so that the noise causes some dithering between ADC values. It's not uncommon to target an ADC to read about 2 or 3 bits "into the noise" in order to make this method work reasonably well.

Assuming that the random errors are Gaussian in distribution, the signal will increase by a factor of $$\N\$$ (the number of samples in the sum) while the random errors will increase by a factor of $$\\sqrt{N}\$$. (There is truncation of the noise by the ADC, so that impairs this simplistic calculation a bit.) But the signal also includes systematic errors and these also increase by a factor of $$\N\$$. So summing doesn't reduce the effect of systematic error on the measurement. To help handle systematic error, measurement devices will use more calibration points or else include additional information about the systematic errors between calibration points which can then be used to make additional corrections.

In general, it's quite expensive to achieve accuracy in temperature measurements. (Excepting the case where an ice bath calibration point is used and you don't make measurements far from that calibration point.)

All the above said, it's true that it is important to improve precision if you expect to calibrate a device for accuracy (or trueness) later. That's obvious. And good precision can yield useful detectability, even if you don't know the true value of something.

If you make two of these devices, or more, there will be the issue of reproducability between devices. I think there's an adage about this: "A man with one clock knows what time it is. A man with two clocks is never sure."

Keep this in mind as you move forward.

• Thank you very much for the detailed answer. Much appreciated. Commented Jun 12, 2017 at 18:44

It's always possible to increase the number of digits following a conversion. We simply read multiple times, and average the reading. Viola, more digits, more apparent precision.

Is it worth doing that though?

If the sensor itself is stable to only 1 degree, is it useful to post a result with 3 decimal places of degrees?

If the voltmeter has real accuracy of only 5 LSBs, is it useful to average readings to show 0.01 LSBs?

Those are rhetorical questions, the answer is of course no, it's not worth posting extra decimal places of false precision.

So the question is, what is the real accuracy of the system, including stability, drift, and all the other errors not expressed in the resolution of the ADC.

The fact that you 'don't care about calibration', when calibration, if available, is the first way to improve the accuracy of your system, suggests that you're not really interested in accuracy at all. So, go ahead, average 1000 readings, and post an extra 3 decimal places.

When you have calibrated the system, do it again, and see how close you get. Then rinse and repeat. Then you'll get an idea of repeatability. Now you'll see how many of those decimal places are meaningful. Repeatability is not the sum total of the errors you'll get, but it is perhaps the easiest to measure quickly.

The LM335 has an accuracy of 1 degC. It produces an output voltage of 10 mV/degC.

If your ADC can resolve better than 10 mV then you can achieve a 1 degC accuracy but this also depends on ADC things being good like: -

• Zero offset error
• Gain error
• Differential non-linearity
• Integral non-linearity

So you need a decent ADC and I cannot say if your AVR ADC is any good.

Improving resolution can be a good thing even though you may not improve accuracy - with an improved resolution you can "see" trends better i.e. you can see if something might be drifting up from (say) 30 degC to 31 degC. This can be very useful.

Oversampling gives better resolution but accuracy doesn't change. If you take 4 times as many samples and average them digitally you get a reliable single bit increase in resolution. If you over sample by 16 (4 x 4) you get 2 bits increase in resolution.

64x oversampling gives 3 more bits of resolution: -

But, to get a thousand time increase in resolution (10 bits) means $4^{10}$ x oversampling - that's increasing the sample rate from 1 times a second to over a million times per second.

Using two sensors and two ADCs is fraught with problems especially if you have ADC issues as described above.

• Don't forget about interpolation. Bad for noise, good for you. Commented Jun 12, 2017 at 12:23
• @Barleyman interpolation IS exactly what is being done by oversampling. Commented Jun 12, 2017 at 12:31
• Interpolation is processing the data produced by oversampling. You can oversample to your heart's content without doing anything except creating a larger data file if you don't do the add-and-shift-by-n-bits routine afterwards. Atmel appnote walks through the procedure in a pretty thorough manner. Commented Jun 12, 2017 at 12:39
• @Barleyman So when I said this (If you take 4 times as many samples and average them digitally you get a reliable single bit increase in resolution) in my answer, did you miss it? Yes, the ATMEL document you linked I've read and linked-to a few times over the years Commented Jun 12, 2017 at 12:47
• Better to specify interpolate or people will go around actually averaging-averaging it. There's the noise requirement too. Commented Jun 12, 2017 at 13:00

An ADC is only as accurate as its voltage reference.

Your arduino's ADC reference is either its 5V power supply, which is as inaccurate as they come, plus it depends on how much current you pull on it. Or you can use the micro's internal reference, which you should check, but it sure aint gonna look good against a real voltage reference chip.

So my advice is: use a digital temperature sensor. This side-steps all the signal conditioning and analog pitfalls, noise picked up by cables, etc, plus it's more convenient, and most likely cheaper when you consider the price of a decent analog chain (good analog sensor, good voltage reference for your ADC, what to do against noise, etc).

The classic, DS18B20. Or...

Resolution is cheap, but absolute accuracy is of course NOT cheap. Your choice! Digikey/Mouser search engine is your friend...

10-bit ADC measuring 10 mV/deg sensor over a range of 140 degrees would in IDEAL case have a resolution of 1.4 V / 1024 = 1.37 mV. That would translate to 0.137 degree resolution.

That's presuming you have zero noise, LM335 has zero offset and perfect linearity and finally that your AVR ADC is using 1.4 V as reference for the ADC. Use the VCC (3.3? V) as a reference and you just (more than) halved your resolution.

As others pointed out, you can get more resolution by oversampling. Actually this means oversampling and doing interpolation. At that point, you're doing as well as you can noise and resolution-wise. In fact Atmel has AVR application note (AVR121) for exactly this ADC. You're in luck.

http://www.atmel.com/images/doc8003.pdf

• Thanks, I'm reading the article. It talks about how dithering the signal (noise fluctuations) improves the precision. I'm aware of this method in audio applications (dithering is applied when a digital signal is down-sampled from 32/24bit to 16 bit when you prepare a file for "CD quality". Commented Jun 12, 2017 at 12:57
• @JohnAm I wasn't actually aware of that noise requirement personally. You always learn something new. Commented Jun 12, 2017 at 13:08
• In fact creating that ultra-clean signal environment for the 16-bit ADC would make things WORSE with regards to interpolation. I'll say. Commented Jun 12, 2017 at 13:09
• en.wikipedia.org/wiki/Dither It contains an interesting passage from the history of dither. Commented Jun 12, 2017 at 13:18