Multiple MPU 9150 and I2C

Hello,
I am working on a project in which I wish to use around 14 MPU 9150. I can only use one controller (preferably Mega).

I looked at the Jeff github libraries for mpu 6050 and mpu 9150. I am able to get the 3 mpu6050 data quite easily by simply HIGH and LOW-ing the AD0 pins of each mpu6050 ( I also connect the interrupt pin of mpu6050 to different interrupts on mega, made different ISR and isr variables for each mpu Interrupt) . In short I got the data from mpu6050 which is not stable (drift issue).

Now when I do the same thing with mpu9150, I get the data but it starts fluctuating very fast after a minute (even when the sensors are at rest, it is not a drift issue btw) or so. I have no idea why is that. I rarely change anything in Jeff-provided example, named 'MPU9150_DMP6' except that I made ISR for each interrupt. To initialize each mpu, I first HIGH all AD0's pin except the one I am initializing (using the 0x68 default I2C address). and did the same when I am getting data (in form of quaternions).

I am printing the data of each mpu at once. I have really hit a roadblock in ideas. Please give me any suggestion or idea, anyone thinks is worth doing.

Arsh.
Thanks :slight_smile:

You may not connect a output of the 5V Arduino board to the AD0 pins.

With 14 sensors at 3.3V, perhaps you better use a 3.3V Arduino board.
I think you also better use the MPU-9250 with SPI interface. Even at 400kHz, the I2C with 14 sensors will be slow.
https://www.invensense.com/products/motion-tracking/9-axis/mpu-9250/

What is your project ?
How long are the wires to the sensors ?
Show us your sketch.

Thank you Koepel for your reply. Though I did not get what u mean by "You may not connect a output of the 5V Arduino board to the AD0 pins."

I have declared pin 8, 9 and 10 (on Mega) as output and connect AD0 pins to them. Should I not do this? Should I use 3.3 arduino boards?

Yes, I might end up using SPI and mpu9250 but I first want to exhaust all my possibilities with mpu-9150 as I have already bought them (also bought mpu-6050, had to come to mpu-9150 due to drift issue).

The weird thing is, I somehow use the same concept of low/high-ing the AD0 pin to get the data from 3 mpu, but this time I am using the "MPU9150_raw example. (for clearly seeing data, I am printing only x-axis accelerometer values) and this time the data is quite stable. Though I don't know how to convert this raw data into sensible and nice quaternions for further use. :confused:

My Guess is there is something going on in the MPU9150_9Axis_MotionApps41.h file that is making the jerky data when 3 mpus are used.

When using a Arduino Mega 2560 or Arduino Uno, a digital pin as output is 5V (up to 40mA).

The MPU-6050, MPU-9150, MPU-9250 are 3.3V sensors. If a 3.3V sensor gets 5V at a pin, the 5V might travel through the sensor, and the sensor could get damaged.

According to the datasheet, the operating voltage VDD is 2.375 to 3.465V, but VDD can be 6V before the sensor is damaged. That is a lot for a 3.3V sensor.
Pin AD0 can be up to VDD + 0.5V. When the sensor it running at 3.3V, that means VDD can be 3.8V. If it gets a higher voltage, it might lift the VDD of the sensor. Perhaps the sensor is not destroyed, but it will no longer run normally.

Keep the sensor in the normal operating voltage range, and use AD0 according to the datasheet, that is no more than 3.8V. Only then you may use the data from the chip.

The Arduino Mega 2560 has 10k pullup resistors at SDA and SCL. That means that also the I2C bus of the Mega 2560 may not be connected to a 3.3V sensor without I2C level shifter.

Thanks Koepel, that clears up almost everything.

So, just to try this. I dont have an arduino (except a uno and mega, both are 5V). Can I use like a voltage divider from OUTPUT pins (in my case, pin 8,9,10) to bring down its voltage to 3.3V? Would that work? I think it should.

And really thanks for pointing that out. I was really outta ideas. :slight_smile:

Yes, the AD0 does not really use current. Perhaps 4k7 to output pin and 10k to GND. Or 2k2 to output pin and 4k7 to GND.
The Arduino Mega 2560 is the only board with 10k resistors from SDA and SCL to 5V. Therefor you must use a level shifter for the I2C bus when using 3.3V sensors.
The Arduino Uno does not need a level shifter for testing, if 4k7 pullup resistors are used from SDA and SCL to 3.3V. But that is only for testing, because the voltage levels will be outside the specifications.

Thank Koepel.

I did try what you asked. dropped down the voltages from output pins to 3.3V but it did not seem to work at all.

BTW I have Invensense sensor board, not sparkfun's and I read that Invensense sensors has a voltage regulator. Though I still tried with 3.3 V at Vcc and voltage divider on other pins but it did not seem to work then at all.

One more thing, when I tried using two sensor, I thought I might not get any unstable data in it, I did though. Like after 5 10 mints, the quaternion data does not make sense and keep fluctuating very fast.

Can u please suggest anything else?

I have attached the example I am using (a bit modified to use two sensors) from Jeff.

TwoSensor_06June.ino (12.8 KB)

Is that the Invensense "MPU-9150 9-Axis Evaluation Board" ?
That board seems to have a 3.0V voltage regulator.
How did you set all the jumpers ? Either the onboard voltage regulator is used (3.0V) or VIN, but VIN should be 3.3V I think.
The MCU_SDA and MCU_SCL could be 3.0V signals for the I2C bus, they are not compatible with a 5V Arduino board. A 5V Arduino board 'sees' a high level for SDA and SCL when the voltage is at least 3.5V. The INT (interrupt) must be at least 3.0V.

First thing is the get the hardware right, run the MPU-9150 with normal voltages. This is where you are stuck at the moment. You must be sure that everything is okay, and when using a 5V Arduino board, you need level shifters for the I2C bus and for the INT and for the AD0.
Next thing is the i2c_scanner, let it run for a while and it should be stable.
http://playground.arduino.cc/Main/I2cScanner
Then perhaps a small test:
http://playground.arduino.cc/Main/MPU-6050#short
After that, connect the interrupt, and try the i2cdevlib.

The i2cdevlib has an example for the 'dmp' for the MPU-6050, but not yet for the MPU-9150 ? I don't understand that.