# Ds18b20 wrong value if temperature is below 0 degrees

**URL:** <https://discourse.nodered.org/t/ds18b20-wrong-value-if-temperature-is-below-0-degrees/40812>\
**Category:** General\
**Created:** [11 February 2021 11:11 UTC](https://discourse.nodered.org/t/ds18b20-wrong-value-if-temperature-is-below-0-degrees/40812 "2021-02-11T11:11:12Z")\
**Posts on this page:** 20\
**Page:** 2

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [11 February 2021 15:24 UTC](https://discourse.nodered.org/t/ds18b20-wrong-value-if-temperature-is-below-0-degrees/40812/22 "2021-02-11T15:24:25Z")

</div>

Remember this used to work, until an upgrade of node-red, though whether that is actually the cause remains to be seen. There can't be a fundamental issue in the ds18b20 node or it would never have worked.

---

<div class="post-metadata">

**Author:** ![RadioFlyer](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/radioflyer/32/21310_2.png) [@RadioFlyer](https://discourse.nodered.org/u/RadioFlyer)\
**Post date:** [11 February 2021 15:42 UTC](https://discourse.nodered.org/t/ds18b20-wrong-value-if-temperature-is-below-0-degrees/40812/23 "2021-02-11T15:42:36Z")

</div>

Yes I am aware of that. I was merely trying to explain what is at the heart of the issue - why you see the number 4039.9

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [11 February 2021 16:50 UTC](https://discourse.nodered.org/t/ds18b20-wrong-value-if-temperature-is-below-0-degrees/40812/24 "2021-02-11T16:50:44Z")

</div>

OK, understood.  
@Speedy are you absolutely certain this used to work?

---

<div class="post-metadata">

**Author:** ![Speedy](https://avatars.discourse-cdn.com/v4/letter/s/ecae2f/32.png) [@Speedy](https://discourse.nodered.org/u/Speedy)\
**Post date:** [11 February 2021 19:17 UTC](https://discourse.nodered.org/t/ds18b20-wrong-value-if-temperature-is-below-0-degrees/40812/25 "2021-02-11T19:17:20Z")

</div>

![grafik](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/d/c/dc3688b79a5a426c04209a198d3daca0eaf0e949.png)

Yes! You see, that till to the update the negative outdoor temperature is shown. There are 13 ds18b20 sensors. They work. I've stop the connect to database because 4000 is not so good for display 😉

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [11 February 2021 20:13 UTC](https://discourse.nodered.org/t/ds18b20-wrong-value-if-temperature-is-below-0-degrees/40812/26 "2021-02-11T20:13:43Z")

</div>

> [@Colin](#):
>
> Did you check the /sys files as I suggested?

Have you done that yet?

---

<div class="post-metadata">

**Author:** ![Speedy](https://avatars.discourse-cdn.com/v4/letter/s/ecae2f/32.png) [@Speedy](https://discourse.nodered.org/u/Speedy)\
**Post date:** [11 February 2021 20:16 UTC](https://discourse.nodered.org/t/ds18b20-wrong-value-if-temperature-is-below-0-degrees/40812/27 "2021-02-11T20:16:27Z")

</div>

Sorry, what you mean?

I can't reply because i a new member.  
Here the Output from the Script:

```auto
 rom: 28-012032f2a482
 temp : 4090.312 °C
 temp : 4090.312 °C
 temp : 4090.312 °C

 rom: 28-012032f2a482
 C=4090.375 F=7394.675
 C=4090.375 F=7394.675
 C=4090.375 F=7394.675
 C=4090.375 F=7394.675

```

I've only one raspberry and the sensor ist ok if the temperature is positive. Before the last update, the values was ok.

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [11 February 2021 20:31 UTC](https://discourse.nodered.org/t/ds18b20-wrong-value-if-temperature-is-below-0-degrees/40812/28 "2021-02-11T20:31:49Z")

</div>

I linked to a tutorial that told you how to do that, and have repeatedly suggested you do it.

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [11 February 2021 20:54 UTC](https://discourse.nodered.org/t/ds18b20-wrong-value-if-temperature-is-below-0-degrees/40812/29 "2021-02-11T20:54:54Z")

</div>

Also, are the other channels on the same pi or on a different one?

---

<div class="post-metadata">

**Author:** ![ScheepersJohan](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/scheepersjohan/32/39556_2.png) [@ScheepersJohan](https://discourse.nodered.org/u/ScheepersJohan)\
**Post date:** [11 February 2021 20:56 UTC](https://discourse.nodered.org/t/ds18b20-wrong-value-if-temperature-is-below-0-degrees/40812/30 "2021-02-11T20:56:35Z")

</div>

Hi,

Have you checked if the DS18B20 is still good?

I have had several failed on me, as mostly what we have available here are fakes.

Please refer to the below, quite a bit of information on the DS18B20

> **[cpetrich/counterfeit\_DS18B20](https://github.com/cpetrich/counterfeit_DS18B20)**
>
> How to tell original from fake DS18B20 temperature sensors.

---

<div class="post-metadata">

**Author:** ![Speedy](https://avatars.discourse-cdn.com/v4/letter/s/ecae2f/32.png) [@Speedy](https://discourse.nodered.org/u/Speedy)\
**Post date:** [12 February 2021 11:47 UTC](https://discourse.nodered.org/t/ds18b20-wrong-value-if-temperature-is-below-0-degrees/40812/31 "2021-02-12T11:47:00Z")

</div>

I can't reply because i'm a new member.

Here the Output from the Script:

```auto
 rom: 28-012032f2a482
 temp : 4090.312 °C
 temp : 4090.312 °C
 temp : 4090.312 °C

 rom: 28-012032f2a482
 C=4090.375 F=7394.675
 C=4090.375 F=7394.675
 C=4090.375 F=7394.675
 C=4090.375 F=7394.675

```

I've only one raspberry and the sensor ist ok if the temperature is positive. Before the last update, the values was ok.

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [12 February 2021 12:09 UTC](https://discourse.nodered.org/t/ds18b20-wrong-value-if-temperature-is-below-0-degrees/40812/32 "2021-02-12T12:09:39Z")

</div>

In order to prove whether it is the node-red update you can go back to the version you had previously, using  
`sudo npm install -g --unsafe-perm node-red@a.b.c`  
where a.b.c is the version you want.

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [12 February 2021 12:16 UTC](https://discourse.nodered.org/t/ds18b20-wrong-value-if-temperature-is-below-0-degrees/40812/33 "2021-02-12T12:16:18Z")

</div>

The script output suggests that it is a clone rather than original (but so are some of mine and they work ok) but it also shows the wrong values, so that suggests it is nothing to do with node-red. Can you swap it for a different sensor to see if that is the problem?

Assuming the script works with -ve values of course.

---

<div class="post-metadata">

**Author:** ![Speedy](https://avatars.discourse-cdn.com/v4/letter/s/ecae2f/32.png) [@Speedy](https://discourse.nodered.org/u/Speedy)\
**Post date:** [12 February 2021 12:20 UTC](https://discourse.nodered.org/t/ds18b20-wrong-value-if-temperature-is-below-0-degrees/40812/34 "2021-02-12T12:20:54Z")

</div>

Hi, i've check with other sensors - same issue. The positive values are ok. Why? I don't think its a sensor problem.

---

<div class="post-metadata">

**Author:** ![Speedy](https://avatars.discourse-cdn.com/v4/letter/s/ecae2f/32.png) [@Speedy](https://discourse.nodered.org/u/Speedy)\
**Post date:** [12 February 2021 12:43 UTC](https://discourse.nodered.org/t/ds18b20-wrong-value-if-temperature-is-below-0-degrees/40812/35 "2021-02-12T12:43:07Z")

</div>

What is with the info from user RadioFlyer?  
"This will turn all negative numbers into large positive ones. For example, 0xFFF8 is -0.5 degrees, but as a positive number it is 65528 and dividing by 16 gives you 4095.5."

And here:

> <https://github.com/charlielito/node-red-contrib-sensor-ds18b20/issues/6>
>
> Hi
> This node has stopped reading negative temperatures - I've tried 3 different sensors and 2 different pi (a Pi 4 2gb...

Why shouldt the sensors this week die? I think is any update!?

This packages was updated before the problem:

```auto
Upgrade: libraspberrypi-bin:armhf (1.20210108-1, 1.20210201-1), libraspberrypi-dev:armhf (1.20210108-1, 1.20210201-1), libraspberrypi-doc:armhf (1.20210108-1, 1.20210201-1), xserver-common:armhf (2:1.20.4-1+rpt2+deb10u2, 2:1.20.4-1+rpt2+deb10u3), libldap-2.4-2:armhf (2.4.47+dfsg-3+rpi1+deb10u4, 2.4.47+dfsg-3+rpi1+deb10u5), xserver-xorg-core:armhf (2:1.20.4-1+rpt2+deb10u2, 2:1.20.4-1+rpt2+deb10u3), libsystemd0:armhf (241-7~deb10u5+rpi1, 241-7~deb10u6+rpi1), node-y18n:armhf (3.2.1-2, 3.2.1-2+deb10u1), nodered:armhf (1.0.6-1, 1.2.9-1), rpi-eeprom:armhf (11.5-1, 11.6-1), libsnmp-base:armhf (5.7.3+dfsg-5+deb10u1, 5.7.3+dfsg-5+deb10u2), node-ini:armhf (1.3.5-1, 1.3.5-1+deb10u1), sudo:armhf (1.8.27-1+deb10u2, 1.8.27-1+deb10u3), udev:armhf (241-7~deb10u5+rpi1, 241-7~deb10u6+rpi1), libmagic1:armhf (1:5.35-4+deb10u1, 1:5.35-4+deb10u2), libpq5:armhf (11.9-0+deb10u1, 11.10-0+deb10u1), libudev1:armhf (241-7~deb10u5+rpi1, 241-7~deb10u6+rpi1), geoclue-2.0:armhf (2.5.2-1, 2.5.2-1+deb10u1), raspberrypi-kernel:armhf (1.20210108-1, 1.20210201-1), device-tree-compiler:armhf (1.4.7-3+rpt1, 1.4.7-4), raspberrypi-bootloader:armhf (1.20210108-1, 1.20210201-1), libsnmp30:armhf (5.7.3+dfsg-5+deb10u1, 5.7.3+dfsg-5+deb10u2), libmagic-mgc:armhf (1:5.35-4+deb10u1, 1:5.35-4+deb10u2), bluez-firmware:armhf (1.2-4+rpt7, 1.2-4+rpt8), systemd-sysv:armhf (241-7~deb10u5+rpi1, 241-7~deb10u6+rpi1), libldap-common:armhf (2.4.47+dfsg-3+rpi1+deb10u4, 2.4.47+dfsg-3+rpi1+deb10u5), libpam-systemd:armhf (241-7~deb10u5+rpi1, 241-7~deb10u6+rpi1), systemd:armhf (241-7~deb10u5+rpi1, 241-7~deb10u6+rpi1), libraspberrypi0:armhf (1.20210108-1, 1.20210201-1), iproute2:armhf (4.20.0-2, 4.20.0-2+deb10u1), unzip:armhf (6.0-23+deb10u1, 6.0-23+deb10u2), grafana:armhf (7.3.7, 7.4.0), file:armhf (1:5.35-4+deb10u1, 1:5.35-4+deb10u2), libgnutls30:armhf (3.6.7-4+deb10u5, 3.6.7-4+deb10u6), ca-certificates:armhf (20200601~deb10u1, 20200601~deb10u2), lxplug-volumepulse:armhf (0.3, 0.4), teamviewer-host:armhf (15.13.6, 15.14.5), raspberrypi-sys-mods:armhf (20201026, 20210208), base-files:armhf (10.3+rpi1+deb10u7, 10.3+rpi1+deb10u8), tzdata:armhf (2020e-0+deb10u1, 2021a-0+deb10u1)

```

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [12 February 2021 13:33 UTC](https://discourse.nodered.org/t/ds18b20-wrong-value-if-temperature-is-below-0-degrees/40812/36 "2021-02-12T13:33:20Z")

</div>

> [@Speedy](#):
>
> And here:

I asked you about that earlier, and I thought your reply meant that you had submitted that issue. If that was not you then that does suggest an update problem, though I don't think it is the node-red update that caused it, more likely something in the system.  
I can't investigate in detail because I don't use the system method of reading the sensors, I use owserver.  
Do you have an SD card backup of your previous working system?

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [12 February 2021 13:41 UTC](https://discourse.nodered.org/t/ds18b20-wrong-value-if-temperature-is-below-0-degrees/40812/37 "2021-02-12T13:41:23Z")

</div>

Also please tell us what you see in the /sys/... file that I keep asking for (as described in the linked tutorial). If you tell me that then I can look at the node's code and hopefully work out what is going on. I can see where it may be failing is something in the system 1-wire driver has changed, but without knowing what is there I have no way of knowing what to do.

Edit: In case a problem has already been found and fixed, run  
`sudo apt update && sudo apt full-upgrade`  
again.

---

<div class="post-metadata">

**Author:** ![Speedy](https://avatars.discourse-cdn.com/v4/letter/s/ecae2f/32.png) [@Speedy](https://discourse.nodered.org/u/Speedy)\
**Post date:** [12 February 2021 15:14 UTC](https://discourse.nodered.org/t/ds18b20-wrong-value-if-temperature-is-below-0-degrees/40812/38 "2021-02-12T15:14:44Z")

</div>

Thank you for your help. I'm not a linux nerd. What for a /sys/ you mean? I backup the database daily and i've a backup from the Node flow. SD-Card Backup is not available.

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [12 February 2021 15:20 UTC](https://discourse.nodered.org/t/ds18b20-wrong-value-if-temperature-is-below-0-degrees/40812/39 "2021-02-12T15:20:29Z")

</div>

Have you read the [link I posted](https://www.waveshare.com/wiki/Raspberry_Pi_Tutorial_Series:_1-Wire_DS18B20_Sensor) in post 14? In particular the section Read Temperature.

---

<div class="post-metadata">

**Author:** ![Speedy](https://avatars.discourse-cdn.com/v4/letter/s/ecae2f/32.png) [@Speedy](https://discourse.nodered.org/u/Speedy)\
**Post date:** [12 February 2021 15:23 UTC](https://discourse.nodered.org/t/ds18b20-wrong-value-if-temperature-is-below-0-degrees/40812/40 "2021-02-12T15:23:13Z")

</div>

```auto
28-012032f2a482 $ cat w1_slave 
d4 ff 4b 46 7f ff 0c 10 54 : crc=54 YES
d4 ff 4b 46 7f ff 0c 10 54 t=4093250

```

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [12 February 2021 15:56 UTC](https://discourse.nodered.org/t/ds18b20-wrong-value-if-temperature-is-below-0-degrees/40812/41 "2021-02-12T15:56:25Z")

</div>

Well that confirms that it is nothing to do with node-red, as the data in the pseudo file is wrong (it isn't a real file I don't think, the system makes it look as if it is).

Did the update command (`sudo apt update && sudo apt full-upgrade`) followed of course by a reboot just in case, make any difference.

[Previous page](https://discourse.nodered.org/t/ds18b20-wrong-value-if-temperature-is-below-0-degrees/40812.md?page=1)

[Next page](https://discourse.nodered.org/t/ds18b20-wrong-value-if-temperature-is-below-0-degrees/40812.md?page=3)
