3+ MS5803 Sensors on I2C Bus

Hi,

I am building a prototype datalogger and I want to use more than 2 MS5803 Pressure Sensors on the same I2C bus, but as far as I can tell, the MS5803 only allows the user to select 2 different I2C addresses (0x76 and 0x77). This is done by changing the solder connection on the board.
Is there a way to assign another I2C address in order to use 3 or more sensors on the same I2C bus? If not, what is my best option moving forward to communicate with an array of sensors in which some sensors will have the same I2C address?

Here is the breakout board from SparkFun that I am using:
https://learn.sparkfun.com/tutorials/ms5803-14ba-pressure-sensor-hookup-guide
It is the 14BA (14 bar) but I plan on using the 2 bar version in the future. I bought the 14BA to avoid the surface mount soldering for now.

Thanks in advance,
Blake

You are looking for an "I2C multiplexer."

If you use the ESP8266 processor you could simply set up a second (or third, or fourth) I2C bus.

Alternatively, use the SPI bus to read these sensors.

The AD/CS pin can be used as address and as chip select pin.

Connect the CS pin of each board to a digital output.
Set all outputs to the same logic level, except for the one you want to read.

The Sparkfun page does not mention if default of that CS pin is HIGH or LOW.
You might have to measure it.
Leo..

I forgot to mention that I hope to use only 4 wires to connect all sensors back to my Arduino Mega.
Hmm.

Also,
the Mega will need to be placed about 40 feet (or more) away from the furthest sensor. This should be acceptable for the I2C bus, right? Should I use pullup resistors to SDA and SCL at each sensor? Are there any issues that I should anticipate?

BlakeCarmichael:
I forgot to mention that I hope to use only 4 wires to connect all sensors back to my Arduino Mega.
Hmm.

Why? You have the pins available.
With two I2C buses you would still need at least six wires: two for the power, and four for the I2C buses.

the Mega will need to be placed about 40 feet (or more) away from the furthest sensor. This should be acceptable for the I2C bus, right? Should I use pullup resistors to SDA and SCL at each sensor? Are there any issues that I should anticipate?

I2C limit is 1-2 meters, you can try to push it (using twisted pair cables and stronger pull-ups - see the I2C technical documentation for suggestions) but 40 ft / 12 meters is a lot.

SPI should be able to handle this distance better, provided the speed is lowered to no more than about 200 kHz, even though also this protocol is not meant for long distances.

wvmarle:
Why? You have the pins available.
With two I2C buses you would still need at least six wires: two for the power, and four for the I2C buses.

The outer diameter size of the cable connecting this array of sensors needs to be as small as possible, and preferably about 3 mm or less. I was planning on using only one I2C bus, so I assumed 4 wires.

wvmarle:
I2C limit is 1-2 meters, you can try to push it (using twisted pair cables and stronger pull-ups - see the I2C technical documentation for suggestions) but 40 ft / 12 meters is a lot.

SPI should be able to handle this distance better, provided the speed is lowered to no more than about 200 kHz, even though also this protocol is not meant for long distances.

I've briefly read about people achieving lengths of 25+ meters using I2C, but have not done it myself yet. For example, this post: Maximum I2C Bus Length? - Electrical Engineering Stack Exchange

I suppose I should reconsider using SPI, although that will require 6 wires. I may be able to use just insulated wires and ditch the cable shielding for now so that my combined diameter of the wires does not become too large. Are there any methods I should be aware of for extending the range of SPI, or should 10-15 meters be achievable as is?

Assuming that cable length was not an issue, what if I used that I2C multiplexer at each sensor, and each I2C multiplexer was connected together with only the VIN, GND, SDA, and SCL pins. Each sensor would be connected to its own multiplexer, on different I2C input pins.

For example,
sensor 0 connects to SDA0 and SCL0 of multiplexer 0,
multiplexer 0 connects from SDA and SCL to SDA and SCL of multiplexer 1,
multiplexer 1 is connected to sensor 1 at SDA1 and SCL1,
and so on...

This would work the same way as with all of the inputs on only one multiplexer, right? The advantage being that the array of sensors would only have 4 wires between each of them.
Am I missing anything here?

Yes: how are you planning to actually read the third sensor? I can see dealing with the first multiplexer, (you address that from the Arduino) but after that it's getting more complex, fast.

wvmarle:
Yes: how are you planning to actually read the third sensor? I can see dealing with the first multiplexer, (you address that from the Arduino) but after that it’s getting more complex, fast.

The multiplexer address can be changed anywhere from 0x70 to 0x77.
Is there a device out there that can simply convert the I2C address of an I2C sensor? Pretty much what this multiplexer is doing without actually multiplexing, so just 1-to-1 I2C “multiplexer” (instead of 1-to-8)

For example, the DSS circuits multiplexer talks to the arduino over one of eight possible addresses, and then connects with up to four sensors with the same address. Why would you want one sensor per multiplexer?

Are you trying to daisy chain the multiplexers? Do you want one of the output channels of a multiplexer to go to the input of another? I'm not sure you can do that.

cattledog:
For example, the DSS circuits multiplexer talks to the arduino over one of eight possible addresses, and then connects with up to four sensors with the same address. Why would you want one sensor per multiplexer?

Are you trying to daisy chain the multiplexers? Do you want one of the output channels of a multiplexer to go to the input of another? I'm not sure you can do that.

Quote from the Adafruit site: "Using it is fairly straight-forward: the multiplexer itself is on I2C address 0x70 (but can be adjusted from 0x70 to 0x77) and you simply write a single byte with the desired multiplexed output number to that port, and bam - any future I2C packets will get sent to that port. In theory, you could have 8 of these multiplexers on each of 0x70-0x77 addresses in order to control 64 of the same-I2C-addressed-part."

I was thinking it would work if each of the multiplexers were common to the SDA and SCL pins. Thus I would be addressing all multiplexers at once, but there would only be one sensor at each I2C port.

I think you could also have the output channel of a multiplexer go to the input of another. Unless i'm reading that quote wrong.

Side note:
I just hooked up about 30 feet of cat5e 24AWG 4P CMR cable between one MS5803-14BA sensor and an Arduino Nano and I am getting valid readings. Would you expect it to fail when I add more sensors?
I need to get some more, I only have one right now.

wvmarle:
I2C limit is 1-2 meters, you can try to push it (using twisted pair cables and stronger pull-ups - see the I2C technical documentation for suggestions) but 40 ft / 12 meters is a lot.

Well, cable length is not that important, cable capacitance is.
If you use low capacitance cable, e.g. Cat-6 (53pF/m), then you can go ~6-7meters if the devices use standard I2C. But there is also FastMode+ I2C (4000pf).
These chips seem to be FM+ (the 400kHz speed is a giveaway).
With the right pull up resistors in the right places you might be able to do 12meters at the standard 100kHz bus speed.
Leo..

Wawa:
Well, cable length is not that important, cable capacitance is.
If you use low capacitance cable, e.g. Cat-6 (53pF/m), then you can go ~6-7meters if the devices use standard I2C. But there is also FastMode+ I2C (4000pf).
These chips seem to be FM+ (the 400kHz speed is a giveaway).
With the right pull up resistors in the right places you might be able to do 12meters at the standard 100kHz bus speed.
Leo..

I'm using cat5e and getting communication at about 9 meters, without pullup resistors.

I was thinking it would work if each of the multiplexers were common to the SDA and SCL pins. Thus I would be addressing all multiplexers at once, but there would only be one sensor at each I2C port.

I guess I'm not understanding what you are trying to do. Can you please explain why you do not want multiple devices(with the same i2c address) connected to each multiplexer?

You do not appear to be using the capability of the multiplexer to talk to more than one device with the same address.

With Cat-5 or Cat-6 cable, you don't need a muxer.

pair#1: clock/ground
pair#2: data/VCC
pair#3 and 4: the four chip select lines.
Leo..

cattledog:
You do not appear to be using the capability of the multiplexer to talk to more than one device with the same address.

That is correct. What I am trying to do is create an array of 3+ sensors of the same address down one cable that contains only 4 wires maximum. If the diameter of the cable, or the number of wires, were not limited due to the situation then I would use an additional 2 wires for each sensor and run them back to the multiplexer at the Arduino end. But, since I can only use 4 wires, I am considering using a multiplexer at each sensor just as a means of “converting” the I2C address of each sensor. As I stated in a previous post above, I’m not really using the “multiplexer” functionality. I’m using it more as a I2C Address Converter for each sensor at the location of the sensor and not at the location of the Arduino.

Arduino<----4WireCable----->Multiplexer/Sensor<----4WireCable----->Multiplexer/Sensor<----4WireCable----->Multiplexer/Sensor<----4WireCable----->Multiplexer/Sensor

Wawa:
With Cat-5 or Cat-6 cable, you don't need a muxer.

pair#1: clock/ground
pair#2: data/VCC
pair#3 and 4: the four chip select lines.
Leo..

Good point. That would limit me to 8 sensors, right? 2 different addresses, and then each with a chip select line.

The OD of this cable is larger than I'd prefer though... about 4.5 mm. That's the tradeoff I suppose. I wonder what the OD would be if it were 26 AWG, and if it would still work.

BlakeCarmichael:
Good point. That would limit me to 8 sensors, right? 2 different addresses, and then each with a chip select line.

The OD of this cable is larger than I'd prefer though... about 4.5 mm. That's the tradeoff I suppose. I wonder what the OD would be if it were 26 AWG, and if it would still work.

There is only one I2C pair on an Arduino to connect all sensors to, so each sensor needs it's own CS line.
All sensors are parked on the wrong I2C address, except for one (the one you read from), so you can have as many sensors as you like. Limited by the number of Mega pins and wires.

Look at the twisted pair capacitance in the datasheet of the cable.
Cat-5 and Cat-6 are not that different.
Leo..

Leo (@wawa) I understand from the MS5803 data sheet how the CSB line can control the last bit of the i2c address.

What I'm not sure about is the implementation on the SparkFun breakout board. I can't seem to find a schematic of the chip on the breakout.

PS does not appear to be used, so the selection between i2c and SPI is wired, and it looks like there are solder pads to change it. There are i2c address solder pads as well, and the default selection seems be for 0x76 and CSB tied HIGH.

Are you certain that the module can be addressed like the device with external selection of CSB.?

I'm sure some traces can be cut or modified to make it work, but a breakout schematic would be useful.