Connecting multiple MPU6050(GY521) to Arduino Due

Hi there,

I did a search and I couldn’t solve my problem so I’m opening a new topic.

I’m trying to connect 10 MPU6050 sensors to an Arduino Due and I’m a bit lost.
I can connect one sensors and get the values with no problem and everything working. I’m using the simple example provided in the web.

My problem comes when I connect two sensors, and want to read them using the AD0 trick mentioned in the arduino playground page. It seems that it is always reading the same sensor, the first one althought I change the value of the AD0.
Can someone give a hint to where’s my problem?

Thanks in advance,

prova_1sensor.ino (5.82 KB)

Each different MPU6050 should have a different address (MPU_ADDR in the attached code) on the I2C bus.

Edit: In the Arduino playground, they suggest an interesting trick to read more than 2 MPU6050:

If your 10 AD0 lines are connected to 10 different pins set to high (3.3V), so every MPU-6050 is I2C address 0x69. BUT you decide in your code to read only the device at address 0x68, and for that you set one and only one pin to a low level (GND) to give this device the address 0x68.

So every sensor is used at I2C address 0x68 (one by one) and 0x69 is never used.

Make sure that your sensors don't have builtin pull ups if you use SDA/SCL, otherwise use SDA1/SCL1 and replace everywhere in your code Wire by Wire1.

The "AD0 trick" works.

Please clean up the code by removing all the extraneous comments, and adding comments where appropriate.

For example, what is connected to pins 52 and 53? (I assume AD0 pins).


How do you know which sensor is being addressed? You print the same heading twice in a row:

    Serial.print("Giroscopi 1 ");

I’ve cleaned up the code and add a little comments.

Pin 52 and 53 are connected to the AD0 pins from two gyroscopes.

I’m using the GY-521.

I connect all the sensor SDA and SCL pins in parallel to the 20 and 21 pins of the arduino due, which are the SDA and SCL.
The Vcc sensor pins are connected tot the 3.3V output of the arduino and the grounds to the ground.

I think that’s all.

prova_1sensor.ino (3.96 KB)

The Vcc sensor pins are connected tot the 3.3V output of the arduino and the grounds to the ground.

If you are using the following type of Module for MPU6050, then the Vcc-pin of the Module should be connected with 5V of the Arduino. This particular Module has built-in 3.3V Regulator.


hey @baowatt Is your final code has worked for connecting 10mpu6050 with Arduino Due..? If yes please upload hardware connection and code...! Thank you in advance...