I have an ESP32 with 11 DS18B20 connected in a tree structure. Cable length completly is about 20m. Longest stub is 3m.
I read the values and send them via mqtt to my broker. So far so good. I program the ESP32, disconnect it from my PC and connect it to a USB wall adapter. After a few seconds I receieve good values via mqtt. After a indefinable timespan all 11 sensors send "-127.0°C" at once and until I reboot. Apparently this means "bad connection". If I restart the the ESP32 it works fine again for a indefinable timespan.
I already tried with 4.7k R and with 2.2k R resistor.
My sketch is attached. I have no idea what the problem could be. All problems I read about the "127.0 °C" problem describe the value is allways send false.
That tells me you are intermittent in communicating with the temperature sensor. A bad connection yes but possibly a bad ground or the grounds are not all connected. With the number of sensors you are using and not knowing the physical layout I would guess you have more capacitance then the bus can work with. It was designed for short distances, not long lines. Here is a great explanation of what you need to know: https://www.maximintegrated.com/en/design/technical-documents/tutorials/1/148.html The DS2477 will allow you to add a large number of sensors and isolate them form each other. See this article: How to Multiplex a 1-Wire Master into Numerous Channels | Analog Devices This response is to help you get started in solving your problem, not solve it for you.
Good Luck & Have Fun!
Gil
pylon:
Post a wiring diagram! I guess you're using parasite mode. Do you have 3 wire cabling in place to use non-parasite mode?
No I am using normal mode. I made a quick photo and will create a schema in the next hours. But I think it will help you (respectively me :P)
@gilshultz:
The simplest solution is usually the best... I agree with that, but I don't think my lines are too long or I have bad wiring.
Which speaks against it, is that if I reboot the ESP32 without touching it, it will work again. The idea with buggy ground is good. I will check this when I am back home.
In the meantime I changed my code a bit. The solution was to relieve the bus. Now I query one sensor address, wait 1 second and then publish it via mqtt. Query the second sensor, wait 1 second, and so on... But it didn't changed anything.. After a few hours all sensors go to -127.0 °C :-X
Put your sensors into an array to make them easier to handle!
Read out the parasite mode. Are all sensors in non-parasite mode?
I never used the DS18B20 with 3.3V over longer distances. On 5V they work very reliable. As you power them from the onboard voltage regulator: Check the voltage once they fail. What do you get?
You might also try a decoupling capacitor at each sensor.
Please explain exactly how they are wired - exactly what cable and which signals go on which wires?, what topology - and where is each terminatlon resistor?, parasite power or not?, what voltage...