View Full Version : 1 wire temperature

01-29-2006, 06:47 PM
I'm trying to achieve better temperature resolution than the 1 degree that follows most of the code for DS18S20. I recall seeing this code at Parallax·webpage but can't find it again.
Any hint is appreciated...

Loopy Byteloose
01-29-2006, 07:23 PM
It is in a Nuts and Volts article, but you have a 12 bit output that provides the greatest resolution and as I recall the article [or maybe the documentation]·used just 8 bits of the 12. You will have to modify the code a bit. (Try column #82, Weather on·the Wire).· Also look for code for the 1822, which is the less accurate cousin.· Finally, try your BasicStamp Manual.

Part of the dilemma is that the 18S20 offers more numerical accuracy than the actually measurement seems to accomodate. I am not sure if the variation is in calibration of individual units or if there is a problem with drift in the actual measurments due to the ambient temperature.

If it is a calibration problem, the information is useful - you have to compensate each one to your own benchmark.
If it is a drift problem, you get a big useless number.

There are platinum resistive elements that are highly accurate and can get down to -100 degrees C.

The Art of Electronics discusses the inherent problems with temperature measurement in silicon devices. While it is wonderful to be able to put a thermometer inside a device for shut down and measurement, there are better older technologies based on very simple physics.

The appeal of the ONE WIRE device is that you can have a network of addressible and confirmible temperature guages. If you have a chemical plant to check the whole network, verify the identity and proper operation of each one AND feel secure in knowing what is really operating.

But, it seem to be a 'ball park' figure -- not a nitty gritty one.

"When all think alike, no one is thinking very much.' - Walter Lippmann (1889-1974)

·················································· ···················· Warm regards,····· G. Herzog [·黃鶴 ]·in Taiwan

Post Edited (Kramer) : 1/30/2006 5:11:00 AM GMT

Kevin Wood
01-29-2006, 07:31 PM
Try using the Google search at Parallax:

search.parallax.com (http://search.parallax.com)

01-29-2006, 08:23 PM
With regards to accuracy I'm properly fine with a 1/2 degree resolution. My project is to develop a better energy calculation based on a diff temperature measurement. Right now I'm measuring input vs output temperature and the diff together with massflow gives an energy figure. I agree that calibration could be an issue but I was not aware of drift due to ambient on the DS1820. I'm measuring in the range of 30 to 55 C and when checked they·been on zero C in ice.

#82 was not the article·I recall, but you right it was properly from the N & V I got it previously.


Jon Williams
01-29-2006, 11:18 PM
I've personally written about high-resolution use of the DS1620, but not the DS1820.· StampWorks 2 also has h/r DS1620 code and after a very quick look at the DS18S20 data sheet I think you can adapt this code pretty easily.· I've attached the code, see this article for reference:


Jon Williams
Applications Engineer, Parallax

Post Edited (Jon Williams (Parallax)) : 1/29/2006 4:26:18 PM GMT

01-30-2006, 02:00 AM
It's possible to get a tad higher resolution out of an 18S20. The trick is
in the spec' sheet for the device.

Look at your BS2p code that reads the temperature from the device.
Notice the 0xBE command that you send to the 18S20? Notice that
the program reads only two bytes for the temperature. The 0xBE
command tells the 18S20 to spit out it scratch pad memory. There
are eight bytes plus a CRC byte available to be read. If you read
bytes 7 & 8, these values allow the reader to perform something akin
to linear interpolation an extract a fractional portion of the temperature.
Well, really "more of the fractional portion....".

Here's a quote from the spec' sheet:

Higher resolutions may be obtained by the following procedure. First, read the temperature,
COUNT_REMAIN, AND COUNT_PER_C registers from the scratchpad. Truncate the 0.5°C bit
(the LSB) from the temperature value. This value is TEMP_READ. The actual temperature may
be calculated by using the following:


Keep in mind that obtaining more RESOLUTION (or PRECISION) may not increase the
ACCURACY of your data! The spec' sheet does state that accuracy of the device is
+/-0.5°C from -10°C to +85°C. (Emphasis is mine).

Bon appetite!

Rusty Haddock = KD4WLZ = rusty@fe2o3.lonestar.org
**Out yonder in the Van Alstyne (TX) Metropolitan Area**
Microsoft is to software what McDonalds is to gourmet cooking

Post Edited (Fe2o3Fish) : 1/29/2006 7:08:06 PM GMT

01-30-2006, 04:06 AM
Thanks all

I'll give it a try.


Loopy Byteloose
01-30-2006, 12:33 PM
The BS2p sample kit had code for the 18s20 or 1822. The data fpr the 1822 provide for .0625 degrees, but accuracy is +/- 2 degrees. Seems they had high unrealized hopes for the silicon.

But you see, that accuracy of +/- 0.5 keeps coming back as a damning reality.
I supose you begin to get statistically random numebrs around the true value.

If you can somehow do a statistical analysis, it might be worthwhile, but you are getting into 'random walk theory' and ozcam's razor.

"When all think alike, no one is thinking very much.' - Walter Lippmann (1889-1974)

·················································· ···················· Warm regards,····· G. Herzog [·黃鶴 ]·in Taiwan