About Sharing of I2C interface

Hi all,

I want to use my Arduino to connect two sensors at the same time. However, these 2 sensors all use I2C protocol for communication. As we all know that the default I2C interface on the Arduino board is Analog In 4 and Analog In 5. How could I connect two sensors using the same I2C protocol on a single Arduino board? Thanks!

You might find http://tronixstuff.wordpress.com/2010/10/20/tutorial-arduino-and-the-i2c-bus/ useful.

The I2C-bus is designed for one master and many slaves. You need pull-up resistors, and you can add many devices. Every I2C-device has it's own address.

Many thanks for the replies!

So I am gonna connect both these 2 sensors onto the same I2C bus (i.e., Analog In 4 and Analog In 5) physically. And write an Arduino sketch which calls their unique I2C address alternatively such that I can read data from both of the 2 sensors using a single Arduino. Please correct me if I am wrong. Many thanks!


That's right, as long as the two sensors have different addresses.

I don't know if the wire library activates the internal pullup resistors but you may have to add external pullup resistors as well.


Thanks Bob.

I am kinda new to this... Actually each sensor I am using is embedded in its own breakout board. Does this indicate I do NOT need the pull-up resistors?


Which Arduino board? It makes a difference. My Mega2560 has specific pins marked for I2C (SDA,SCL) (Pins 20,21) it makes it a lot easier.

Give people the information to help you and help will come.

Some breakout boards have no pull-ups others have 2k2, or 4k7 or 10k, some have a level shifter, some are for 3.3V others for 5V, and so on...... What breakout boards are you using? You can past the URL in your post.

I would not expect a breakout board to have resistor although it's possible, maybe with disabling jumpers.

The trouble is they don't know in advance how many boards (and other stuff) you will have on the wires and you can't keep adding resistors in parallel.


Thanks for all the replies!

Right now I am using a Arduino Duemilanove with ATmega 168. The two breakout boards I use are (1) BMP085 (https://www.sparkfun.com/products/9694) and (2) K30 CO2 sensor (http://www.co2meter.com/products/k-30-co2-sensor-module). If everything works, I would shift them to the new Arduino Ethernet board. Thanks.


That BMP085 board has 4k7 resistors, the CO2 module says it also has pullup resistors if you have the "I2C extension", do you have that?

Either way you don't need to add any more resistors and hopefully the combination of the two will be OK.


Thanks for the links.

The Sparkfun BMP085 breakout board has 4k7 pull-up resistors. The K30 seems to have 56k pull-up resistors, or they recommend 56k, but I'm not sure of that. So you are good, you don't have to add extra resistors.

The Sparkfun BMP085 board should have 3.3V. The K30 needs 3.3V for "DVCC" and 5V for the "Supply Voltage" (I don't understand that), but the logic levels should be maximum 3.3V. If you connect both sensors to the I2C-bus, the pull-up resistors of the BMP085 board will keep the I2C-lines between 0 and 3.3V (or a little more). So you have to connect both sensors to the I2C-bus at all times !

Some information about the I2C levels can be found here: http://arduino.cc/playground/Main/I2CBi-directionalLevelShifter

...while I was typing this, Graynomad had already answered it (and we came up with the same result).

People here are so nice! Thanks for all your replies. I will try it today and let you guys know if it works. Finger crossed. :P


My Arduino works perfectly! Thanks all for your sincere help!