DS18S20 giving slightly to high readings

Hi,

I need a temperature sensor for my project with a resolution of 0.1°C (actually I only need it between 0-80 Degrees, to be honest even less, but it should cover this area) and found this 1-Wire Digital Sensors and decided to try out the DS18S20.

Im using it with the DallasTemperature library and I installed it for testing on a breadboard with an LCD display to see if it works like I want it to, thats the Code Im using (The board is an Arduino UNO):

#include <OneWire.h>
#include <DallasTemperature.h>
#include <LiquidCrystal.h>

#define ONE_WIRE_BUS 10

OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

float Temp = 0;

void setup(void)
{
  Serial.begin(9600);
  sensors.begin();
  lcd.begin(16, 2);
}

void loop(void)
{ 
  sensors.requestTemperatures();
  delay(1000);
  Temp = sensors.getTempCByIndex(0);
  lcd.setCursor(0, 0);
  lcd.print(Temp);
}

The problem I have now is the sensors giving to much temperature, my results I got in 3 longer runs were between 2-6 degrees celsius more then it actually was - Tested 3 different sensors, which are always do the same. In the first attempt I was using the OneWire Sample and all 3 Sensors were giving about the same value.

Yes, Im using the 4k7 Resistor between signal and 5V, and I tried to let it run for longer times. The sensor itself feels cold, so nothing getting warm there... But its still showing about 24.5 celsius while its at most 20-22, probably less... In the cellar (18-19 celsius) I got measurements of 21-22. The worst result was 28 for room temperature...

And when using digital sensors just subtract something from the temperature feels somehow wrong... :wink:

Im thinking of just ordering some DS18B20, but I cannot imagine all my DS18S20 are defective... So I hope you can help me: Either with a fix for my problem, or alternatives I can use...

Mine consistently read high too, at least, higher than other digital thermometers I have in the house. There's the rub though, unless you have a calibrated known accurate thermometer, how do you know which is right? Also there's the issue of the current flowing when you're operating the DS18S20 heating it a little. Have you tried using reference temps such as ice water and boiling water (adjusting for altitude)?

I havent tried some reference temps, maybe Ill do this tomorrow...

Im pretty sure it is showing to much, 25 degrees celsius would be brutal, im sitting here fully clothed ;)...

Also I used an good old mercury thermometer and I got exactly 19 degrees in the cellar, the digital thermometer Im using for different heating baths showed 18.8, And as Im using this one often with boiling water I know its correct...

I have a DS18S20 as well, and it seemed to be reading too high. I thought it was maybe just defective or not calibrated, but maybe they're all like that? I got mine on ebay, so maybe that explains it :stuck_out_tongue:

I was going to try it with ice water, but didn't have any ice, now my UNO is attached to another project...

And as Im using this one often with boiling water I know its correct...

Assuming you are callibrating at sea level :wink:

The boiling point is lower if pressure drops / height increases - http://www.hi-tm.com/Documents/Calib-boil.html -

in Formula form:
Pressure (in. Hg) = 29.921* (1-6.8753*0.000001 * altitude, ft.)^5.2559
Boiling point = 49.161 * Ln (in. Hg) + 44.932

  • Altitude in feet
  • Boiling point in Fahrenheit
  • Pressure in inches Hg

==> Boiling Fahrenheit= 49.161 * Ln (29.921* (1-6.8753*0.000001 * feet )^5.2559) + 44.932


if you want SI units (Meters and Celsius)
1 meter = 3.2808399 feet (3 feet 3? inches);
C = (F-32) / 1.8;
Celsius = (49.161 * Ln (29.921 * (1 - 6.8753*0.000001 * meter *3.2808399 )^5.2559) + 44.932 -32) /1.8
==>
Celsius = 27.312 * LN (29.921 * (1 - 2.255676E-5 * meter)^5.2559) + 7.184;

check meter = 0 ==> 100.005 (accepatable).

From the table on the mentioned webpage one can derive a simpler linear formula (which is easier to inverse, height as function of boiling temperature)

  • Fahrenheit = 212 - 0,0018 * Feet;
  • Celsius = 100 - 0.0059 * Meter;

OK, enough physics for now :wink:

Remember its black, so will be receiving heat-radiation from your body if you are nearby - this is a bigger effect than you might at first think. Many digital thermometers put their sensor inside a metal probe and hence reflect most of the heat radiation.

The DS18B20's I've had (OK, different part with higher resolution) are pretty consistent, several batches, standard deviation less than 0.1 degC between the lot of them (15 devices).

I suspect the "reading high" is just the thermal radiation issue. Wrap them carefully in foil after insulating the leads and see if it makes a difference? Or just move well away from it while taking readings.

Littich:
I need a temperature sensor for my project with a resolution of 0.1°C (actually I only need it between 0-80 Degrees, to be honest even less, but it should cover this area) and found this 1-Wire Digital Sensors and decided to try out the DS18S20.

As I recall, the output of the S series is 9 bit and the B series is 12bit. Are you accounting for that in your code? There are encapsulated versions of the series out there... easy enough to stick one of those into a ice/boiling bath of water to establish some goal posts.

Lastly, it wouldn't surprise me if your room thermostats are off, none of the thermostats I have looked at used such nice sensors... too expensive.

Oh, the other obvious effect is self-heating - the device takes 1 to 1.5mA (at 5V that's upto 7mW of self-heating, which is enough to account for several degrees.

You need to power it down between readings or use forced-air circulation to reduce the self-heating effect. Alternatively provide a small heat-sink to bring its temperature closer to ambient.

  1. You need to make sure your reference thermometer is accurate. Unless you spend a lot of money, it's hard to get thermometers that are more accurate than +/- 0.5C.

  2. The guaranteed accuracy of the DS18S20 is +/- 0.5C over the range -10 to _85C. See http://datasheets.maxim-ic.com/en/ds/DS18S20.pdf.

  3. As MarkT pointed out, self heating causes over-reading. This can be very significant. However, the dissipation is only up to 7mW when a temperature conversion or other operation is taking place. At other times, the dissipation is 5uW maximum. To reduce self heating, don't take temperature readings continuously, take them e.g. once a second. But your code appears to be doing that already.

I have similar problem. Mine is off 2 degrees C.
How did you fix this?

return TemperatureSum - 2;

Mine is off 2 degrees C.

Two degrees is surely unreasonable and more likely to be down to bad code. I recognise that you are using the DS18S20 and I understand they work in much the same way, but I note that the DS18S20 is factory configured to always perform 12-bit conversions and assume it takes about the same time to do so as the preferred DS18B20.

your line

delay(100); //just here to slow down the output so it is easier to read

would have to be one of the most futile bits of code around but, as it stands, it says a lot. Hopefully, it is just a mistake

I think your loop cycle is a little more than about 850ms, being 750 for the conversion plus the little bit you add. The conversion is normally independent of Arduino which can get on and do its own thing, including specific orders to do nothing. You have not given Arduino enough to do, and this means that what could be happening is that the sensor is effectively being used as a timing device, and you could be thereby inviting false readings. If you change the delay from 100 to 1000, you are transferring loop-time control to Arduino, and this may be enough to fix everything.

If you feel you really need the loop cycle times that your code suggests you think you are getting now, you are using the wrong sensor and should replace it with a PT500 or the like.

I submit this self-heating stuff, particularly in your case, is nonsense or, at best, the result of user abuse, and the deafening silence on this matter from Dallas rather suggests they have the same view. Further, the idea of having to add your own corrections to the result returned is surely absurd. If that was the case, everybody would be saving money by using thermistors, and Dallas would be out of business.

I imagine the libraries for the DS18B20s work for the DS18S20. If so, and if the abovementioned small change doesn't fix it, the code could still be suss and you might be better off using something a bit closer to what God and Dallas intended. There are several ways of doing this, all surely better than the convoluted stuff you are using, one of which is here.

rrrrrrr:
I actually have a DS18b20**+**

What a bloody joke...............
I wrote a post, and then thought under the shower "What if all that junk code is legitimate, and there because he is using something other than a DS18B20?". I re-read the heading, doh, and removed my post. Then against my better judgement, I wrote another. No matter, the essential comments still apply for both and, now we all know it is a DS18B20, nobody will ask what possessed you to use DS18S20.

It is just possible that the code is correct for the DS18S20. The fact that there is no setting of the resolution rather suggests this might be the case, and it just might be unsuitable for the DS18B20 - another good reason for ditching it, as previously advised.

For matters of posterity, you might try to fix the title of this thread.

Hah.. yes I knew, but had forgotten you were not the OP. It would be a good idea to start a new thread specifically alluding to the the DS18B20 but I'm really not sure there is much difference and my reply #11 would be much the same anyway. I'm sure you will find the problem is either bad code, or code that has been badly implemented. The first thing to to do though, is work out which code you are using. Clearly, the code you now say you are using is not the same as what you said you are using in reply #9.

If it's the former, it looks conventional enough at a glance but you might strip out the irrelevant stuff to get it down to just a temperature reader and see how that goes.

If it's the code in reply #9, you might check to see if it is actually exclusive for the DS18S20. I suspect it is but it may be claimed to work on the B20. On reflection, I submit it is either wrong for the DS18B20 or, most probably, junk for both, and you would be better off concentrating on the code in the other thread, or the tutorial I mentioned in reply #11

People seem to have odd ideas about temperature.

You think 25 degrees is "brutally hot". But a couple of days ago, another guy was complaining about his device being too cold, because he keeps his house at 27 degrees, I think he said.

You need to calibrate your device against an ACCURATE thermometer.

You need to calibrate your device against an ACCURATE thermometer.

You ought to read his reply#2 again - all of it. It's quite short.

@Littich: The code you posted does not look too strange to a DS18B20 user, but are you sure it is kosher for a DS18S20? A 2-6 degree error is absurd, and about the best line of this whole thread is

And, when using digital sensors, just subtract something from the temperature feels somehow wrong..

You already know what the alternative is.