I have been trying to change the I2C address of MPU9150 with AD0=L/AD0=H, connecting with AD0 to either GND and 3.3VCC. In the Sketch of Arduino, I also changed to either MPU9150_I2C_ADDRESS = 0x68 or MPU9150_I2C_ADDRESS = 0x69. When the AD0 is connected with GND and it is MPU9150_I2C_ADDRESS = 0x68 in Arduino, I can correctly get the data. However, when the AD0 is connected with 3.3VCC and MPU9150_I2C_ADDRESS = 0x69, I can not get any data from MPU9150.
I have tried this with MPU9150 from Sparkfun (I removed the jumper) and others. I also tried many examples, for example Arduino Playground - MPU-9150, GitHub - sparkfun/MPU-9150_Breakout: Example code and PCB design files for the MPU-9105, 9DOF., and others, but there was no luck.
Did anyone already succeed this? If so, thank you for the information in detailed.
I would suggest that you run the I2C scanner after you change the address. I don't have a datasheet but I don't think the address changes by only lsb. The lsb of an I2C address sets whether the communication is a send or receive.
#include <Wire.h>
void setup() {
Serial.begin (115200);
// Leonardo: wait for serial port to connect
while (!Serial)
{
}
Serial.println ();
Serial.println ("I2C scanner. Scanning ...");
byte count = 0;
Wire.begin();
for (byte i = 1; i < 120; i++)
{
Wire.beginTransmission (i);
if (Wire.endTransmission () == 0)
{
Serial.print ("Found address: ");
Serial.print (i, DEC);
Serial.print (" (0x");
Serial.print (i, HEX);
Serial.println (")");
count++;
delay (1); // maybe unneeded?
} // end of good response
} // end of for loop
Serial.println ("Done.");
Serial.print ("Found ");
Serial.print (count, DEC);
Serial.println (" device(s).");
} // end of setup
void loop() {}
I have tried what you suggested. I also tried with getAuxVDDIOLevel() previously. As a matter of fact the address is changed, but the I can not correctly get the date from MPU9150, when it is AD0->3.3VCC + 0x69. Do you have any idea?
From datasheet:
The slave address of the MPU-9150 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-9150s 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).
So you only have two possible addresses (0x68 or 0x69) to test.Pretty simple
Do you have pull-up resistors 4.7K in both i2c lines?
I have check this again:
http://playground.arduino.cc/Main/MPU-9150
Besides on the I2C address, do I also need to change the address of 0x0C/0x0D within the Sketch?
MPU9150_I2C_ADDRESS = 0x0C; //change Adress to Compass
I found the solution.
In the header of MPU6050.h, there is
class MPU6050 {
public:
MPU6050();
MPU6050(uint8_t address);
………etc.
in the line of 411. Therefore, it can be simply added like this in Sketch:
MPU6050 accelgyro(0x69);
for the case of Sketch « MPU9150_raw.ino
Then it worked!