17martin
Posts: 5
Joined: Wed Oct 16, 2019 1:25 pm

One wire DS18b20 sensors disconnected when reading too fast

Wed Oct 16, 2019 1:40 pm

Hello everybody, I've read almost all the posts about this topic on this forum and of course elsewhere on the net. I have an old RPi B+ and I'm trying to connect 4 DS18b20 temp sensors. These are wired on 3 to 5 m length ethernet cat 5 cable in star topology.
When I check

Code: Select all

/sys/bus/w1/devices
everything is fine, I see all 4 sensors detected and getting right temp. When I try to read temperature periodically after some time sensors start to give wrong CRC check and unreal temperature(-62C) and at some point I lose them (they dissapear from the folder). If I shorten the interval between readings, sensors tend to go into bad state and dissapear earlier. If I leave them connected without any readings, they stay connected for a long time.
I have 4k7 resistor and I don't use parasite power (I use 3.3V pin for power). From what I have read, one wire protocol is somehow sensitive in timing. Could this be an issue, when the RPi gets bigger load (more readings use more resources)? I don't thing this is an issue with wiring, since everything stays connected if there are no readings, is it? I would love to hear any suggestions, thanks

pcmanbob
Posts: 7060
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: One wire DS18b20 sensors disconnected when reading too fast

Wed Oct 16, 2019 6:06 pm

Well the first thing to do is not use a star topology, this is know to cause problems.

You should wire the sensors in a chain from one sensor to the next and so on.

You may also find that powering them with 3.3V means that at the actual sensor you are getting nearer 3V or even less, you could try powering them from the 5V but keep the pull up resistor connected to the 3.3V .

Image
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

JohnsUPS
Posts: 122
Joined: Fri Jul 06, 2018 2:13 am
Location: USA

Re: One wire DS18b20 sensors disconnected when reading too fast

Thu Oct 17, 2019 1:45 am

If your sensors are located in such a manner that running one cable and daisy chaining them together isn't practical, you can run each sensor back to a separate GPIO pin. However, each pin must have its own pullup resistor to 3.3v.
This will eliminate the star topology that was created when the data lines were connected together at the Pi.

The resultant schematic will be the same as what pcmanbob has provided, but it will be with just one sensor per line, and each sensor data line will go to a different GPIO pin and have its own pullup.

Also consider adding a small capacitor (10ufd or less) at each sensor between Vcc and gnd.

17martin
Posts: 5
Joined: Wed Oct 16, 2019 1:25 pm

Re: One wire DS18b20 sensors disconnected when reading too fast

Mon Oct 21, 2019 10:36 am

Thank you both for your valuable tips. I made some further debbuging. With one sensor at a time running for at least 30mins reading the temperature every 5 seconds. One of my four sensors dies after circa 10 minutes. I haven'm made another test run to confirm or another run with those remaining 3 together. But it looks like the one is wired (soldered) badly or it could be faulty from the begginning. Is one-wire protocol like this? I mean if one sensor is faulty, could this be a reason that all other fail as well? Thanks

pcmanbob
Posts: 7060
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: One wire DS18b20 sensors disconnected when reading too fast

Mon Oct 21, 2019 11:46 am

It sounds like you are using a water proof ds18b20 sensor, there are many low quality/factory seconds being sold on line on various line on sales sites, these often fail after some use or randomly , I have experienced this myself.

You could try testing your setup using just the ds18b20 chip obtained from a better source that would at least prove you setup is good, that's what I did , I then dismantled the water proof sensors and placed the proved good sensors in the water proof housing.

if you don't want to go down that road source some new water proof sensors form a better source.
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

JohnsUPS
Posts: 122
Joined: Fri Jul 06, 2018 2:13 am
Location: USA

Re: One wire DS18b20 sensors disconnected when reading too fast

Mon Oct 21, 2019 11:47 pm

pcmanbob wrote:
Mon Oct 21, 2019 11:46 am
It sounds like you are using a water proof ds18b20 sensor, there are many low quality/factory seconds being sold on line on various line on sales sites, these often fail after some use or randomly , I have experienced this myself.

You could try testing your setup using just the ds18b20 chip obtained from a better source that would at least prove you setup is good, that's what I did , I then dismantled the water proof sensors and placed the proved good sensors in the water proof housing.

if you don't want to go down that road source some new water proof sensors form a better source.
I second this.

I encountered bad sensors when I sourced them from overseas trying to save a buck. I suspect they were fakes, as they were out of calibration.
You will save some headaches by sourcing directly from a reputable company.

JohnsUPS
Posts: 122
Joined: Fri Jul 06, 2018 2:13 am
Location: USA

Re: One wire DS18b20 sensors disconnected when reading too fast

Mon Oct 21, 2019 11:59 pm

17martin wrote:
Mon Oct 21, 2019 10:36 am
Thank you both for your valuable tips. I made some further debbuging. With one sensor at a time running for at least 30mins reading the temperature every 5 seconds. One of my four sensors dies after circa 10 minutes. I haven'm made another test run to confirm or another run with those remaining 3 together. But it looks like the one is wired (soldered) badly or it could be faulty from the begginning. Is one-wire protocol like this? I mean if one sensor is faulty, could this be a reason that all other fail as well? Thanks
Maybe.
It boils down the failure mode of the bad sensor. If the bad sensor is pulling the data line low or corrupting it in some way, it could cause bad readings on all because they all share that same data line. You could consider putting a 150 ohm resistor in series with the data line at each sensor.
Also keep in mind that a star topology is not recommended for 1-wire. Although your setup is working, it may be running on the edge.
In your first post you mentioned that all is well if they are connected but no readings are taken, but fail once the sensors have to do some work. This sounds to me like the internals of one or more sensors is warming up and failing as a result. This also makes sense because you stated that the faster the readings are taken, the earlier they (it) fails.

17martin
Posts: 5
Joined: Wed Oct 16, 2019 1:25 pm

Re: One wire DS18b20 sensors disconnected when reading too fast

Tue Oct 22, 2019 7:38 am

Thank you guys, I replaced the one that I identified to be causing failures with other one I have at home. Cable lenghts are almost the same and after 50 mins of reading temp every 3 seconds from each of those sensors I haven't had a problem. So I guess it could be a faulty sensor/wiring and what is more important - ONE FAULTY SENSOR CAN APPARENTLY INFLUENCE THE OTHERS. I'll let the test run for at least a day and report back after.
There's one lesson learned - don't buy the cheapest DS sensors as these can misbehave (another interesting fact - the new one I attached is reporting temperature one degree lower than others - it was bought from different seller, not a big deal, but it shows the quality/construction difference ).
Anyway I hope this helps someone in the future. If you have more sensors attached and something goes wrong try to attach them one by one and read temps extensively. Thanks pcmanbob and JohnsUPS

Return to “Interfacing (DSI, CSI, I2C, etc.)”