# 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:** 15\
**Page:** 3

<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 16:05 UTC](https://discourse.nodered.org/t/ds18b20-wrong-value-if-temperature-is-below-0-degrees/40812/42 "2021-02-12T16:05:07Z")

</div>

No, the update with restart have not solve the problem.

---

<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 16:27 UTC](https://discourse.nodered.org/t/ds18b20-wrong-value-if-temperature-is-below-0-degrees/40812/43 "2021-02-12T16:27:43Z")

</div>

As a workaround until whatever is wrong with the pi s/w gets updated again, feed the value through a function node containing

```auto
if (msg.payload > 2048) msg.payload = msg.payload-4096
return msg;

```

That won't break if the s/w is fixed, because it should never be more than 2k anyway.

---

<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 16:49 UTC](https://discourse.nodered.org/t/ds18b20-wrong-value-if-temperature-is-below-0-degrees/40812/44 "2021-02-12T16:49:49Z")

</div>

Thank you!!! That's work.

---

<div class="post-metadata">

**Author:** ![tloehr](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/tloehr/32/37315_2.png) [@tloehr](https://discourse.nodered.org/u/tloehr)\
**Post date:** [16 February 2021 10:31 UTC](https://discourse.nodered.org/t/ds18b20-wrong-value-if-temperature-is-below-0-degrees/40812/45 "2021-02-16T10:31:06Z")

</div>

Hi,

it seems, that I have the same problem as You described here. I am running 6 Raspis for various cooling devices. Suddenly 4 of the freezers were showing values above 4000 degrees celsius. It seems, that the sensors are faulty. I replaced the raspi with another one to make sure the installation is not to blame.

Its has nothing to do with Node-RED. I just posted this here, so You know that there are others with these faulty readings.

Gonna replace the sensors.

Bye, Torsten...

---

<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:** [16 February 2021 10:35 UTC](https://discourse.nodered.org/t/ds18b20-wrong-value-if-temperature-is-below-0-degrees/40812/46 "2021-02-16T10:35:01Z")

</div>

Hi, with the function from Colin is all ok. The sensor is ok. Possible is with an udpate the problem start.

---

<div class="post-metadata">

**Author:** ![tloehr](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/tloehr/32/37315_2.png) [@tloehr](https://discourse.nodered.org/u/tloehr)\
**Post date:** [16 February 2021 11:21 UTC](https://discourse.nodered.org/t/ds18b20-wrong-value-if-temperature-is-below-0-degrees/40812/47 "2021-02-16T11:21:46Z")

</div>

Yes, but... my setup is running for over a year now. And suddenly SOME of the freezer sensors are showing these values above 4000. There are still sensors that show the correct values below 0.

I even installed a new raspi node with the most recent raspian on it to make sure it has nothing to do with it. So the same problem on old raspians versions and the most recent ones. So I am pretty sure its an HW issue with the sensors.

I will report the results for the new sensors, when I replaced them.

```auto
/sys/bus/w1/devices/28-01143bb438aa
4073.93
/sys/bus/w1/devices/28-02159245cb05
4075.81
/sys/bus/w1/devices/28-01143b87deaa
4076.31

```

---

<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:** [16 February 2021 11:23 UTC](https://discourse.nodered.org/t/ds18b20-wrong-value-if-temperature-is-below-0-degrees/40812/48 "2021-02-16T11:23:47Z")

</div>

I've try with 3 new sensors and all have the same issue. I think it's a software problem. But not node-red.

---

<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:** [16 February 2021 11:26 UTC](https://discourse.nodered.org/t/ds18b20-wrong-value-if-temperature-is-below-0-degrees/40812/49 "2021-02-16T11:26:37Z")

</div>

Are you saying you have some sensors that are failing and some that are not, on the same Pi? Are they all on the same bus?

---

<div class="post-metadata">

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

</div>

Hello Speedy and Colin. You are absolutely right.

I just checked a node which was still showing the correct value below zero. Then I did an update/dist-upgrade and after the reboot the negative values were beyond 4000.

It definitely is a software issue.

Further googling brought me here:  
[https://www.raspberrypi.org/forums/viewtopic.php?f=37&t=303036&p=1819347&hilit=ds18b20#p1819347](https://www.raspberrypi.org/forums/viewtopic.php?f=37&t=303036&p=1819347&hilit=ds18b20#p1819347)

> <https://github.com/raspberrypi/linux/commit/bcf55ad4a1d5fabe9161ef6040547a467adc1781>

The "full-upgrade" didn't help. Nor the most recent version of raspian. But for now, please accept my apology for the confusion.

Bye, Torsten...

---

<div class="post-metadata">

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

</div>

Following the GitHub threads, I came across this workaround

`The thermometers always overreport by 4096°C and by subtracting 4096 if the temperature is over 100°C correct readings can be obtained.`

You could try doing this in the flow

UPDATE:

> <https://github.com/raspberrypi/linux/issues/4124>
>
> Is this the right place for my bug report?
> This repository contains the Linux kernel used on the Raspberry Pi. If you...

Says a `rpi-update has a fix for this.

---

<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:** [16 February 2021 13:44 UTC](https://discourse.nodered.org/t/ds18b20-wrong-value-if-temperature-is-below-0-degrees/40812/52 "2021-02-16T13:44:11Z")

</div>

See reply #42 🙂

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [16 February 2021 13:46 UTC](https://discourse.nodered.org/t/ds18b20-wrong-value-if-temperature-is-below-0-degrees/40812/53 "2021-02-16T13:46:00Z")

</div>

It seems there is a fix if you run rip-update.

@Colin oops, missed #42 🤔

---

<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:** [16 February 2021 14:00 UTC](https://discourse.nodered.org/t/ds18b20-wrong-value-if-temperature-is-below-0-degrees/40812/54 "2021-02-16T14:00:12Z")

</div>

I think you have to be careful running rpi-update as (I believe) it installs the latest pre-release kernel etc. If I had a 'production' system with this problem I might be inclined to stick with the workaround for the moment and wait till it makes its way through the system to full release.

**[Edit]** Otherwise @zenofmud's typo above might become remarkably perceptive.

> [@zenofmud](#):
>
> there is a fix if you run rip-update

---

<div class="post-metadata">

**Author:** ![tloehr](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/tloehr/32/37315_2.png) [@tloehr](https://discourse.nodered.org/u/tloehr)\
**Post date:** [16 February 2021 14:18 UTC](https://discourse.nodered.org/t/ds18b20-wrong-value-if-temperature-is-below-0-degrees/40812/55 "2021-02-16T14:18:42Z")

</div>

Well, the `rpi-update` helps with the problem. But let's see what other "wonders" lie ahead of me, now that I updated the kernel.

But for the time being, thanks for all the infos. The freezer alerts are quiet now.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [2 March 2021 14:19 UTC](https://discourse.nodered.org/t/ds18b20-wrong-value-if-temperature-is-below-0-degrees/40812/56 "2021-03-02T14:19:35Z")

</div>

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

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