It is only possible to connect two of these sensors to your Arduino, not four. On the first, you connect the AD0 pin to the GND, on the second, you connect the AD0 pin to the 3,3V pin. The first will have I2C address 0x68, the second will have address 0x69.
I don't know for sure, but I think you should add some extra things:
#define MPU6050_I2C_ADDRESS_unit2 0x69 // the address of your second MPU
The rest of the code is also used in a slightly different way. Everywhere where it says "MPU6050_I2C_ADDRESS", you can choose which MPU you want to use.
int MPU6050_read(int start, uint8_t *buffer, int size)
int i, n, error;
n = Wire.write(start);
if (n != 1)
n = Wire.endTransmission(false); // hold the I2C-bus
if (n != 0)
// Third parameter is true: relase I2C-bus after data is read.
Wire.requestFrom(MPU6050_I2C_ADDRESS, size, true);
i = 0;
while(Wire.available() && i<size)
if ( i != size)
return (0); // return : no error
This code will 'do something' with the first MPU, when you use MPU6050_I2C_ADDRESS, and it will 'do something' with the second MPU when MPU6050_I2C_ADDRESS is changed to MPU6050_I2C_ADDRESS_unit2. The same goes for MPU_write()