0

My target is to use multiple MPU-6050 at once, I searched on the internet and found that they can be hooked up really simply. Just connect in parallel and use I2C-Scanner. Then get those addresses and use normally.

But I can't find another address, there appears to be just one address 0x68, that is the reason why, I want to connect my other MPU-6050 in other pins.

How this can be achieved ?

  • The MPU-6050 has 1 pin to change 1 bit of the address. Means, that you can connect 2 MPU-6050 to the same I2C bus. – chrisl May 27 at 8:47
  • How, can you describe ?? Please – Maifee Ul Asad May 27 at 8:52
  • from datasheet "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)" – Juraj May 27 at 8:59
2

As you can read in the MPU-6050's datasheet, it uses the I2C address 0b110100X, where X is the state of the pin AD0. If you wire AD0 to ground, the address will be 0b1101000, whereas if you wire it to Vcc it will be 0b1101001. That is equivalent to the addresses 0x68 and 0x69.

That means, that - depending on how you wire AD0 - you can have 2 distinct MPU-6050's on the same I2C bus (you cannot have devices with the same address).

If you really need to connect more than 2 of them, you have to use an I2C multiplexer like PCA9544A, which will divide the bus down to sub-busses.


EDIT: Usually the address pins of I2C devices are set permanently by wiring them either to ground or Vcc. The sense of the address system is, that a slave device will stay at it's address, not changing it. But as Jot reported in the comments and as the Arduino Playground site of the MPU-6050 confirms, you can actually set the address pin of the MPU-6050 during operation.

You need 1 digital output pin on your Uno for each MPU, which then get's tied to the MPU's AD0 pin via a voltage divider. The last part is important: You need a voltage divider, because the MPU is a 3.3V device, while the Uno works with 5V. To avoid frying the address pin, you need to step down the voltage.

Then you would use the address pins to set all MPU's to one address (let's say 0x69). When you need to communicate with one of them, you toggle it's address pin, which will change it's address (in this case to 0x68). Then you can use the normal I2C workflow with this address (0x68). When you are done, you can put this MPU back to the other address by again toggling the address pin. You can repeat this with any of the connected MPU's, which can be many (I think the limit here is the I2C bus itself with it's wires capacity).

This is a workaround and not really, what the I2C bus is meant for. But it seems to be valid solution. Just be sure, that the addresses, that you communicate with, are always unique. Contacting an address, which belongs to more than 1 device, will block your I2C bus.

  • It means, using a loop toggling value of AD0, I can access both ? – Maifee Ul Asad May 27 at 9:11
  • I don't think, that the MPU continously checks AD0, but that it checks it at power on. (Though I didn't found that clearly in the datasheet) That means, that you cannot change the address without power cycling the MPU. Either way, you won't be able to address more than 2 MPU's on the same bus. – chrisl May 27 at 9:23
  • 1
    @chrisl I have read somewhere that AD0 is used runtime. It is possible to have many mpu6050 sensors and select them one by one via its AD0 pin (keep them at 0x69 and use one at 0x68). This can not be done with an arduino uno, since a pin with 5v would blow the mpu6050 via the AD0 pin. – Jot May 27 at 12:32
  • @Jot Can you maybe remember, where you read that? Would be good to have some reference for that. – chrisl May 27 at 20:37
  • For example here: forum.arduino.cc/index.php?topic=545257.msg3716437#msg3716437 I have not tested it myself. – Jot May 27 at 21:37
0

You can connect more than 2 in serial by using the Address bit like a chip select. Say you had 8 of them. Use a shift register with the 8 outputs going to the 8 chips. Now output 0b00000001 and use I2C address 0x69, only the one device with a 1 on its address line will reply. Then use 0b00000010 for the 2nd device, 0b00000100 for the 3d, etc. up to 0b10000000 for the 8th.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.