# DS18B20 to big deviation, 5%

**URL:** <https://forum.arduino.cc/t/ds18b20-to-big-deviation-5/1180306>\
**Category:** Sensors\
**Created:** [October 20, 2023, 9:19am UTC](https://forum.arduino.cc/t/ds18b20-to-big-deviation-5/1180306 "2023-10-20T09:19:32Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Modesty](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/modesty/32/815765_2.png) [@Modesty](https://forum.arduino.cc/u/Modesty)\
**Post date:** [October 20, 2023, 9:19am UTC](https://forum.arduino.cc/t/ds18b20-to-big-deviation-5/1180306/1 "2023-10-20T09:19:32Z")

</div>

Hi

I have 2x DS18B20 sensors on same project.  
Readings are not same

> 01:22:02.000 -\> BStempKube: 25.75  
> 01:22:02.000 -\> BSStempUte: 27.12

Difference is in this case 1.37 celsius, this is around 5% (25,75 \* 1.05=27.12)

I thinks this 5% is much, data sheet +-0.5C.

I guess I run on 9 Bits, std library no spesific Bit programming:

> #include \<OneWire.h\> // DS18B20  
> #include \<DallasTemperature.h\> // DS18B20

Any tip to get?

**Data sheet:**

> Benefits and Features  
> • ±0.5°C Accuracy from -10°C to +85°C  
> ●● Unique 1-Wire® Interface Requires Only One Port  
> Pin for Communication  
> ●● Reduce Component Count with Integrated  
> Temperature Sensor and EEPROM  
> • Measures Temperatures from -55°C to +125°C  
> (-67°F to +257°F)  
> • Programmable Resolution from 9 Bits to 12 Bits  
> • No External Components Required

![image](https://europe1.discourse-cdn.com/arduino/original/4X/5/6/4/564ae069ff06f9bd9092af062c67a41d1e1330f6.jpeg)

---

<div class="post-metadata">

**Author:** ![b707](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/b707/32/854321_2.png) [@b707](https://forum.arduino.cc/u/b707)\
**Post date:** [October 20, 2023, 9:36am UTC](https://forum.arduino.cc/t/ds18b20-to-big-deviation-5/1180306/2 "2023-10-20T09:36:29Z")

</div>

Datasheet is for genuine sensors, and if you bought them on aliexpress, most of the sensors there are fake

---

<div class="post-metadata">

**Author:** ![b707](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/b707/32/854321_2.png) [@b707](https://forum.arduino.cc/u/b707)\
**Post date:** [October 20, 2023, 9:43am UTC](https://forum.arduino.cc/t/ds18b20-to-big-deviation-5/1180306/3 "2023-10-20T09:43:32Z")

</div>

> [@Modesty](#):
>
> I guess I run on 9 Bits, std library no spesific Bit programming:

Sure, by default the library set 9bit resolution,  
However, you can easily change it by `setResolution()` method:

```arduino
// set resolution of all devices to 9, 10, 11, or 12 bits
// if new resolution is out of range, it is constrained.
void DallasTemperature::setResolution(uint8_t newResolution)

```

---

<div class="post-metadata">

**Author:** ![Modesty](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/modesty/32/815765_2.png) [@Modesty](https://forum.arduino.cc/u/Modesty)\
**Post date:** [October 20, 2023, 9:55am UTC](https://forum.arduino.cc/t/ds18b20-to-big-deviation-5/1180306/4 "2023-10-20T09:55:28Z")

</div>

> [@b707](#):
>
> Datasheet is for genuine sensors, and if you bought them on aliexpress, most of the sensors there are fake

This may be the answer.... I

**My order:**  
Nr 1: Digikey

> **[DS18B20 | Digi-Key Electronics](https://www.digikey.no/en/products/detail/umw/DS18B20/16705963?so=81073124&content=productdetail_NO&mkt_tok=MDI4LVNYSy01MDcAAAGLPYD4pl8nZffW3CLG-PCxYFWuJB6eUFQoIvmLKhDU_kCfeBx8dMcE7dHheDhnLEvLDPaSKDfKwnQMqONdvKAxE4UVKHceBkpWC3gsHN0S)**
>
> Order today, ships today. DS18B20 – Temperature Sensor Digital, Local -55°C ~ 125°C 9 b, 10 b, 11 b, 12 b TO-92 from UMW. Pricing and Availability on millions of electronic components from Digi-Key Electronics.

Nr 2  
[https://www.dustinhome.no/product/5011266343/ds18b20-temperature-sensor?ssel=false](https://www.dustinhome.no/product/5011266343/ds18b20-temperature-sensor?ssel=false)

---

<div class="post-metadata">

**Author:** ![Modesty](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/modesty/32/815765_2.png) [@Modesty](https://forum.arduino.cc/u/Modesty)\
**Post date:** [October 20, 2023, 10:39am UTC](https://forum.arduino.cc/t/ds18b20-to-big-deviation-5/1180306/5 "2023-10-20T10:39:12Z")

</div>

> [@b707](#):
>
> ```arduino
> // set resolution of all devices to 9, 10, 11, or 12 bits
> // if new resolution is out of range, it is constrained.
> void DallasTemperature::setResolution(uint8_t newResolution)
> 
> ```

Thanks for tip.  
Added

> sensors.setResolution(12);

Now it reads:

> 12:37:32.987 -\> BStempKube: 26.87  
> 12:37:32.987 -\> BSStempUte: 26.50

Better, not perfect, like 1.3%

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/system/32/1140315_2.png) [@system](https://forum.arduino.cc/u/system)\
**Post date:** [April 17, 2024, 10:40am UTC](https://forum.arduino.cc/t/ds18b20-to-big-deviation-5/1180306/6 "2024-04-17T10:40:01Z")

</div>

Closed on April 17, 2024, 10:40am UTC

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.
