I am trying to building a flight controller with Arduino
for that, I need a magnetometer and barometric altimeter
The problem is communication to both sensors are via I2C, is this possible with the ArduinoMega, which only has pin 20 and 21 assigned for I2C
i got this from another tutorial forum: "I2C is a bus, with multiple slave devices on a single pair of wires. You can chain a number of devices off the same pair of wires, up until you exceed the 400 pF total capacitance of the combined inputs on your devices as well as the total length of cables."
Does this mean I should make Arduino the master and the two sensors slaves?
Yes, I think it will work. I2C is a bus and each slave as an address and it should ignore messages sent to other addresses.
As you say, the arduino would be the master and the two sensors the slaves.
so how will the master distinguish between which slave device it wishes to read from?
I saw a fn from the Arduino Wire library calle Wire.begin(address)
i'm guessing address should contain the address of my magnetometer and altimeter?
if so how do I find this address
If you check out the Arduino Wire library wiki page a bit more you'll see that if you run Wire.begin(address) and provide an address then you (the arduino board running the code) will join the bus as a slave. If you want to join the bus as a master, don't provide the address. To send data to a particular slave you do something like this: