Pages: [1]   Go Down
Author Topic: About Sharing of I2C interface  (Read 1178 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 14
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Gosport, UK
Offline Offline
Faraday Member
**
Karma: 19
Posts: 3114
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Offline Offline
Edison Member
*
Karma: 9
Posts: 1010
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Offline Offline
Newbie
*
Karma: 0
Posts: 14
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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!

Michael
Logged

nr Bundaberg, Australia
Online Online
Tesla Member
***
Karma: 121
Posts: 8447
Scattered showers my arse -- Noah, 2348BC.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.

______
Rob
Logged

Rob Gray aka the GRAYnomad www.robgray.com

Offline Offline
Newbie
*
Karma: 0
Posts: 14
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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?

Michael
Logged

Georgina Ontario
Offline Offline
Sr. Member
****
Karma: 5
Posts: 437
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Just another Hacker

Offline Offline
Edison Member
*
Karma: 9
Posts: 1010
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

nr Bundaberg, Australia
Online Online
Tesla Member
***
Karma: 121
Posts: 8447
Scattered showers my arse -- Noah, 2348BC.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.

______
Rob
Logged

Rob Gray aka the GRAYnomad www.robgray.com

Offline Offline
Newbie
*
Karma: 0
Posts: 14
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.

Michael
Logged

nr Bundaberg, Australia
Online Online
Tesla Member
***
Karma: 121
Posts: 8447
Scattered showers my arse -- Noah, 2348BC.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.

______
Rob
Logged

Rob Gray aka the GRAYnomad www.robgray.com

Offline Offline
Edison Member
*
Karma: 9
Posts: 1010
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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).
« Last Edit: July 29, 2012, 02:09:51 am by Krodal » Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 14
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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. smiley-razz

Michael
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 14
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Michael
Logged

Pages: [1]   Go Up
Jump to: