Connecting multiple I2C devices

I am working with the BMP085 pressure sensor from BOSCH . The sensor uses the I2C interface to communicate to the micro controller. I would like to create an array of sensors (possibly 20) to gather dynamic pressure information across a wing. From what I have read I know that it is possible to run multiple devices on the same I2C lines. However, I am having trouble figuring out how to configure the individual adresses for each device, or if this is even possible. Is there a better way to connect multiple devices to the micro controller? Any help would be appreciated, thanks.

The BMP085 looks to be a single address device. http://www.bosch-sensortec.com/content/language1/downloads/BST-BMP085-DS000-05.pdf

You need a part/board like this http://www.dsscircuits.com/i2c-multiplexer.html Each PCA9544A can select between 4 parts, and the PCA9544As further can be assigned 1 of 8 addresses, allowing up to 32 BMP085s to be arrayed together.

Don't forget pullup resistors on the SCL/SDA lines. Data sheet says you also use XCLR to set one part silent while you talk to the other. So each PCA9544A can then talk to 8 parts, and you would only need three (for up to 24 BMP085s). Need 3 IO lines to select which PCA9544A, 2 IO lines to select which of 4, and 1 IO more for XCLR. And the SCL/SDA lines.

Are you going to have each one on a circuit card so you can spread them out and have a way to attach power, gnd, SCL, SDA, XLCR lines, decoupling cap, and pullup resistors?

You can also use an analogue multiplexer like this:- http://www.flickr.com/photos/33177304@N03/3230647685/in/photostream

There is no need to actually switch the clock line, these can be common if you want.

Thank you all for the response. This is becoming a little more complicated than I hoped, but this isn't exactly a blinking led. Yes, I would like to have them linked back to a central board that would make it easy to connect multiple lines together.

My goal is to design a array that I could pull data from each of the sensors simultaneously. Is this possible with I2C or is it the case that you would have to collect data from only on device at a time? If this is not possible with I2C any suggestions on another interface that might work?

I2C is a serial interface that only talks to one device at a time. All you have is a Serial-Clock and a Serial-Data line.

I suppose you could command all of them to capture data at the same time (they can all listen at the same time), but unless you have multiple processors reading the multiple sensors, you can olny read them one at a time.

How quickly do you want to read them?

A must read about I2C - http://www.gammon.com.au/forum/?id=10896 -

I suppose you could command all of them to capture data at the same time (they can all listen at the same time), but unless you have multiple processors reading the multiple sensors, you can olny read them one at a time.

This should work. Since you're using the BMP085 (the BMP180 is also out now) you are going to need to convert the logic levels for I2C from 3.3 v to 5 volt so you could use logic level converters on each of the sensors that have built in output enable pins. When sending the command to initiate a pressure read you would just enable all the level converters. Then enable one by one and read the data back.

Thanks for the mention of the BMP180. So if I'm getting this straight, each pressure sensor would have to be connected to its own micro controller in order to process the data from each sensor simultaneously, is this correct? Is there any other way to listen to each sensor simultaneously, possibly using another type of interface? I know that there are other sensors on the market that use the SPI interface. The ideal read speed that I would like to collect would be around 20Hz.

Is there any other way to listen to each sensor simultaneously, possibly using another type of interface?

No.

Very few things in the world of computers happens simultaneously.

The ideal read speed that I would like to collect would be around 20Hz.

That is very very slow. Why are you worried about simultaneously?

20 Hz, so 20 samples in that time means you be sampling devices at a 400 Hz rate, so a sample every 2.5mS, or 2500uS.

I2C transfers at “Up to 400kHz Data Transfer Speed” per the data sheet
bytes are 9 bits long and appear to have a break, so lets call them 10 for easy math.
So 400 KHz = 40 Kbytes/second.
You send out a 3-byte command, then after 4.5mS you can start a 6 byte sequence, the final 2 bytes being the pressure result.
1/4.5mS = 222 Samples/second
and (40 Kbytes/second)/(6 byte/device * 20 devices) = 333 samples ‘group’ samples per second if I did the math right,
so it seems like the data transfer time is fast enough to read them all back.
I suppose if you filled up an array with the 42 bytes (say 2 bytes for a sample number), and dumped it to external EEPROM (with 3.3mS writes) while waiting for the 4.5mS it could work out okay for you.

Grumpy_Mike: You can also use an analogue multiplexer like this:- http://www.flickr.com/photos/33177304@N03/3230647685/in/photostream

There is no need to actually switch the clock line, these can be common if you want.

Why use an analog multiplexer when you can use a multiplexer designed specifically for I2C? They are magical, similar to these products http://focus.ti.com/paramsearch/docs/parametricsearch.tsp?family=analog&familyId=1650&uiTemplateId=NODE_STRY_PGE_T

Why use an analog multiplexer when you can use a multiplexer designed specifically for I2C?

That is designed for using I2C that have the same address on one I2C bus.

http://uk.farnell.com/texas-instruments/pca9548apwr/ic-sm-logic-i2c-switch/dp/1607855 £3.40 and a surface mount package.

as opposed to : http://uk.farnell.com/on-semiconductor/mc14051bcpg/ic-4000-cmos-4051-dip16-15v/dp/9665684 £0.39 and DIL package.

It's a no brainer really!

Grump_Mike, I don't think you understand what I mean by simultaneously. What I mean is to collect information for each pressure sensor at the same time, not simultaneous in its strictest sense.

CrossRoads, are you saying this could be done using the multiplexer setup? I need to be able to listen to each of the 20 sensors at the same time.

What I mean is to collect information for each pressure sensor at the same time, not simultaneous in its strictest sense.

That was what I was suggesting you needed to do. Yes you can do it with a multiplexer.

at the same time == simultaneous

With one processor you can never read all sensors at "the same time", but maybe close enough for your application.

You need to describe just how much skew between readings you are happy with.


Rob

If the readings are all made at the same time (all sensors react to the same "get pressure" command, then read back sequentially and given the same time-stamp when stored, is that not simultaneous?

Can you write to X devices at the same time with I2C? If so then yes that would do the trick.


Rob

I might just have to test this out tonight. The jig I have setup to test the multiplexor board has 4 HMC5883L ICs that can be configured to perform single measurements which would closely resemble what he's trying to do. It's going to need a separate logic level converter with an output enable to make it work though.

“Can you write to X devices at the same time with I2C? If so then yes that would do the trick.”

I would say yes - the trick then is to not multiplex going out, and to multiplex coming back so only 1 responds at a time.
Use 20 trisate drivers for the data line going out, and 3 8:1 muxes coming back - all can be commanded to send their data, all may reply but only 1 makes thru the muxes.

Let me draw it up quick…

Here we go. Not these specific parts, but this functionality.

CrossRoads, thank you for the schematic this should get me going in the right direction. I will have to get a multiplexer and try this on the breadboard. I'll keep you all updated on the progress.