How to determine a specific DS18B20 sensor in an OneWire sensor array

Hi all,

I'm building a home automation system that will consist of several DS18B20 temperature sensors. Since they can use the OneWire protocol I would only use 1 digital input port to communicate with all the temp sensors.
Without knowing their device address is it possible to determine that, let say, the second sensor is the outside temperature sensor?
If not, what if if I need to replace one of the sensors later, should I change the software according to the new device address and reflash it again?

Thanks in advance!

Without knowing their device address is it possible to determine that, let say, the second sensor is the outside temperature sensor?

Kind of. You can determine which is which by experiment - the initial exploration of the bus is deterministic, so the 1st one found will always be the same physical device. If you have to replace one though, that will no longer be true and you'll need to figure it all out again and then reflash. So you might as well hard code the device addresses from the start.

Can you plug them in one at a time and read the internal serial number then write it on something attached to the sensor. Build your project then note the serial numbers and where the device is. You might then be able to hard code this in your sketch using a lookup table?

papaiatis:
Without knowing their device address is it possible to determine that, l

The thing to do is know the address.

If not, what if if I need to replace one of the sensors later, should I change the software according to the new device address and reflash it again?

You might as well. It isn't likely to be often, is probably not hard to do, and removes any chance of confusion.

I believe the DS18B20 devices have two "user bytes" of EEPROM. So, you could write a magic value to the EEPROM of each one to act as an identifier something like

1 = master bedroom
2 = hallway
3 = guest bedroom
4 = living room
5 = outside

etc. Then, as long as you only replace ONE sensor at a time, you can detect a DS18B20 with a missing magic value, figure out which old DS18B20 disappeared off the bus, and write that value to the the EEPROM of the new sensor.

Or set up a jig with a 3-pin header + drop resistor to plug the DS18B20 into, ID the serial number, print a sticker or mark it otherwise. Log the number in an array and then use a lookup function to ID the location.

The arduino with the Jig would simply poll the channel over and over and spit out any found addresses once a second via the serial channel.