Need help understanding erratic behaviour of DS18B20 sensors


I currently have 15x DS18B20 sensors hooked up to an ESP32 and displaying the data on an IOT board. The sensors are placed in a column of wet soil and I am using conductive pipes to heat/cool the soil inside this column.

In the first 2 weeks of using them, everything was working fine. In the third week, I decided to cover up all the mesh-like holes on the column using bubble wrap (to improve the insulation). This new setup was working great for a few days until one sensor started to behave erratically (ie. it would read the correct temperature and then suddenly jump to -5 degrees and then come back to the normal temperature). I continued using it for a few days and then 12 out of the 15 sensors started to act the same way (see picture below).

Normally, I would say that I f*cked up my sensor with moisture trapped inside the column. But two very strange things happened:

  • 12 of the sensors are behaving erratically, but in a NEAR EXACT 'erraticness'
  • I shut off my system for 3 days and just turned it back on, now only 4 out of the 15 sensors are being erratic. The rest are reading fine again...

x - time
y - temperature (deg. C)
Grey line - ambient temperature
Blue lines - (supposedly) the correct reading
Red, orange, yellow lines - erratic sensors

Does anyone have any theories on what could be going on?

Moisture and powered electronics DO NOT MIX. Corrosion will over time introduce current paths that are completely unpredictable, and will eventually destroy connections entirely.

Everything, including the connecting wires, exposed to a moist environment needs to be impermeably sealed.

It is typically 1 faulty probe that causes the others to malfunction (but this probe is not damaged, it is that with all 15 probes, one is weakened by the shared structure, and it causes the fault for the others; there is at least a mix of addresses ; for the measurement offset, I don't understand). They are therefore wired together, in a star configuration I suppose. The CRC check on the data sent by each probe (integrated in the OneWire library) does not detect the fault : did you check this CRC in your code?
How is the reading done: 15 conversion commands sent to the 15 probes, wait 700...1000 ms, then read the 15 temperature values, or the same thing but probe by probe?
Maybe decrease the value of the pullup resistor on the OneWire pin? I went down to 560 ohms (but on an arduino; I forgot the output power of the esp pins, but less than 1K ohms, it must be possible).
Are there any connections (solder, connector) on the farthest probe extensions?

or maybe it's the program (not the probes) : do you wait long enough for the conversion time? I wait at least 1000 ms. Otherwise you have to test the end of conversion, but it's tedious, and adding 300 ms to 700 ms is easier!

edit : I forgot that with esp32 you don't have to worry about the code, you just have to read the temperatures of the different probes in a file.

Those water proof ds18b20’s are not waterproof - the tip is but the rest not , despite what they tell you …if moisture gets anything can happen .

Verify all wires are of equal length.
ONEWIRE is sensitive to timing from each sensor on the network, each can effect what other readings are being sent.

read the data sheet on wireing

Does "conductive pipes" mean that an electric current is running through the wet soil?

the onewire-bus is sensitive to signal-reflections.
A onewire-bus should have a line-topolgy with small stubs (5 cm to 15 cm) to each sensor.

A star-topology creates too much signal-reflections that bend the rectangular signal to too much rounded edges which makes communication fail.

One thing that does help is to reduce the pullup-resistor of the dataline from 4,7 kiloohms to something around 2 kiloohms.

If you have an storage-oscilloscope look at the data-signal if the edges are rounded too much.

Does your code averaging the measured values?
failed communication results in a value -127.0 degrees? So -5 degree is really strange

best regards Stefan

What DS18B20 sensors do you have?
The individual TO-92 case device, or the metal enclosed "weather proof" device?

As @hammy has said they are not waterproof.

Tom... :smiley: :+1: :coffee: :australia:

1 Like

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