Easily Changing I2C Address Of MPU6050 Accelerometer + Gyroscope

Hi,

Just thought i'd share my experience of the i2c interface on the mpu6050. I was trying to interface my generic mpu6050 breakout board with my arduino mega and also a i2c 20x4 lcd and tiny rtc and found the rtc and mpu6050 to be on the same i2c address of 0x68.

Having a quick read through the data sheet (http://invensense.com/mems/gyro/documents/PS-MPU-6000A-00v3.4.pdf) It has a section (page 15) referring to the i2c addresses and "AD0" being equal to 1 or 0. It turns out by putting 5v through the connector AD0 on the breakout board you can change the i2c address of the board from 0x68 to 0x69.

This means by ether connecting AD0 to a output on the arduino then digitalWrite(pin,HIGH); you can change the address, or alternatively you can connect the AD0 straight to the 5v output of the arduino.

Hope this helped :slight_smile:

Yes, and if you want to use more then two if them. Set all but the one you address to low, or high and the one you want to address, the opposite.

Some chips let you connect the address line to Gnd, VCC, SDA, or SCL, to have 1 of 4 addresses.

MPU6050 only supports 2 addresses:

9.2 I2C Interface
I2C is a two-wire interface comprised of the signals serial data (SDA) and serial clock (SCL). In general, the lines are open-drain and bi-directional. In a generalized I2C interface implementation, attached devices can be a master or a slave. The master device puts the slave address on the bus, and the slave device with the matching address acknowledges the master.
The MPU-60X0 always operates as a slave device when communicating to the system processor, which thus acts as the master. SDA and SCL lines typically need pull-up resistors to VDD. The maximum bus speed is 400 kHz.
The slave address of the MPU-60X0 is b110100X which is 7 bits long. The LSB bit of the 7 bit address is determined by the logic level on pin AD0. This allows two MPU-60X0s to be connected to the same I2C bus. When used in this configuration, the address of the one of the devices should be b1101000 (pin AD0 is logic low) and the address of the other should be b1101001 (pin AD0 is logic high).

If you need more, use an I2C mux:

Some chips let you connect the address line to Gnd, VCC, SDA, or SCL, to have 1 of 4 addresses.

And there are others that let you put in a voltage of up to eight steps between the Vcc and ground to get 8 addresses from one pin.

steinie44:
Yes, and if you want to use more then two if them. Set all but the one you address to low, or high and the one you want to address, the opposite.

neat trick! ; you need to program the dynamic addressing.

This will work if the sensor reads the AD0 pin constantly. (and you have enough pins)

If the sensor only senses the AD0 pin at startup (and copy it internally in a register or so ) the trick will not work.

If the sensor only senses the AD0 pin at startup (and copy it internally in a register or so ) the trick will not work.

What sensors do that?

Do not know of a sensor as I never tested using dynamic addressing this way.
but theoretically a sensor only need to read the address lines at start...

If I find one I'll post it here :wink:

Don't connect AD0 to 5V. The MPU-6050 is a 3.3V chip, and connecting AD0 to 5V might destroy it.

steinie44:
Yes, and if you want to use more then two if them. Set all but the one you address to low, or high and the one you want to address, the opposite.

steinie44, can you check this paragraph : Arduino Playground - HomePage
I hope I explained it well.

Looks good. if the number of pins is a problem, then a shift register or a port expander can be used. You will have to put a voltage divider or level shifter for 3.3 volts on each of the outputs.
Think of it as charlieplexing sensors.

Hey, I am trying to change the address of MPU-6050 from Ox68 to Ox69. According to the above discussion I need to keep the AD0 pin of the MPU high. At the same time I have edited the code. I replace Ox68 with Ox69 in the code mentioned here
http://playground.arduino.cc/Main/MPU-6050
But its not working. It is giving some random value.

lohani1575:
Hey, I am trying to change the address of MPU-6050 from Ox68 to Ox69. According to the above discussion I need to keep the AD0 pin of the MPU high. At the same time I have edited the code. I replace Ox68 with Ox69 in the code mentioned here
Arduino Playground - HomePage
But its not working. It is giving some random value.

Does address 0x69 show up if you try the I²C scanner:
Arduino Playground - HomePage ?

If your breakout board is like the photo in the original post, I understand there is an on-board low drop-out regulator for Vcc. What voltages are you connecting to Vcc and ADO on the breakout board?

If you have an oscilloscope, I suggest you check the 'high' signal levels on the I²C bus.