user27157: [UPDATE] Now it works fine but the as soon as I add the GY-521 module (hardware not software), it starts sending me crapy info
Project uses:
Arduino Pro Mini as brain
FTDI as a programmer
GY-521 gyro/accel
MPL3115A2 baro/altimeter
DS3231 real time clock
Micro SD card adapter to datalog
The GY-521, MPL3115A2 and the DS3231 uses I2C and they are breakout boards so they include pull-up resistors on the board. Now the GY-521 and the MPL3115A2 works fine together but as soon as I add the DS3231, it all freezzes. My code is fine and I'm sure of that.
Now my theory is that all of those pull-up resistors caused some kind of problem in the circuit. I know that normal I2C require 4.7k ohm pull-up resistors. Now I BELIEVE that the GY-521 uses 4.7k pull-up resistors, the MPL3115A2 uses 10k pull-up resistors and the DS3231 also uses 10k pull-up resistors.
I don't know if this setup could work and I would like to know if I can add some external resistors to calm the whole I2C constellation a bit. Note that I do not want to sodder anything to the breakouts nor do I want to modify them.
Here is the code:
Tab1: MAIN
  //==================================================

#include <SPI.h>                        //include the SPI library
#include <SD.h>                         //include the SD card library
#include <Wire.h>                       //include I2C library
#include "I2Cdev.h"                     //include another I2C library
#include "Wire.h"                       //include another I2C library (yes, again)
#include "MPU6050_6Axis_MotionApps20.h" //include the MPU6050 library
#include "SparkFunMPL3115A2.h"          //include the MPL3115A2 library
#include <DS3231.h>                     //include the DS3231 library

//==================================================

#define testtest           //*** COMMENT THIS LINE BEFORE UPLOADING OFFICIAL CODE TO FINAL PROJECT ***

#define chipSelect 10      //pin for the CS/SS
#define led 2              //led and/or buzzer

volatile bool mpuInterrupt = false; //just one of those bools

bool ledState     = false; //state of the led and/or buzzer
bool dmpReady     = false; //state of the mpu6050

int yprInt[3];             //gyro data in a integer because the extra precision of the float is total bullshit
int altitude;              //altitude above takeoff point in meters
int altitudeCalibration;   //calibration for the altimeter
int temperature;           //temperature in degrees Celcius

float counter = 0;         //time counter, a somewhat internal clock that starts when the module starts dataloging

uint8_t mpuIntStatus;      //holds actual interrupt status byte from MPU
uint8_t devStatus;         //return status after each device operation (0 = success, !0 = error)
uint8_t fifoBuffer[64];    //FIFO storage buffer

uint16_t packetSize;       //expected DMP packet size (default is 42 bytes)
uint16_t fifoCount;        //count of all bytes currently in FIFO

String day;                //day of the week
String ymd;                //date: year,month,day
String hms;                //time: hour,minute,second

MPU6050 mpu;               //MPU6050 object declaration as mpu
Quaternion q;              //quaternion container
VectorFloat gravity;       //gravity vector

MPL3115A2 myPressure;      //MPL3115A2 object declaration as myPressure
DS3231  rtc(SDA, SCL);     //DS3231 object declaration as rtc

//==================================================

void setup()
{
  generalSetup();

  gyroSetup();
  baroSetup();

  dataSetup();
}

//==================================================

void loop()
{
  gyro();      //read angles
  baro();      //read altitude and temperature
  timeClock(); //read day, date, time

  dataPrint();   //serial print the information

  dataLog();   //write data in sd card

  timer();     //time delay and led flash
}

Tab2: SETUP
//==================================================

void generalSetup()
{
  Serial.begin(115200); //start serial communication
  Wire.begin();         //start I2C communication
  rtc.begin();          //start DS3231

  pinMode(led, OUTPUT); //led or buzzer; used to easily find a lost device
}

//==================================================

void dmpDataReady() {
  mpuInterrupt = true;
}

void gyroSetup()
{
#if I2CDEV_IMPLEMENTATION == I2CDEV_ARDUINO_WIRE
  TWBR = 24;
#elif I2CDEV_IMPLEMENTATION == I2CDEV_BUILTIN_FASTWIRE
  Fastwire::setup(400, true);
#endif
  //while (!Serial);
  mpu.initialize();
  devStatus = mpu.dmpInitialize();
  mpu.setXGyroOffset(220);
  mpu.setYGyroOffset(76);
  mpu.setZGyroOffset(-85);
  mpu.setZAccelOffset(1788);

  if (devStatus == 0)
  {
    mpu.setDMPEnabled(true);
    attachInterrupt(0, dmpDataReady, RISING);
    mpuIntStatus = mpu.getIntStatus();
    dmpReady = true;
    packetSize = mpu.dmpGetFIFOPacketSize();
  }

  else
  {
    return;
  }
}

//==================================================

void baroSetup()
{
  myPressure.begin();             //start MPL3115A2 communication 
  myPressure.setModeAltimeter();
  myPressure.setOversampleRate(7);
  myPressure.enableEventFlags();
  altitudeCalibration = myPressure.readAltitude(); //read altitude
}

//==================================================

void dataSetup()
{
  if (SD.begin());
}

//==================================================

Tab3: FUNCTIONS
//==================================================

void gyro()
{
  float yprFlo[3]; //gyro data in a float

  mpu.resetFIFO();
  mpuInterrupt = false;
  mpuIntStatus = mpu.getIntStatus();
  fifoCount = mpu.getFIFOCount();

  if (mpuIntStatus & 0x02)
  {
    while (fifoCount < packetSize) fifoCount = mpu.getFIFOCount();
    mpu.getFIFOBytes(fifoBuffer, packetSize);
    fifoCount -= packetSize;
    mpu.dmpGetQuaternion(&q, fifoBuffer);
    mpu.dmpGetGravity(&gravity, &q);
    mpu.dmpGetYawPitchRoll(yprFlo, &q, &gravity);

    for (int i = 0; i < 3; i++)
    {
      yprFlo[i] = yprFlo[i] * 180 / M_PI; //simplify the variable for serial printing and dataloging
    }

    for (int i = 0; i < 3; i++)
    {
      yprInt[i] = yprFlo[i]; //changing the variable from a float to a int
    }
  }
}

//==================================================

void baro()
{
  altitude = myPressure.readAltitude() - altitudeCalibration; //read altitude
  temperature = myPressure.readTemp();  //read temperature
}

//==================================================

void dataPrint() //serial print all the data
{
  Serial.print(day);
  Serial.print(" ");
  Serial.print(ymd);
  Serial.print(" -- ");
  Serial.print(hms);
  Serial.print(", ");
  Serial.print(counter);
  Serial.print(", ");
  Serial.print(yprInt[0]);
  Serial.print(", ");
  Serial.print(yprInt[1]);
  Serial.print(", ");
  Serial.print(yprInt[2]);
  Serial.print(", ");
  Serial.print(altitude);
  Serial.print(" ,");
  Serial.print(temperature);
  Serial.println();
}

//==================================================

void dataLog()//wirte all the data in a note file on the sd card
{
  if (altitude > 1) //if the device is higher then 1m, then we sstart recording everything
  {
    File dataFile = SD.open("datalog.txt", FILE_WRITE);

    if (dataFile)
    {
      dataFile.print(day);
      dataFile.print(" ");
      dataFile.print(ymd);
      dataFile.print(" -- ");
      dataFile.print(hms);
      dataFile.print(", ");
      dataFile.print(counter);
      dataFile.print(", ");
      dataFile.print(yprInt[0]);
      dataFile.print(", ");
      dataFile.print(yprInt[1]);
      dataFile.print(", ");
      dataFile.print(yprInt[2]);
      dataFile.print(", ");
      dataFile.print(altitude);
      dataFile.print(" ,");
      dataFile.print(temperature);
      dataFile.println();
      dataFile.close();
    }
  }
}

//==================================================

void timeClock()
{
  day = rtc.getDOWStr();
  ymd = rtc.getDateStr();
  hms = rtc.getTimeStr();
}

//==================================================

void timer()
{
  counter = counter + 0.5;

  #ifndef testtest
  ledState = !ledState;
  digitalWrite(led, ledState);
  #endif

  delay(500);
}

//==================================================


user612: In fact the MPU-6050 on the GY521 and the DS3231 both use I2C address 0x68.  Had you looked at the source of the header files you included for each, this would have been apparent.
By consulting the data sheet for each chip you will likely find a way to either change the I2C address by changing a configuration pin, or else to potentially enable/disable the chip by changing one with a GPIO.  This will, however, likely require surgical modification of the carrier board.
You could also move whichever device you expect to access least to a distinct "soft" I2C bus bit-banged on other GPIO pins. No endorsment is implied, but the the first such library that came up in a web search was:
http://playground.arduino.cc/Main/SoftwareI2CLibrary
you can likely find other options for yourself, or can potentially create your own.
There are also other chips in the family of the MPU-6050 which speak SPI instead of or as well as I2C, however these tend to be more expensive.

user10794: According to my calculations the total pull-up is:
1 / (1/10 + 1/10 + 1/4.7) = 2.423 k

As I show on my page about I2C a 2.2 k pull-up resistor gives a reasonably good signal:

Thus I don't think the resistors are the issue. And I don't see how adding more would "calm the whole I2C constellation a bit".

user78196: When additional resistors are added in parallel, which is what is going on when you add new I2C devices to the I2C bus, the overall resistor is lowered. This could cause a problem with devices that cannot provide enough current with a low pull-up resistance. Hence, the device will not function well when the pull-up resistance is lower than a specific value. To fix the problem, I recommend removing all parallel pull-up resistors and just keep one at each line to achieve a good resistor value of approximately 4.7 k-ohms.

27157: <p>[UPDATE] Now it works fine but the as soon as I add the GY-521 module (hardware not software), it starts sending me crapy info</p>

<p>Project uses:</p>

<p>Arduino Pro Mini as brain</p>

<p>FTDI as a programmer</p>

<p>GY-521 gyro/accel</p>

<p>MPL3115A2 baro/altimeter</p>

<p>DS3231 real time clock</p>

<p>Micro SD card adapter to datalog</p>

<p>The GY-521, MPL3115A2 and the DS3231 uses I2C and they are breakout boards so they include pull-up resistors on the board. Now the GY-521 and the MPL3115A2 works fine together but as soon as I add the DS3231, it all freezzes. My code is fine and I'm sure of that.</p>

<p>Now my theory is that all of those pull-up resistors caused some kind of problem in the circuit. I know that normal I2C require 4.7k ohm pull-up resistors. Now I BELIEVE that the GY-521 uses 4.7k pull-up resistors, the MPL3115A2 uses 10k pull-up resistors and the DS3231 also uses 10k pull-up resistors.</p>

<p>I don't know if this setup could work and I would like to know if I can add some external resistors to calm the whole I2C constellation a bit. Note that I do not want to sodder anything to the breakouts nor do I want to modify them.</p>

<p>Here is the code:</p>

<p>Tab1: MAIN</p>

<pre><code>  //==================================================

#include &lt;SPI.h&gt;                        //include the SPI library
#include &lt;SD.h&gt;                         //include the SD card library
#include &lt;Wire.h&gt;                       //include I2C library
#include "I2Cdev.h"                     //include another I2C library
#include "Wire.h"                       //include another I2C library (yes, again)
#include "MPU6050_6Axis_MotionApps20.h" //include the MPU6050 library
#include "SparkFunMPL3115A2.h"          //include the MPL3115A2 library
#include &lt;DS3231.h&gt;                     //include the DS3231 library

//==================================================

#define testtest           //*** COMMENT THIS LINE BEFORE UPLOADING OFFICIAL CODE TO FINAL PROJECT ***

#define chipSelect 10      //pin for the CS/SS
#define led 2              //led and/or buzzer

volatile bool mpuInterrupt = false; //just one of those bools

bool ledState     = false; //state of the led and/or buzzer
bool dmpReady     = false; //state of the mpu6050

int yprInt[3];             //gyro data in a integer because the extra precision of the float is total bullshit
int altitude;              //altitude above takeoff point in meters
int altitudeCalibration;   //calibration for the altimeter
int temperature;           //temperature in degrees Celcius

float counter = 0;         //time counter, a somewhat internal clock that starts when the module starts dataloging

uint8_t mpuIntStatus;      //holds actual interrupt status byte from MPU
uint8_t devStatus;         //return status after each device operation (0 = success, !0 = error)
uint8_t fifoBuffer[64];    //FIFO storage buffer

uint16_t packetSize;       //expected DMP packet size (default is 42 bytes)
uint16_t fifoCount;        //count of all bytes currently in FIFO

String day;                //day of the week
String ymd;                //date: year,month,day
String hms;                //time: hour,minute,second

MPU6050 mpu;               //MPU6050 object declaration as mpu
Quaternion q;              //quaternion container
VectorFloat gravity;       //gravity vector

MPL3115A2 myPressure;      //MPL3115A2 object declaration as myPressure
DS3231  rtc(SDA, SCL);     //DS3231 object declaration as rtc

//==================================================

void setup()
{
  generalSetup();

  gyroSetup();
  baroSetup();

  dataSetup();
}

//==================================================

void loop()
{
  gyro();      //read angles
  baro();      //read altitude and temperature
  timeClock(); //read day, date, time

  dataPrint();   //serial print the information

  dataLog();   //write data in sd card

  timer();     //time delay and led flash
}
</code></pre>

<p>Tab2: SETUP</p>

<pre><code>//==================================================

void generalSetup()
{
  Serial.begin(115200); //start serial communication
  Wire.begin();         //start I2C communication
  rtc.begin();          //start DS3231

  pinMode(led, OUTPUT); //led or buzzer; used to easily find a lost device
}

//==================================================

void dmpDataReady() {
  mpuInterrupt = true;
}

void gyroSetup()
{
#if I2CDEV_IMPLEMENTATION == I2CDEV_ARDUINO_WIRE
  TWBR = 24;
#elif I2CDEV_IMPLEMENTATION == I2CDEV_BUILTIN_FASTWIRE
  Fastwire::setup(400, true);
#endif
  //while (!Serial);
  mpu.initialize();
  devStatus = mpu.dmpInitialize();
  mpu.setXGyroOffset(220);
  mpu.setYGyroOffset(76);
  mpu.setZGyroOffset(-85);
  mpu.setZAccelOffset(1788);

  if (devStatus == 0)
  {
    mpu.setDMPEnabled(true);
    attachInterrupt(0, dmpDataReady, RISING);
    mpuIntStatus = mpu.getIntStatus();
    dmpReady = true;
    packetSize = mpu.dmpGetFIFOPacketSize();
  }

  else
  {
    return;
  }
}

//==================================================

void baroSetup()
{
  myPressure.begin();             //start MPL3115A2 communication 
  myPressure.setModeAltimeter();
  myPressure.setOversampleRate(7);
  myPressure.enableEventFlags();
  altitudeCalibration = myPressure.readAltitude(); //read altitude
}

//==================================================

void dataSetup()
{
  if (SD.begin());
}

//==================================================
</code></pre>

<p>Tab3: FUNCTIONS</p>

<pre><code>//==================================================

void gyro()
{
  float yprFlo[3]; //gyro data in a float

  mpu.resetFIFO();
  mpuInterrupt = false;
  mpuIntStatus = mpu.getIntStatus();
  fifoCount = mpu.getFIFOCount();

  if (mpuIntStatus &amp; 0x02)
  {
    while (fifoCount &lt; packetSize) fifoCount = mpu.getFIFOCount();
    mpu.getFIFOBytes(fifoBuffer, packetSize);
    fifoCount -= packetSize;
    mpu.dmpGetQuaternion(&amp;q, fifoBuffer);
    mpu.dmpGetGravity(&amp;gravity, &amp;q);
    mpu.dmpGetYawPitchRoll(yprFlo, &amp;q, &amp;gravity);

    for (int i = 0; i &lt; 3; i++)
    {
      yprFlo[i] = yprFlo[i] * 180 / M_PI; //simplify the variable for serial printing and dataloging
    }

    for (int i = 0; i &lt; 3; i++)
    {
      yprInt[i] = yprFlo[i]; //changing the variable from a float to a int
    }
  }
}

//==================================================

void baro()
{
  altitude = myPressure.readAltitude() - altitudeCalibration; //read altitude
  temperature = myPressure.readTemp();  //read temperature
}

//==================================================

void dataPrint() //serial print all the data
{
  Serial.print(day);
  Serial.print(" ");
  Serial.print(ymd);
  Serial.print(" -- ");
  Serial.print(hms);
  Serial.print(", ");
  Serial.print(counter);
  Serial.print(", ");
  Serial.print(yprInt[0]);
  Serial.print(", ");
  Serial.print(yprInt[1]);
  Serial.print(", ");
  Serial.print(yprInt[2]);
  Serial.print(", ");
  Serial.print(altitude);
  Serial.print(" ,");
  Serial.print(temperature);
  Serial.println();
}

//==================================================

void dataLog()//wirte all the data in a note file on the sd card
{
  if (altitude &gt; 1) //if the device is higher then 1m, then we sstart recording everything
  {
    File dataFile = SD.open("datalog.txt", FILE_WRITE);

    if (dataFile)
    {
      dataFile.print(day);
      dataFile.print(" ");
      dataFile.print(ymd);
      dataFile.print(" -- ");
      dataFile.print(hms);
      dataFile.print(", ");
      dataFile.print(counter);
      dataFile.print(", ");
      dataFile.print(yprInt[0]);
      dataFile.print(", ");
      dataFile.print(yprInt[1]);
      dataFile.print(", ");
      dataFile.print(yprInt[2]);
      dataFile.print(", ");
      dataFile.print(altitude);
      dataFile.print(" ,");
      dataFile.print(temperature);
      dataFile.println();
      dataFile.close();
    }
  }
}

//==================================================

void timeClock()
{
  day = rtc.getDOWStr();
  ymd = rtc.getDateStr();
  hms = rtc.getTimeStr();
}

//==================================================

void timer()
{
  counter = counter + 0.5;

  #ifndef testtest
  ledState = !ledState;
  digitalWrite(led, ledState);
  #endif

  delay(500);
}

//==================================================
</code></pre>
 612: <p>In fact the MPU-6050 on the GY521 and the DS3231 both use I2C address 0x68.  Had you looked at the source of the header files you included for each, this would have been apparent.</p>

<p>By consulting the data sheet for each chip you will likely find a way to either change the I2C address by changing a configuration pin, or else to potentially enable/disable the chip by changing one with a GPIO.  This will, however, likely require surgical modification of the carrier board.</p>

<p>You could also move whichever device you expect to access least to a distinct "soft" I2C bus bit-banged on other GPIO pins. No endorsment is implied, but the the first such library that came up in a web search was:</p>

<p><a href="http://playground.arduino.cc/Main/SoftwareI2CLibrary" rel="nofollow">http://playground.arduino.cc/Main/SoftwareI2CLibrary</a></p>

<p>you can likely find other options for yourself, or can potentially create your own.</p>

<p>There are also other chips in the family of the MPU-6050 which speak SPI instead of or as well as I2C, however these tend to be more expensive.</p>
 10794: <p>According to my calculations the total pull-up is:</p>

<pre><code>1 / (1/10 + 1/10 + 1/4.7) = 2.423 k
</code></pre>

<p>As I show on <a href="http://www.gammon.com.au/i2c" rel="nofollow noreferrer">my page about I2C</a> a 2.2 k pull-up resistor gives a reasonably good signal:</p>

<p><a href="https://i.stack.imgur.com/4gbW0.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/4gbW0.png" alt="2.2k pullup"></a></p>

<p>Thus I don't think the resistors are the issue. And I don't see how adding more would "calm the whole I2C constellation a bit".</p>
 78196: <p>When additional resistors are added in parallel, which is what is going on when you add new I2C devices to the I2C bus, the overall resistor is lowered. This could cause a problem with devices that cannot provide enough current with a low pull-up resistance. Hence, the device will not function well when the pull-up resistance is lower than a specific value. To fix the problem, I recommend removing all parallel pull-up resistors and just keep one at each line to achieve a good resistor value of approximately 4.7 k-ohms.</p>
