How to connect two MPU6050?

Hi everybody,
...I've a problem: I connect two sensors MPU6050 and I use the AUXSCL and AUXSDA channel to read data from the second sensor. (to see the attached my circuit) But I don't know how I can read data from the "auxiliary" sensor. There aren't any problem to read data from the first sensor but how can I read the second on the serial monitor?!?

Thanks very very much!

But I don't know how I can read data from the "auxiliary" sensor.

What does it say about it in the MPU6050 datasheet?

Pag. 26 of the datasheet...

The MPU-60X0 always acts as a slave when communicating to the system processor. The LSB of the of the I2C slave address is set by pin 9 (AD0). The logic levels for communications between the MPU-60X0 and its master are as follows:
? MPU-6000: The logic level for communications with the master is set by the voltage on VDD
? MPU-6050: The logic level for communications with the master is set by the voltage on VLOGIC
Auxiliary I2C Serial Interface
The MPU-60X0 has an auxiliary I2C bus for communicating to an off-chip 3-Axis digital output magnetometer or other sensors. This bus has two operating modes:
? I2C Master Mode: The MPU-60X0 acts as a master to any external sensors connected to the auxiliary I2C bus
? Pass-Through Mode: The MPU-60X0 directly connects the primary and auxiliary I2C buses together, allowing the system processor to directly communicate with any external sensors.
Auxiliary I2C Bus Modes of Operation:
? I2C Master Mode: Allows the MPU-60X0 to directly access the data registers of external digital sensors, such as a magnetometer. In this mode, the MPU-60X0 directly obtains data from auxiliary sensors, allowing the on-chip DMP to generate sensor fusion data without intervention from the system applications processor.
For example, In I2C Master mode, the MPU-60X0 can be configured to perform burst reads, returning the following data from a magnetometer:
? X magnetometer data (2 bytes)
? Y magnetometer data (2 bytes)
? Z magnetometer data (2 bytes)
The I2C Master can be configured to read up to 24 bytes from up to 4 auxiliary sensors. A fifth sensor can be configured to work single byte read/write mode.
? Pass-Through Mode: Allows an external system processor to act as master and directly communicate to the external sensors connected to the auxiliary I2C bus pins (AUX_DA and AUX_CL). In this mode, the auxiliary I2C bus control logic (3rd party sensor interface block) of the MPU-60X0 is disabled, and the auxiliary I2C pins AUX_DA and AUX_CL (Pins 6 and 7) are connected to the main I2C bus (Pins 23 and 24) through analog switches.
Pass-Through Mode is useful for configuring the external sensors, or for keeping the MPU-60X0 in a
low-power mode when only the external sensors are used.
In Pass-Through Mode the system processor can still access MPU-60X0 data through the I2C
interface.
Auxiliary I2C Bus IO Logic Levels: MPU-6050: The logic level of the auxiliary I2C bus can be programmed to be either VDD or VLOGIC

I followed the istructions for the Pass-Through Mode:... on the chip is present an "interface bypass mux" and it shuold be the "analog switches" above cited. I don't know how I can read the aux-data.

THANKS for your reply!

MPU-6050.pdf (1.6 MB)

The important part is: "The LSB of the of the I2C slave address is set by pin 9 (AD0).". You need to set pin 9 to different values on the to units. Then they will have different I2C addresses so you can controll them separately. Once you do that it doesn't matter if they are on he same I2C bus or if you use pass-through.

Somewhere in your code there is an address for the first module. To communicate with the other module you use the other address.

Johnwasser, thank you very much for your advice!

I read that, of default, the address of the sensor is 0X68 IF the AD0 is linked to GND or 0X69 if it's linked to VDD. Therefore, I should desolder the jump and remake it, so that I can change the address of the second sensor.

That you know... Is there a way to change the address by SW and not HW?... For example: Can I control the MUX someway?!? Read first one and than the other.

woodstock:
That you know... Is there a way to change the address by SW and not HW?

I do not know of any way to change the address of the MPU6050 with software.

Not possible in software.

The AD0 solder jumper is on the breadboard to select 0x68 or 0x69. And you select in software the address according AD0. See also : Arduino Playground - MPU-6050

So connect them both to the normal I2C bus, with different AD0, and run the i2c_scanner : http://arduino.cc/playground/Main/I2cScanner

I changed the address and now I've got first sensor 0x68 and second 0x69.

I connect the two sensors in this way (scheme in attach). The I2Cscanner is OK and I see two address, but I have some problem... First of all, sometimes on the serial monitor I read "FIFO overflow" and, in particular, after few seconds (random) the TX stops (turn off TX led on Arduino). I don't understand!! Please, can you help me???

I specially modified the script so that I can read the data from two sensors. (script in attach).

Schema.pdf (244 KB)

script.txt (9.67 KB)

Hi!

I'm trying to connect two MPU6050 (GY-521 breakout board) but I have the same problems showed in this post.
I think it could be because of the libraries but I can't identify the problem yet.
My code (attached, sorry for the "spanglish") is slightly different than yours but the result is the same :frowning:

Could anyone connect two MPU6050?

Can anyone help me?

Thanks in advance.

Code.txt (11.5 KB)

Are you sure the INT is open collector and can be tied together ?
The 'dmp' sketch sets a default for the sample rate to be placed in the fifo. That is not ment for two devices, so perhaps you can't do all the calculations in the example. Don't add a delay in the sketch.

This all I can think of at the moment.

Hi everyone,
i have a question ,hoped that all of you can solve for me.
I want to connect more than 2 MPU6050 on board arduino Uno R3
what should i do?
Thanks!

hi
did you tried to connect two mpus to same pin ie pins from both mpu to the same pin on arduino (it will be common pin for both mpu's)
just a thought..

Hi, i've tried that but the problem is there will be fifo overflow and unstable reading of the MPU 6050. I've tried to change the dmp rate, but the problem is still there. and after 15-20 minutes run, the sensor reading will stop, I dont know what is the problem. can someone help me?

erguezga:
Hi!

I'm trying to connect two MPU6050 (GY-521 breakout board) but I have the same problems showed in this post.
I think it could be because of the libraries but I can't identify the problem yet.
My code (attached, sorry for the "spanglish") is slightly different than yours but the result is the same :frowning:

Could anyone connect two MPU6050?

Can anyone help me?

Thanks in advance.

Hi,

I am interested in connecting 4 MPU6050 to one arduino. By looking at your sketch, I can just connect the SDA and SCL of 4 MPU6050 to the breadboard and change the address for the other sensors. However, I am not really familiar with arduino code. Can you please help me if you had already achieve reading multiple MPU6050.

Thank you.

Do you mean this new section : Arduino Playground - MPU-6050
No one has tried it yet, as far as I know.

If you have a 5V Arduino, you have to adapt the selection signal to 3.3V for the 4 AD0 lines.
You can start your project with two MPU-6050 modules. Connect one AD0 line to GND, the other to 3.3V. Try to make a sketch that reads both.

Hi,

I am using sparkfun MPU6050 and I guess the AD0 pin is already connected to ground????(since it is being soldered)...
I think i will use 74HC4051N multiplexer since I need to connect 4 mpu6050 and it only have two address (i guess)???

Is this sound sensible to you?

Sparkfun uses solder to connect AD0 either to GND or VCC (3.3V).

You can use the multiplexer for the I2C SDA signal. Is that what you want to do ?

I agree with the answer of using the two mpu6050 chips in parallel on the I2C bus.

BUT, I have the same question about using the I2C AUX pins on the mpu6050,
except with the Hmc5883L chip/board.

I am using the Gy521 mpu6050 and the Gy273 hmc5883L boards.
I need to have the hmc5883 on the I2C AUX pins XCL and XDA,
but the Arduino host does NOT see the hmc5883 on the AUX bus.

I can swap the Hmc5883 SCL and SDA onto the host I2C bus,
and it spits out the 5883 data (with the 6050 data),
but only zeroes when connected on the 6050 XCL & XDA pins.

I have the Arduino wired up to the 6050 and powered by 5V from the USB.
I also tried adding a 9V battery on the Raw pin - still no results from the I2C AUX 5883.
Pull-up Resistors were also tried on the XCL & SDA -> Hmc5883 pins - no luck with or without.
These additional Pull-ups should not be needed though - considering the XCL & XDA plus the Hmc5883 board are supposed to already have Pull-ups.

Below is part of the program that I used :

void setup()
{
// ...

// Mpu6050 :

Wire.begin();

Wire.beginTransmission(0x68);
Wire.write(0x6B); // PWR_MGMT_1 register
Wire.write(0); // set to zero (wakes up the MPU-6050)
Wire.endTransmission(true);
//

// (Mpu6050) :
// ENABLE AUX_I2C Port :
Wire.beginTransmission(0x68);
Wire.write(0x37); // INT_PIN_CFG register
Wire.write(0x02); // set 0x02 to one Enables AUX_I2C
Wire.endTransmission(stop);
//

// TEST HMC5883 CONNECTION : //
int Frspcnt;
for(Frspcnt=100; Frspcnt>0; Frspcnt --) {
Wire.beginTransmission(HMC_address);
Wire.write(0x0A); // REG_RA_ID_A
Wire.endTransmission(false);
Wire.requestFrom(HMC_address, 1);
if(Wire.available()) {
if(Wire.read() == 'H') {
Wire.endTransmission(stop);
break;
}
}
Wire.endTransmission(stop);
}
if(Frspcnt == 0)
{ Serial.println("* --- HMC5883 Connection FAILED ! --- *"); }

//Put the HMC5883 IC into the correct operating mode
Wire.beginTransmission(HMC_address); //open communication with HMC5883
Wire.write(0x02); //select mode register
Wire.write(0x00); //continuous measurement mode
Wire.endTransmission(stop);
//

//Tell the HMC5883 where to begin reading data
Wire.beginTransmission(0x1E);
Wire.write(0x03); //select register 3, X MSB register
Wire.endTransmission(false);

//Read data from each axis of HMC5883, 2 registers per axis
Wire.requestFrom(HMC_address, 6);
if(6<=Wire.available()) {
x = Wire.read()<<8; //X msb
x |= Wire.read(); //X lsb
z = Wire.read()<<8; //Z msb
z |= Wire.read(); //Z lsb
y = Wire.read()<<8; //Y msb
y |= Wire.read(); //Y lsb
}

// and Print them :
Serial.println(x);
Serial.println(y);
Serial.println(z);

Wire.endTransmission(stop);
//

// (Mpu6050) :
// DISABLE AUX_I2C Port :
Wire.beginTransmission(MPU);
Wire.write(0x37); // INT_PIN_CFG register
Wire.write(0x00); // set 0x02 to zero Disables AUX_I2C
Wire.endTransmission(stop);

// ...

}

This clip does not show the 6050 Read & Print code.
But it only prints zeroes for the 5883 when it is on the I2C AUX bus.
While it does print out valid 5883 Values if it is on the Arduino host I2C bus
(because the AUX bus becomes not important).

But I NEED this hooked on the AUX bus ! ... What could be the problem ?


  • UPDATE: - Also added the TEST HMC5883 Connection Code ... but it Still just Fails repeatedly ...
    -> QED: ALL I can Say is: the I2C_AUX on mpu6050 is a NONWORKING and Useless feature ...

Hi,
I'm using the MPU6050 inertial sensor and I would like to do the thing he does in the next video: MPU6050 Arduino Matlab Motion Capture - YouTube

I really don't know much of working with arduino and the sensor, so if somebody could help me with the code and the connection of multiple sensors to one arduino i would appreciate it very much.

Thank you!

I followed this video and it works properly, Get Value from Multiple MPU6050 Using Arduino with Code - YouTube
Hope it helps

1 Like