Multiple DS18B20's on the same bus

I was wondering how people manage multiple DS18B20 sensors on the same bus?

I see a few problems with this:

- If you are just scanning the bus and reading the available temperatures, how do you ensure they are always read in the same order?

- If they are in different locations, how do you ensure that they are mapped correctly, so you know which is the kitchen, which is the lounge etc?

- What happens if a sensor fails, a cable problem etc? - eg: if there are now only 2 sensors instead of 3, what stops the 3rd one now getting written to the feed for the 2nd as one has disappeared.

The only way I can think of dealing with this is to use a sketch to print out the addresses on the bus and add each sensor one at a time, noting the address. Then hardcoding those addresses in an array and manually getting the temperature from each based on the address.

Is there a better way?

Is anyone doing something like this? (and if so, any code examples anywhere?)

Thanks,

Ian

 

Ian Eagland's picture

Re: Multiple DS18B20's on the same bus

Hi

 

This is covered in the emonTx_temperature_examples

 

// By using direct addressing its possible to make sure that as you add temperature sensors
// the temperature sensor to variable mapping will not change.
// To find the addresses of your temperature sensors use the: **temperature_search sketch**
DeviceAddress address_T1 = { 0x28, 0xB2, 0x8F, 0xE0, 0x03, 0x00, 0x00, 0x7E };
DeviceAddress address_T2 = { 0x28, 0x85, 0x7A, 0xEE, 0x02, 0x00, 0x00, 0xDC };
DeviceAddress address_T3 = { 0x28, 0x95, 0x51, 0xEE, 0x02, 0x00, 0x00, 0x0F };
DeviceAddress address_T4 = { 0x28, 0x95, 0x51, 0xEE, 0x02, 0x00, 0x00, 0x0F };

Regards

Ian

ichilton's picture

Re: Multiple DS18B20's on the same bus

Hi,

Thanks!

I was using: this sketch which doesn't have that, but I see that:

https://github.com/openenergymonitor/emonTxFirmware/blob/master/Guide/d_...

does have that direct addressing.

Thanks,

Ian

 

Petrik's picture

Re: Multiple DS18B20's on the same bus

 

When reading the address from the chips some tools seem to report the address with bytes in reverse order. The arduino based tool is easiest, just copy and paste the addresss.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.