Pages: [1]   Go Down
Author Topic: How to determine a specific DS18B20 sensor in an OneWire sensor array  (Read 851 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 17
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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!
Logged

New Jersey
Offline Offline
Faraday Member
**
Karma: 72
Posts: 3764
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
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.
Logged

Norfolk UK
Offline Offline
Faraday Member
**
Karma: 71
Posts: 2615
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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?
Logged


Dee Why NSW
Offline Offline
Edison Member
*
Karma: 48
Posts: 2314
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

The thing to do is know the address.

http://www.hacktronics.com/Tutorials/arduino-1-wire-address-finder.html

Quote
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.
Logged

Idaho, US
Offline Offline
Edison Member
*
Karma: 22
Posts: 1080
Special User
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Peoples Republic of Cantabrigia
Offline Offline
God Member
*****
Karma: 6
Posts: 722
Arduino happiness
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
« Last Edit: August 13, 2013, 02:12:53 pm by Constantin » Logged

Pages: [1]   Go Up
Jump to: