Multiple I2C devices on the same board

Can some one please show me (hopefully with a code snippet) how to have more than one I2C device (assume they're different sensors) on the same board at the same time.

How can I configure the Analogue Address to one I chose instead of being constrained to A4 and A5?

Read up on I2C. All I2C devices share the same SDA & SCL. You get the sensor's output by addressing their internal address.

Make sure there's at least one set of pullup resistors on the I2C bus lines.

Mistergreen,

Thank you for the heads up on this - very interesting.

MarkT:
Make sure there's at least one set of pullup resistors on the I2C bus lines.

MarkT,

Thank you - a couple of questions if I may;

  1. How do I calculate the value of the resistors required?
  2. I assume when they say "pull up resistors" they just mean ordinary resistors or are they a special type of resistor?, (i.e. different from ordinary resistors).

Pull up is a regular resistor connected from data bus to V+. So when there's no data, it's always 5V, hence the name PULL UP. 10K ohm is a good general resistor to use for 5V devices.

I thought there's a pull up built in the arduino I2C pins. So you shouldn't need to add one.

From what I have seen 4.7K (total) is the recommended pullup for I2C. The internal pullups are, I think, enabled by the Wire library. The internal pullups (20K to 60K by the datasheet) may be too weak to properly pull the bus up, so external resistors will probably be required. Some modules come with the pullups installed on SDA and SCL (check schematic or datasheet). You have to check because if too many modules have pullups, the total pullup resistance can be to low (too strong of pullup for the devices to pull the bus low).