Interfacing multiple DS18B20 by socket/connector

Thread Starter

Kibirad

Joined Oct 18, 2021
24
Hi,
I'm trying to solve problem with interfacing multiple DS18B20 sensors. If I'm correct you can address each of them either by address or index. And to my understanding if I connect multiple sensors to one bus, then turn off power and turn in on again (maybe even switch/replace some sensors) I won't be able to distinct which index relates to which sensor. I need to be able to adress sensors by "socket/terminal block" in my application. So in a case of change of bad sensor I don't need to figure out new sensor adress and program it to the board. I've spend some time searching for some reasonable solution and come to two possible solutions.

Fisrt one is to use DS2482S-800+. But there are few reasons I'm not fan of this solution. It comes to the number of pins (8 is barely enough - room for expansion in future would be nice). Next one is the price of the chip. It seems like a lot of money for just a converter to another communication. The last one is availability as with almost everything these days...

Second one is to use ATMEGA328P-AU or something like it and use it as slave chip. Then connect single sensor sockets to the single pin of the chip and select the sensors just by selecting pin on chip. Availability is the same problem, but I could probably order arduino nano from china an desolder atmega from it.

The reason why I'm writing this question is to mainly find out if I'm not going in to some sort of dead end and if there is better or cheaper solution that I didn't think of...
 

Jon Chandler

Joined Jun 12, 2008
1,029
If you have a series of sensors, say a string of 10, and you want to know which is #1, #2, #3.... without knowing its ID, the DS28EA00 temperature sensor has a "chain" function. When you apply power, the first sensor only is active. Read its ID, then tell it to connect the rest of the chain. This connects sensor 2, and you can read its ID. Repeat for sensor 3, then 4, etc. to map the IDs of each sensor.
 

Thread Starter

Kibirad

Joined Oct 18, 2021
24
I think the 'search rom' command is your friend here. See AN937.
If I'm looking at it correctly the "search rom" command returns adresses of all connected sensors. But if I connect let's say 5 sensors at once and then turn on the power to MCU I'll get five addresses but I won't be able to identify in what terminal block is terminated what sensor (described by its unique adress). What I have in mind is PCB with number of 3 pin terminal blocks (data, vcc, gnd). I do not need to know address, index or whatever similar informations about sensor. In the proposed solution I know that the sensor connected to terminal block 1 measures X - no asigning related to exact sensor is needed. If the sensor is replaced I don't need to search for new sensor address. I'm not saying the proposed solution using search rom is bad. But to my understanding you still need to add sensors one by oneso you could assign them in code what are they measuring(X,Y..) or do the same thing by looking at live data and heating/cooling one of them and assigning them as well.
 

Thread Starter

Kibirad

Joined Oct 18, 2021
24
If you have a series of sensors, say a string of 10, and you want to know which is #1, #2, #3.... without knowing its ID, the DS28EA00 temperature sensor has a "chain" function. When you apply power, the first sensor only is active. Read its ID, then tell it to connect the rest of the chain. This connects sensor 2, and you can read its ID. Repeat for sensor 3, then 4, etc. to map the IDs of each sensor.
The first thought was along the lines of multiple sensors on one bus. But after a while as I wasn't able to figure out how I would distinct sensors from each other I dropped the idea and searched for some circuitry that would be able to distinct sensors by pin (terminal block) on which they are connected instead of address or index. I already have the DS18B20 sensors so I probably won't be changing to different one any time soon.
 

bassbindevil

Joined Jan 23, 2014
824
I'm pretty sure you can only ID the DS18B20 sensors by address. They're electrically all in parallel (usually). If that's too inconvenient, then addressing them individually through a multiplexer could be the answer.
And FYI, there's a risk that getting cheap Arduinos from China will not get you a genuine ATMEGA328P-AU. Also, almost no DS18B20 from China is genuine Dallas; there's several families of fakes ranging from quite good to "noisy garbage" and you can't trust that a vendor who sold you "pretty good" ones will be selling the same kind a few months later. Dallas has been known to send free samples of real DS18B20s, though, which are useful to have since the fakes can behave differently in-circuit.
 

upand_at_them

Joined May 15, 2010
940
If you have multiple sensors on the same bus the position you assign is arbitrary. How would they know which socket they're in? The only way to identify each sensor by socket number is to have a separate bus for each.
 

Thread Starter

Kibirad

Joined Oct 18, 2021
24
I'm pretty sure you can only ID the DS18B20 sensors by address. They're electrically all in parallel (usually). If that's too inconvenient, then addressing them individually through a multiplexer could be the answer.
And FYI, there's a risk that getting cheap Arduinos from China will not get you a genuine ATMEGA328P-AU. Also, almost no DS18B20 from China is genuine Dallas; there's several families of fakes ranging from quite good to "noisy garbage" and you can't trust that a vendor who sold you "pretty good" ones will be selling the same kind a few months later. Dallas has been known to send free samples of real DS18B20s, though, which are useful to have since the fakes can behave differently in-circuit.
The multiplexer idea is close to proposed solution using DS2482S-800. But as I stated before availability is big problem. I have no idea how would 1-Wire work with multiplexer. Even if it would work it doesn't look like something straight forward and lately I don't have as much time as I used to so I'm really looking for something simple, quick but reliable. About the genuine ATMEGA328P-AU.. Kindly I don't care what's "under the hood", if it works reliability I'm okay with that. The thing is.. I've looked to all reputable sellers websites and non of them have eather DS2482S-800 or ATMEGA328P in stock. So at least the china atmega is giving me a chance to do something.
 

Thread Starter

Kibirad

Joined Oct 18, 2021
24
If you have multiple sensors on the same bus the position you assign is arbitrary. How would they know which socket they're in? The only way to identify each sensor by socket number is to have a separate bus for each.
And thats why I proposed using DS2482S-800 with eight independent 1-Wire I/O channels or use single I/O pins for every DS18B20 sensor. I wasn't talking about using all the sensors on single bus. I was only asking if I didn't overlook something that would enable using them on one bus. But primarly I've posted this thread to ask for alternatives to the proposed solutions because parts that I was able to find aren't nowhere to be found in stock and also if my solutions are sound.
 

Thread Starter

Kibirad

Joined Oct 18, 2021
24
If you have a not unreasonable number of sensors I would use a single I/O pin for each. It saves a part.
Not so much. As I stated in opening question the atmega would work as slave chip but that is just detail. I've wrote this question to get more insight in problematics and apparently there is not much solutions except those that I suggested.
 
Top