# Problem with DS18b20 error code = -127

**URL:** <https://forum.arduino.cc/t/problem-with-ds18b20-error-code-127/656654>\
**Category:** Sensors\
**Created:** [May 23, 2020, 8:29pm UTC](https://forum.arduino.cc/t/problem-with-ds18b20-error-code-127/656654 "2020-05-23T20:29:27Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![sohaibpannu](https://avatars.discourse-cdn.com/v4/letter/s/7c8e57/32.png) [@sohaibpannu](https://forum.arduino.cc/u/sohaibpannu)\
**Post date:** [May 23, 2020, 8:29pm UTC](https://forum.arduino.cc/t/problem-with-ds18b20-error-code-127/656654/1 "2020-05-23T20:29:27Z")

</div>

I'm interfacing 2 ds18b20 sensors with arduino mega 2560. I'm reading from both sensors after 4 seconds and displaying their values on lcd. After some time my sensors started giving -127 temperature in celsius. In the dallas library -127 error code that represents sensor is disconnected.

I replaced my ds18b20's both of them and now after 3 days one of my sensor gives me -127. I plugged in my old sensors (both of them) back and they worked fine for a few minutes until they both gave -127.

I'm using both sensors on one wire and have powered them up from arduino 5V pin and GND pin (not parasitically). I also have a pullup resisitor of 4.7kOhms. My arduino is powered from my laptop. I wrote another arduino sketch that displays values from 2 ds18b20's on serial monitor but I am facing the same problem. Below is my code and my schematic diagram, only difference is that my sensor is in a waterproof probe, which of course is dipped in a bucket of water.

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

#define ONE_WIRE_BUS 6
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);

void setup()
{
sensors.begin()
Serial.begin(9600);
}

void loop()
{
sensors.requestTemperatures();
Serial.println(sensors.getTempCByIndex(0));
Serial.println(sensors.getTempCByIndex(1));
delay(4000);
}

```

Somebody please help me! ☹ ...

![sch.jpg](https://europe1.discourse-cdn.com/arduino/original/4X/1/3/d/13df15752a1080a7fe8af1f649619ca2ef3271ef.jpeg)

---

<div class="post-metadata">

**Author:** ![JCA34F](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/jca34f/32/340148_2.png) [@JCA34F](https://forum.arduino.cc/u/JCA34F)\
**Post date:** [May 23, 2020, 8:40pm UTC](https://forum.arduino.cc/t/problem-with-ds18b20-error-code-127/656654/2 "2020-05-23T20:40:19Z")

</div>

See if this way changes anything:

```cpp
void loop()
{
sensors.requestTemperatures();
delay(4000);
Serial.println(sensors.getTempCByIndex(0));
Serial.println(sensors.getTempCByIndex(1));
}

```

---

<div class="post-metadata">

**Author:** ![sohaibpannu](https://avatars.discourse-cdn.com/v4/letter/s/7c8e57/32.png) [@sohaibpannu](https://forum.arduino.cc/u/sohaibpannu)\
**Post date:** [May 24, 2020, 3:28am UTC](https://forum.arduino.cc/t/problem-with-ds18b20-error-code-127/656654/3 "2020-05-24T03:28:06Z")

</div>

That doesn't solve it.

---

<div class="post-metadata">

**Author:** ![Nick\_Pyner](https://avatars.discourse-cdn.com/v4/letter/n/e8c25b/32.png) [@Nick\_Pyner](https://forum.arduino.cc/u/Nick_Pyner)\
**Post date:** [May 24, 2020, 4:42am UTC](https://forum.arduino.cc/t/problem-with-ds18b20-error-code-127/656654/4 "2020-05-24T04:42:27Z")

</div>

> sohaibpannu:  
> After some time my sensors started giving -127 temperature in celsius.

I submit this suggests wiring that looks kosher, but isn't.

It may not be the cause of your problem, but "waterproof" is a relative term, and it would now be a good idea to slide the sleeve back and check things.

---

<div class="post-metadata">

**Author:** ![sohaibpannu](https://avatars.discourse-cdn.com/v4/letter/s/7c8e57/32.png) [@sohaibpannu](https://forum.arduino.cc/u/sohaibpannu)\
**Post date:** [May 24, 2020, 7:56am UTC](https://forum.arduino.cc/t/problem-with-ds18b20-error-code-127/656654/5 "2020-05-24T07:56:53Z")

</div>

I ripped across the sleeve to see and I only found little moisture at the beginning of sleeve. I was unable to bring sensor out of the stainless steel housing. One I thing I noticed that I'm using white color connectors with both of my sensors. 1 sensors connector got a bit orange like it was rust. So I suspect that sensors are not totally waterproof.  
One thing I would like to ask is that I'm powering 2 sensors, 3 eeprom chips, 1 rtc, 1 max232 ic and 1 arduino uno through my mega. I hope this much load is not a problem for mega or sensors because they seem to work for some time perfectly.

---

<div class="post-metadata">

**Author:** ![srnet](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/srnet/32/238868_2.png) [@srnet](https://forum.arduino.cc/u/srnet)\
**Post date:** [May 24, 2020, 8:35am UTC](https://forum.arduino.cc/t/problem-with-ds18b20-error-code-127/656654/6 "2020-05-24T08:35:39Z")

</div>

So what happens if you use the same setup to test probes that have never been in the water, do they fail after a couple of days too ?

---

<div class="post-metadata">

**Author:** ![sohaibpannu](https://avatars.discourse-cdn.com/v4/letter/s/7c8e57/32.png) [@sohaibpannu](https://forum.arduino.cc/u/sohaibpannu)\
**Post date:** [May 24, 2020, 9:14am UTC](https://forum.arduino.cc/t/problem-with-ds18b20-error-code-127/656654/7 "2020-05-24T09:14:41Z")

</div>

I am going to test new sensors today (transistor only) then will update you guys

---

<div class="post-metadata">

**Author:** ![sohaibpannu](https://avatars.discourse-cdn.com/v4/letter/s/7c8e57/32.png) [@sohaibpannu](https://forum.arduino.cc/u/sohaibpannu)\
**Post date:** [May 24, 2020, 12:27pm UTC](https://forum.arduino.cc/t/problem-with-ds18b20-error-code-127/656654/8 "2020-05-24T12:27:13Z")

</div>

Its been about an hour since my sensors are working correctly and i hope that they wont bug out after 2 or 3 days. If they do I will be back here again. Thanks guys for the help:)

---

<div class="post-metadata">

**Author:** ![Nick\_Pyner](https://avatars.discourse-cdn.com/v4/letter/n/e8c25b/32.png) [@Nick\_Pyner](https://forum.arduino.cc/u/Nick_Pyner)\
**Post date:** [May 24, 2020, 3:54pm UTC](https://forum.arduino.cc/t/problem-with-ds18b20-error-code-127/656654/9 "2020-05-24T15:54:04Z")

</div>

> sohaibpannu:  
> So I suspect that sensors are not totally waterproof.

They clearly aren't. Some silicon grease should suffice for normal abuse. Don't expect to pull the guts out of the can, it wouldn't tell you anything you don't already know anyway. I would not have thought your peripheral loads were a problem. The DS18B20s certainly aren't.

---

<div class="post-metadata">

**Author:** ![sohaibpannu](https://avatars.discourse-cdn.com/v4/letter/s/7c8e57/32.png) [@sohaibpannu](https://forum.arduino.cc/u/sohaibpannu)\
**Post date:** [May 25, 2020, 10:06am UTC](https://forum.arduino.cc/t/problem-with-ds18b20-error-code-127/656654/10 "2020-05-25T10:06:50Z")

</div>

Thanks for support nick, the sensors are working perfectly as they are out of water. I will make a waterproof housing myself now.

---

<div class="post-metadata">

**Author:** ![Nick\_Pyner](https://avatars.discourse-cdn.com/v4/letter/n/e8c25b/32.png) [@Nick\_Pyner](https://forum.arduino.cc/u/Nick_Pyner)\
**Post date:** [May 25, 2020, 1:02pm UTC](https://forum.arduino.cc/t/problem-with-ds18b20-error-code-127/656654/11 "2020-05-25T13:02:58Z")

</div>

I think the simplest approach is to copy a thermowell. I couldn't find a store-bought example, so I made one up with a drilled brass plug in a T fitting.

---

<div class="post-metadata">

**Author:** ![hammy](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/hammy/32/238813_2.png) [@hammy](https://forum.arduino.cc/u/hammy)\
**Post date:** [May 25, 2020, 6:36pm UTC](https://forum.arduino.cc/t/problem-with-ds18b20-error-code-127/656654/12 "2020-05-25T18:36:43Z")

</div>

These waterproof sensors are only waterproof at the metal tip . If you submerge them , they fail !

You need to look at using or making a thermowell to keep the sensor dry .

---

<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:** [May 6, 2021, 10:29am UTC](https://forum.arduino.cc/t/problem-with-ds18b20-error-code-127/656654/13 "2021-05-06T10:29:28Z")

</div>

Closed on May 6, 2021, 10:29am UTC


