3

I have a string of 10x DS18b20 sensors on a single two wire line (parasitic power). Below is a table of the sensors, Where they are located on the wire, and in what order where they discovered.

Serial              Order on wire*   Order discovered
286305560100002c    1                7
28a158610100006a    2                3
28ad48610100006b    3                6
2851ae60010000ad    4                4
289b426101000089    5                8
28cd1161010000ce    6                5
2864026101000030    7                1
280c766101000026    8                2

I read this document on how the OneWire discovers sensors on the bus. https://www.maximintegrated.com/en/app-notes/index.mvp/id/187

My question: Is there a way to detect the order of the sensors on a wire?

3 Answers3

1

There is no way to detect position on the bus because all devices are connected in parallel. This is why a serial or "chain" wire, added to the newer devices, is required.

(To complicate matters, what is the "order of devices" - or even the meaning of "order" in a center-fed bus, or a circular, star, or other branched network? Order is just something we perceive when looking at an end-fed linear network. Electrons don't care. Think of a capacitor (unfortunately, the bus behaves like one but that's another story) with two plates, several centimeters square, and a dozen 1-wire devices connected from plate to plate. Now what is their order? Ow, my brain hurts! Let's go back to linear buses.)

The discovery order is a function of the set of binary device IDs on the bus. There are two ways I know of to come to know the physical ordering, both empirical (i.e., by observation):

  1. Connect the set of devices one at a time, to a temporary bus such as a breadboard. With an Arduino, read the their IDs and tag them (human readable). With knowledge of the discovery alogrithm, or by running actual discovery on an Arduino with all devices connected, write down the IDs in the order they are discovered which is invariant for a given set of device IDs. Assemble your wired bus with the devices in this order.

  2. (The reverse of 1 and quicker to build, and is what you've already shown in your question: Wire the bus. With a simple Arduino program, repeatedly sample all devices on the bus and report print their indices and temperatures (the indices will be in discovery order). One at a time, warm each device with your hand and notice which device index is affected. Write down the physical position (first, second, ...) and the index. This is the mapping table between position and index. Include it in your control algorithm.

JRobert
  • 15,407
  • 3
  • 24
  • 51
1

what you can apparently do is use the User Data space set aside for the alarm and add an ID in there. I have not done this yet but am looking at this option as my sensor array has over 40 sensors in a line and ideally I would like the top one to be 0 and the last one in the chain to be 40.

0

I found this application note.

APPLICATION NOTE 4037
Regain Location Information by Leveraging the 1-Wire® Chain Function—A Simple Signaling and Protocol Method Determines Device Physical Location

https://www.maximintegrated.com/en/app-notes/index.mvp/id/4037