DS18B20 temperature sensor circuit: accuracy?

I'm running the circuit and sketch from this tutorial, which uses the DS18B20 thermistor:

My circuit is the 'normal' option, reproduced below.

But I'm wondering about the accuracy of the result. My commercial unit that I believe accurate says 19.4 versus 24.1 from the Arduino citcuit. Both probes are suspended and are a mere inch apart.

20:50:58.635 -> Celsius temperature: 24.12 - Fahrenheit temperature: 75.43
20:51:00.417 -> Celsius temperature: 24.12 - Fahrenheit temperature: 75.43
20:51:02.148 -> Celsius temperature: 24.12 - Fahrenheit temperature: 75.43

I'm using identical code, reproduced below.

The only differences I can think of are:

  • I assume a Vcc of 5.0 is used; mine (via USB) is 4.86.
  • I had no 4k7 resistor at hand so used 5K1.

Assuming both of those cause a linear reduction would combine to give a result of 21.7, 2.3 below the program's output.

Comments appreciated, especially from anyone with experience of similar circuits please.

/*********
  Rui Santos
  Complete project details at https://randomnerdtutorials.com  
  Based on the Dallas Temperature Library example
*********/

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

// Data wire is conntec to the Arduino digital pin 4
#define ONE_WIRE_BUS 4

// Setup a oneWire instance to communicate with any OneWire devices
OneWire oneWire(ONE_WIRE_BUS);

// Pass our oneWire reference to Dallas Temperature sensor 
DallasTemperature sensors(&oneWire);

void setup(void)
{
  // Start serial communication for debugging purposes
  Serial.begin(115200);
  delay(200);
  Serial.print("TalkingTemp-DS18B20-Single");
  // Start up the library
  sensors.begin();
}

void loop(void){ 
  // Call sensors.requestTemperatures() to issue a global temperature and Requests to all devices on the bus
  sensors.requestTemperatures(); 
  
  Serial.print("Celsius temperature: ");
  // Why "byIndex"? You can have more than one IC on the same bus. 0 refers to the first IC on the wire
  Serial.print(sensors.getTempCByIndex(0)); 
  Serial.print(" - Fahrenheit temperature: ");
  Serial.println(sensors.getTempFByIndex(0));
  delay(1000);
}

![DS18B20-Circuit-1|690x425](upload://wZ3WV79nkl4YdWzV7BOUGGoqzA5.jpeg)
![DS18B20-Circuit-1|690x425](upload://wZ3WV79nkl4YdWzV7BOUGGoqzA5.jpeg)

Is the offset between the different devices constant?

Have you left the sensors stationary in still air long enough for temperatures to stabilize after handling? Say 15 minutes?
How far apart are they?

From the DS18B20 datasheet:

  • Power supply between 3.0V and 5.5V
  • "The 1-Wire bus requires an external pullup resistor of approximately 5kΩ"

that's ok

Where did you buy your DS18B20? There are lots of "counterfeits" floating around on E-Bay, Ally, Amazon, etc. While not really counterfeit, they may be "rejects" kicked out by the manufacturing QC equipment for being out of spec (+/-0.5°), then bought in bulk and resold as "genuine" by unscrupulous sellers.

Yes, half an hour of observation.

“… a mere inch apart.”

I buy from Mouser, DigiKey, RS, AdaFruit, Jameco, etc. who stand up for the quality of their merchandise.

Sounds too cheap for genuine to me.

Please explain what offsets you mean. And anyway there is no easy or safe access to my commercial device.

What is that unit? 19.4 seems pretty cool for room temp. :slightly_smiling_face:
Did you try another DS18B20?

I mean, if the commercial device reads 20 degrees, does yours read 18, and if the commercial reads 25, does yours read 23?
(And so on)

It's a perfectly comfortable temperature.
Oh. Wait. Are you one of those metrically-challenged North Americans?

Well, here in the SE US the outdoor temp is 34.5, I keep my HVAC tStat at 24.5 and I have no bias against "The Empire" or any other country.

Check it out.

1 Like

It's 23:00 here now, the Sun has been down for perhaps a couple of hours, outside is a shade over 17°, I'm indoors at around 21.5° in jeans and a polo shirt and very comfortable.
I don't imagine I'd be "cool" at 19.4°

Well I guess it would be if you live in Oslo, but the OP didn't say.

No, Oslo is a good way North of here.

I guess lowering your temperature to a comfortable one is just too expensive?

Thanks, understood. I will test over a larger range tomorrow and see how the difference varies, ( I thought perhaps by ‘offset’ you were referring to circuitry voltages.)

At around 21:00 in the late evening the room was cooling down a little, but still perfectly comfortable. Tomorrow I’ll experiment with:

  • alternative probes from the same purchased batch
  • ice cubes in water
  • boiled water
  • one of my DMMs, which has a temperature option

Thanks, interesting and I will. But I haven’t a clue how to perform this ‘pathetically simple’ test!

Regarding (II), there is one pathetically simple test for differences with Maxim-produced DS18B20 sensors that apparently all counterfeit sensors fail [5]:

  • It is a fake if its ROM address does not follow the pattern 28-xx-xx-xx-xx-00-00-xx [5]. (Maxim's ROM is essentially a 48-bit counter with the most significant bits still at 0 [5].) Also, with the exception of rare Family A2 and Family E, none of the fake sensors adjust reserved byte 6 in the scratchpad register correctly. Only the fake sensors of Family A2 respond correctly to undocumented function codes regarding the Trim values.