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.
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.
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.
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:)
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.
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.