one wire search multiple sensors at same bus

hello all I'm start working with one wire sensores dalas ds18b20 and I want connect 4 sensors in parasite mode (2 wires only).In onewire library there is a function[x]) which will discover the address of the sensor on the bus.My question is can I just have one sensor at the moment of the search or can I have all sensors connected on the bus and the[x]) will deal with it and fill the array with each address[] of the sensors?

From what I had read from the data sheet when the master perform the search doesn't all the sensor will reply on the same time causing data collision on the bus?

"Each 1-Wire device contains a unique 64-bit 'rom' code, consisting of an 8-bit family code, a 48-bit serial number, and an 8-bit CRC. The CRC is used to verify the integrity of the data."

Each call to fills addr with one device address and returns 'true' or returns 'false'/0 if there are no more devices. You can reset the search and start over from the beginning by calling ds.reset_search().

I understand that but what will be the first sensor id stored on the array? In my mind I'm thinking like this: Master perform the and there are 4 sensors on the bus.Since every sensor will received the master question I presume all then will answer at the same time( big mess on the bus), since I have no way to just speak to one separatly? Is this wrong? How can the master store the ID then?

Try the DS18x20_Temperature.pde example in the OneWire library examples.


well I already found the answer just now.Nothing like just read the datasheet could save hours of search. Aparantly there are to commands to do the search.Looking on the library code I found the search is done by writing 0xf0 wich will do like a brute force search for every one.Also there is another command if we just have just one sensor on the bus, here we just need to seend 0x33 and the sensor will reply the id

SEARCH ROM [F0h] When a system is initially powered up, the master must identify the ROM codes of all slave devices on the bus, which allows the master to determine the number of slaves and their device types. The master learns the ROM codes through a process of elimination that requires the master to perform a Search ROM cycle (i.e., Search ROM command followed by data exchange) as many times as necessary to identify all of the slave devices. If there is only one slave on the bus, the simpler Read ROM command (see below) can be used in place of the Search ROM process. For a detailed explanation of the Search ROM procedure, refer to the iButton® Book of Standards at After every Search ROM cycle, the bus master must return to Step 1 (Initialization) in the transaction sequence. READ ROM [33h] This command can only be used when there is one slave on the bus. It allows the bus master to read the slave’s 64-bit ROM code without using the Search ROM procedure. If this command is used when there is more than one slave present on the bus, a data collision will occur when all the slaves attempt to respond at the same time.

Thanks for all