How do I wire three i2c inerface devices together? (With separate power sources)

I'm new to I2c, and I have a sort of weird setup. Not sure how to wire these together:

I have 1 master arduino mega with its own power source, 1 slave arduino uno with its own power source, and a barometric pressure sensor. I want the uno and the pressure sensor to communicate with the mega through I2c.

How do I wire this together? When I connect all of the SCL and SDA wires together, the pressure sensor stops working.

The Mega, the Uno, and the pressure sensor share a common ground. Is it a problem that they have separate power supplies?

Thanks in advance!

First thing to do is familiarize yourself with this info.

With multiple objects, a common ground is essential. However, the Vcc supplies should not be tied together. All of the SDA pins should be tied to one line and the SCL pins to another. Both lines need pullup resistors of about 4K7 or maybe lower. If the sensor is a 3v3 device then you will need a level shifter on the two signal wires. Since you have two Arduinos, only one can be the master while the other has to be a slave. It is likely that you have not set one as the slave and now have two devices trying to drive the SCL line.

It would be more helpful if we could see your code and a schematic.

John09121,

In this case you need to do something that might not seem intuitive: have the Uno be the I2C master.

You cannot have two masters on one circuit, as they will fight for control of the lines. By using the Uno as the master it can communicate with the baro sensor then to the Mega in sequence.

As Arctic_Eddie says, you must reference the power commons together, but not the Vcc lines. Power the sensor from the Uno, of course.