I am making a project and one of its requirement is to interface and collect data from three MPU6050 at a time. I am successfully able to get one MPU6050 work and process the raw values. But I have no idea how to connect/interface the remaining two!
I have gone through a number of threads but unable to resolve the problem!
Help will be appreciated!
I2C interface, with an AD0 line for address select. Connect SDA/SCL to all devices in parallel. See 9.2 of the datasheet:
"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)."
Use a separate Arduino IO pin to connect to AD0 on each MPU6050. Take AD0 low for the device you want to talk to, and use the b1101000 address to talk to the device.
Thanks for the prompt response. I just saw the section 9.2 of the datasheet.
What I understood of your comment is to connect AD0 pinof first sensor to high(3.3V) and the other to low (0V)}
What about the third sensor?
How do I define the Sensor addresses?
I am using this built in example!
MPU6050_DMP6.ino (15.5 KB)
The pin "AD0" selects between I2C address 0x68 and 0x69. That makes it possible to have two of these sensors in a project. Most breakout boards have a pullup or pulldown resistor to make AD0 default low or high. Connect AD0 to GND or 3.3V for the other I2C address.
When more MPU-6050 sensors are needed in a project, the I2C-bus can be extended with multiplexers. However, someone in the forum mentioned a nice trick:
Using more than two MPU-6050 sensors can be achieved by connecting each of the AD0 pins to a separate output of the Arduino. If the number of pins is a problem, then a shift register or a port expander can be used.
The output of a 5V Arduino can not be used. In that case a voltage divider or level shifter for 3.3 volts on each of the outputs is needed. The 5V output pins can also be converted in 3.3V open collector outputs by using transistors or an open-collector driver. Pullup resistors to 3.3V should be added for a high level of 3.3V.
Suppose all AD0 lines are default high (3.3V), so every MPU-6050 is I2C address 0x69. That I2C address is however never used ! The Arduino makes one of the AD0 lines low, and uses that sensor at I2C address 0x68. After that is finished, the Arduino selects another AD0 line, and can use that sensor.
So every sensor is used at I2C address 0x68 (one by one) and 0x69 is never used."
I saw these instruction at some form of arduino.
Can anybody explain in steps the method needed to followed?
You found that here : http://playground.arduino.cc/Main/MPU-6050
That is what CrossRoads was saying.
It has been confirmed that the 'trick' works.
The MPU-6050 can be at I2C address 0x68 or 0x69, depending on AD0. Do you know what a I2C address is ?
With three sensors, you need three seperate digital pins from the Arduino to the three AD0 of the sensors. Set those all three default high. All the sensors will be at 0x69.
When you want to use a sensor, make its AD0 low, and use the sensor at address 0x68. When finished with that sensor, make the AD0 high again.
However, the Arduino Mega 2560 is a 5V Arduino board, and it has 10k pullup resistors on board. Therefor you may not connect the Arduino SDA or SCL to the MPU-6050. You may also not connect a digital pin to AD0.
You must use level shifters. Two for SCA and SCL and three more for the three AD0 signals.
I hope you don't want to use the interrupts of the sensors or the i2cdevlib library with the 'dmp' mode.