0

This question already has an answer here:

I am trying to build a project that contains more than one MPU 9250, until now I'm still confused to MPU9250. If I were going to that, does anybody here know how to set addresses to each of the MPU's I am going to use? Thank you for spending time reading my question. I hope someone will help me get through this.

marked as duplicate by Dmitry Grigoryev, user31481, gre_gor, dhimaspw, KIIV Feb 7 '18 at 7:56

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

1

It is possible to have up to two MPU 9250 devices on an I2C bus without any extra logic. Pin 9 (AD0/SD0) defines the lowest bit in the I2C address of the device. Please see Chap 7.2 I2C Interface

If you need to connect more than two devices this can be done by connecting the AD0/SD0 pin of each device to a chip select pin on the arduino. This pin is asserted when addressing the device (This solution was provided by @Gerben, see comments below).

An example with three MPU 9250: Arduino D4-D6 are used as chip select pins. MPU1 AD0/SD0 pin connected to D4, MPU2 pin to D5, and MPU3 to D6. D4..D6 are initiate to HIGH. When addressing a MPU the chip select pin is set to LOW and the lower I2C address is used for access. The other MPUs will be listening for the higher I2C address.

Cheers!

  • You could connect the AD0/SD0 pin to an arduino pin (source). That way you can set the unit you want to communicate with to one address, and all the other units to the second address. – Gerben Dec 18 '15 at 13:14
  • @Gerben Please explain how this would work. Sounds like you are talking about chip select for SPI. For I2C, one of the MPU 9250 should have the AD0/SD0 pin tied to GND and the other to VCC (preferable with resistor). – Mikael Patel Dec 18 '15 at 16:19
  • 1
    By connecting the AD0/SD0 address pin to the arduino, you can change the address "on the fly". So you set the pin to HIGH on every module except one, and then use address 1101000 to connect to the one module with AD0/SD0 set low. This however assumes that the module allows changing the address on the fly, and doesn't e.g. only read the AD0 pin on powerup. See also; hackaday.com/2015/03/27/using-i2c-addresses-as-chip-selects – Gerben Dec 18 '15 at 16:26
  • 1
    @Gerben Thanks that explains the idea. It is actually a bit like SPI chip select addressing but with the I2C address match instead. Thanks for sharing that! – Mikael Patel Dec 18 '15 at 20:17
0

This is the type of information which a Data Sheet is intended to communicate. In I2C mode the AD0 pin selects between two possible addresses,

1101000 for AD0=0 and 1101001 for AD0=1.

In SPI mode you can presumably have as many as you like by giving each its own chip select.

That said, using multiple sensors may not be very useful unless your apparatus is flexible - only the 3 accelerometer axis would be expect to yield different values based on position relative to the center of rotations.

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