I found very strange incompatibility of DS18B20 sensors. Any idea?

Hi, I have 5 sensors on a OneWire bus, and I decided to replace one of them with a new one because one of the sensors sometimes reported -127C (error). Well, I bought a couple of new sensors, and I decided to replace one my old sensor with a new one, and it didn't work, all sensors started reporting -127C error. :confused:

I tried to find out what is wrong, and I found some kind of incompatibility between my old sensors and the new ones.

Here is what I found out:
If I only connect new sensors they work fine, and if I only connect old sensor they also work fine, but if I connect them together (or replays an old with a new one) I only can see the address of old sensor, but even old sensors start reporting -127C error.

What difference I found between old sensor and new ones:

Here is adreses of old sensors:
**Number of devices: 5 **
**2888f8cf02000021 **
287c832909000013
28e2e0cf0200006f
2896cf2d05000088
28b75b280900009b

And here is the new ones:
Number of devices: 2
2861641195cf3da1
2861641197f1a311

As you can see new addresses don't have 0000 in it, I don't know what those 0000 means, but sensors are incompatible.

Any idea what is going on?
What addresses your sensors have?

By the way, I use esp8266, and libraries: OneWire.h and DallasTemperature.h

How do you power all this? 5V?

I have ten DS18B20 and they all work, and none of them has the zeros.
Since you already had problems with your bus, that seems to be the basic problem.
Perhaps the zeros in the ID numbers trigger problems on your flaky bus.

I suggest to make your bus better.
What kind of cable is used ? How long is it ?
Use the normal mode with three wires, not the parasite mode.

The -127°C is probably not a bad sensor. They hardly turn bad. It seems to be a problem with your bus.
Replacing a good sensor with another good sensor will not help.

robtillaart:
How do you power all this? 5V?

I use 3.3V to 5V level shifter using a MOSFET

Koepel:
I suggest to make your bus better.
What kind of cable is used ? How long is it ?
Use the normal mode with three wires, not the parasite mode.

The -127°C is probably not a bad sensor. They hardly turn bad. It seems to be a problem with your bus.
Replacing a good sensor with another good sensor will not help.

I don't use parasite mode.
I use twisted pair, no shield, about 20 meters long. I know that it is long, But:
3 of my sensors did not have a single error in 24 Hours.
1 sensor had 10 errors in 24 Hours
and 1 sensor had 100 errors (I tried to replace it).

But the problem that if I connect the new sensor even close to ESP8266 the bus stops working, and if I connect old sensor at the very same point on the bus everything works.

Update: I just cuted the bus to 1 meter and an old sensor started to work with a new sensor, but I still don't know what is going on... will try to investigate.

Noise on the bus sounds like a very plausible explanation for this. This can disturb the signal being sent back, and it can disturb the sensors themselves causing them to malfunction.

Start with good decoupling of the power supply: place a 10-100 nF ceramic capacitor as close as possible to every individual sensor between 5V and GND.

If that's not enough, you may have to replace your cable with a shielded one.

Are there any electric motors or other potential electrical noise sources around? If so, keep your cable as far away as possible from those appliances.

wvmarle:
Start with good decoupling of the power supply: place a 10-100 nF ceramic capacitor as close as possible to every individual sensor between 5V and GND.

Yes, it is a good idea. I have capacitors on some of the sensors, and today I added one more and also made the bus a little shorter, I also experimented with pull up resistors, and now I have fewer errors. But I still can't connect my new sensors to the bus...

I agree that my bus is not very good, but it still doesn't explain completely that strange behaviour that I saw...
I mean after replacing one old sensor with a newer all sensor stopped working completely, and when I connected the old sensor back, it works again.
How are the new sensors different?
On the shorter bus, I tested one new and one old, and they work fine, so it is not the address problem as I previously thought.
Maybe different sensors have different tolerance to interference? but they are digital, I don't get it.
To find the problem it would be good to connect all my sensors one be one to the bus and see when this problem appear, but it is not easy to do.

Actually errors not that bad, usually, I have just around 50 - 100 errors per 20000 readings or so, but I want it to be perfect.

Anyways thanks for help.

Well, it does explain the behaviour.
When you are on the edge of a working / non-working situation, then anything can disturb it. There could be a small difference with the new sensors, or maybe they are the same. Maybe the zeros in the ID keeps the bus a little lower which is just enough to make it work. When using a long cable, the signal can create knots and can bounce back. That means that if something changes at the end of the cable, it can create a problem at the begin of the cable.

The goal is to solve it, so that all the DS18B20 will work.

I think that the long cable and the level shifter can cause troubles.
Can you tell me why you use a level shifter ? In my opinion it will make the signal weaker.
Since the DS18B20 works with 3.0V, the 3.3V should be enough. A 5V signal via a level shifter does not make the signal "stronger".

When you write about a cable, please tell us which cable, and which signals are paired.
When you write about a level shifter, please give a link to the module that you use.

My suggestion:
Use three wires. Use 3.3V. Don't use the level shifter.
If you use Cat5 cable, pair the GND and the signal. Put 3.3V on any other wire.
To compensate for the long cable, use a pullup resistor of 2k2 instead of the standard 4k7. Connect the pullup resistor to 3.3V of course.
In the sketch, ignore the errors. You can count the errors, to know the quality of the bus. If 5% fails, that's fine with me. Perhaps the cable picks up electrical noise.

Well, after adding the 1000uF capacitor to one of my sensor I don't have errors with my old sensors anymore (at least for now)

Statistics:
Uptime: 0 Days, 19 Hours, 3 Min, 19 Sec.
Reading times Total: 39355 (5 sensors)
Errors Total: 0
Reading every 8 Seconds.
So no errors anymore.

Koepel:
Can you tell me why you use a level shifter ?

I have a couple of displaces that get power from the bus, and they need 5V, that is why I decided to use 5V, and also I thought it makes the signal "stronger". Displays could explain errors in the first place. Displays have good capacitors and consume just about 40mA, but maybe those capacitors are not enough, and when I added one capacitor to the sensor there are no more errors.
I use DIY level shifter, using a MOSFET, I've googled the circuit (all those circuit almost the same).

But the problem still exists:
Today I disconnected all my displays from the bus, ONLY sensors are connected, and when I connected new sensor, I only see addresses of the old sensor, and all sensors report -127C

Even if the bus or level shifter is not very good, that is still strange to me... 0 errors in 19hours and one more sensor ruin everything...
Maybe your explanation is still true here:

When you are on the edge of a working / non-working situation, then anything can disturb it.

For now, I leave it as is, because it is too cold outside to experiment with my bus, and I don't have errors for now (with my old sensors of course).
I think it would be interesting to connect sensors one by one to the bus and see when the problems appear.

Anyways thanks for your help, now I have much more information to think about.

Wait a moment... you don't only have temperature sensors on the bus? Why didn't you mention this before? That changes the picture quite drastically! Not only does this mean a lot more power draw than suggested, it also means you must have more communication going along those lines (displays don't normally work on one wire).

A 1000 µF cap on your power lines is for decoupling, not for filtering. Those things don't filter much noise, you use small ceramic caps for filtering. Very different purpose and effect.

deimos666, perhaps you can draw a picture and a schematic of the level shifter. I think that a few things are not okay and I wonder what else there is.

What about the pullup resistor for the 1-Wire bus ?

Can you power the displays with a seperate 5V wire ?
If the displays use the same GND signal in the cable, then the returning ground current from the displays can disturb the 1-Wire bus. So you need a seperate GND as well.

You have now already three things that make a bad bus: the long cable, the level shifter and the displays with shared 5V and GND wires. That could be already a problem if the cable was only 5 meters.

A level shifter with mosfets can adapt the voltage levels of a open-collector / open-source bus. But the signal gets weaker.

wvmarle:
Wait a moment... you don't only have temperature sensors on the bus? Why didn't you mention this before? That changes the picture quite drastically! Not only does this mean a lot more power draw than suggested, it also means you must have more communication going along those lines (displays don't normally work on one wire).

A 1000 µF cap on your power lines is for decoupling, not for filtering. Those things don't filter much noise, you use small ceramic caps for filtering. Very different purpose and effect.

On one of the sensor, I have two of 100nF capacitors.
I am not sure that it matters much because I have 4.95V on the last point of the bus, and sensors can work even with 3.3V. Interference from displays still can matter here I agree, but today I disconnected all my displays from the bus, and only the sensors are connected, and I still have a problem with new sensors.

Koepel:
deimos666, perhaps you can draw a picture and a schematic of the level shifter. I think that a few things are not okay and I wonder what else there is.

What about the pullup resistor for the 1-Wire bus ?

I was using this circuit

I have a couple of pull-ups that together make about 5k, making it 3k didn't help much, I think it made it even worse.

I will try connecting bus with 3.3V without a shifter, and disconnect all displays, and will write here if it works.

Koepel:
Use three wires. Use 3.3V. Don't use the level shifter.

You are right, without the shifter I can see addresses of all my sensor. Case closed.

But one of my old sensors started reporting 127.94 without that shifter.
But I think it is the problem with that sensor because I remember before instaling that sensor, it was showing 0.5C higher temperature than other sensors, and it consumed 1mA or 2mA more, so I installed it for measuring heating system temperature where 0.5C doesn't matter. (maybe that faulty sensor can only work with 5V).
Maybe that sensor for some reason ruined communication for the new sensor. I will try to disconnect it and see.
(this sensor didn't have any errors before when it was working with the level shifter)

Thanks for the help.

deimos666:
But one of my old sensors started reporting 127.94 without that shifter.
But I think it is the problem with that sensor.
I will try to disconnect it and see.

No, disconnecting this sensor doesn't help, I just tested. With the level shifter, my new sensors don't work. Without level shifter old sensor doesn't work. :smiley:

Koepel:
You have now already three things that make a bad bus: the long cable, the level shifter

Maybe that is it. Maybe I am on the edge of a working / non-working situation, as it was previously said.
And maybe that is causing that strange behaviour.
But I don't like that I don't understand it completely.
Now, I leave it as is, and will not add or replace any sensors, and if I will have errors, I will add more capacitors 100nF ceramic and 1000uF electrolytic.

Koepel, wvmarle Thanks for the help.

The small ceramics in your power lines should be placed one at a sensor, as physically close to the sensor as possible. That's where they have most effect.

deimos666:
I don't use parasite mode.
I use twisted pair, no shield, about 20 meters long.

If you are using three wires, you can't have just a twisted pair.

Hello all, I have task, to run 5 DS18b20 waterproof sensors providing the link ( https://de.rs-online.com/web/p/entwicklungstools-sensorik/2049893). so I have to run this sensor in Parasite mode, So my problem is , Those sensors are working fine with the Non Parasitic mode, on 3.3v and on 5v with pull-up resistor.
But when I am connecting VCC to ground (Parasite mode), I am always getting -127 dc according to datasheet sensors are disconnected, so I have spend lot of time on it, but I didn't find out what went wrong.

  1. I have solder each cable so that I can connect those to my breadboard(so maybe because of less metal solder).
  2. while testing I have made the wrong connection, so because of this sensors damaged
    3.Is it possible this DS18B20 sometimes doesn't work on parasitic since all are working fine in Non-parasitic
    4.I have tested this with 1k,3.3k,4.7k, and even with 10k, from internet solution. 5..So I did a lot of research, And now I am leaving hopes from it, I need guidance over it, I don't know what went wrong now, Is it possible I will contact through your mail or something so that I can share my hardware connections.
    I am attaching my results here, please kindly check
    , Thanks a lot for Your help

so In the pictures:

  1. I have used 2 buses connected with the parasite using a 4.7k pull-up resistor all sensors working well !
    result- sensors with non-parasite mode working fien|690x317
  2. Connected 2 sensors in parasitic and 2 in non-parasitic, here only 2 sensors are working wich is parasitic.

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