multiple i2c's

It has occured to me that i am going to be using multiple ( about 3 ) i2c modules in my project and i would like some advice on setup for these.

a sample diagram would be great.

They are all 3.3v , grnd, scl,sda of course but im not sure the correct way to wire them all together.

Each needs its own address (that's what those "A" pins are for.)
Data and Clock are shared.

If you would let us know what modules you have, you will probably get a more complete answer. Many have unique addresses, or addresses that can be modified under program control, while others have pins that allow you to select from a subset of possible addresses.

The modules i am using are

MMA7455 Accelerometer
HMC5883L Compass
MPR121 Capacitive Touch Sensor

Thank you. Any advice would be great.

Those devices all have different default I2C addresses so you can connect them to the same bus (SDA and SCL) with no problem. You use only one pair of pullup resistors, typically 2K2 to 4K7. Pay attention to the address selection pins on each of the modules.

There are these comments complaining that some of the literature on the MPR121 that gives the wrong I2C device address: https://community.freescale.com/thread/62485

When in doubt, connect one device at a time to the I2C pins and run the I2C address scanner: Arduino Playground - I2cScanner Then, connect them all to the same bus and rerun the scanner. It should see all of the devices respond.

Thank you thats very informative. How should these resistors be attached?

Pull up means the resistor is connected to the pin and the other side to the positive power supply.

It will pull up the electronic level of that pin in case there is nothing controlling it to an other level.

Jaychad:
Thank you thats very informative. How should these resistors be attached?

Very carefully.

The standard "Wire" library turns on the Arduino's internal pullup resistors. This is wrong, it will apply 5V to your 3.3V devices.

Worse, if you add external 3.3V pullups then you have the 5V and 3.3V pullups on the same lines.

So the first thing you need to do is:

a) Modify the function "twi_init()" in file "twi.c" to fix this.
or, second best:
b) Do "digitalWrite(SDA,0)" and "digitalWrite(SCL,0)" right after you call Wire.begin()

After that, just join all the SCL and SDA pins of your devices to A4 and A5 on the Arduino then add a 4.7k resistor from 3.3V to each of the lines (one resistor per line).

OK thanks.

I have tried each one of my modules individually, without the resistor and they work great. From what you've said, do i need to add these because i'll be using more than one?

Also, i am using an arduino Mega

Jaychad:
I have tried each one of my modules individually, without the resistor and they work great.

How exactly do you know they work "great"?

A two minute test with visual inspection proves nothing. As noted, you're probably applying 5V to their input pins via the Arduino pullups. That's not much surrent so they probably won't die instantly from it, but how long will they last?

You need to:

a) Research to find out if the modules have "5V tolerant" inputs (find datasheets for the chips).
or
b) Turn off the internal 5V pullups of the Arduino and use external 3.3V pullups.

Thank you great points.

They were only running a couple of hours a peice. my accelerometer was running for 5 hours in total. including a couple of restarts.

This page is informative and discusses the various issues:

http://playground.arduino.cc/Main/I2CBi-directionalLevelShifter