Multiple IMU (MPU6050) into an Arduino, generating funky results

Hi all,

My friend and I are working on an Arduino project which involves the usage of 6 IMUs (MPU6050) together.

The way we are doing this is by using the AD0 port to turn on and off the IMUs sequentially to gather the data from a single IMU and place it into an array.

This sometimes works quite well but at other times we find that the data isn’t quite right, eg it reads that the IMU is vertical instead of horizontal and isn’t consistent.

We haven’t used any pull up/down resistors within the circuit as we don’t quite understand where to place them and were not sure if that was even necessarily an issue.

The code works quite well for individual IMUs it just becomes a but more funky since we get it to add more on.

Thanks very much for your help.

MultiIMURead.ino (12.4 KB)

Which Pro Mini do you use ?
You may not put a 5V digital output to the AD0 input of the 3.3V sensor. There are 3.3V 8MHz Pro Mini boards, so I’m hoping that you have one of those.

When you set all AD0 high in setup(), then you can assume that they are all high and you only have to lower the pin for the sensor that you want to use, and make it high at the end.

The ‘;’ closes the if-statement. In this case it is a empty statement after the if-condition. You code says: “if some_condition then do nothing”. In other words: “do nothing”:

if (Wire.available() == 14);

Waiting for something until all bytes are received is something that is made up by someone in the past. Please remove this, it is wrong:

while(Wire.available() < 14);

Do you know that there is a delay of 18 ms in the loop(). A delay of 18 ms doing nothing. That is wasting eightteen whole milliseconds. The code with micros() trying to get 250Hz can not get to 250Hz when there is a delay of 18 ms.
Have I mentioned the delay of 18 ms :wink: In case I forgot to mention that, there is a delay of 18 ms in your loop() :o

I think that you are outputting too much text.
With a baudrate of 57600, the output can be 5kbyte per second.
At 250Hz, that is 23 bytes per loop() iteration.
A baudrate of 115200 is more standard, and you could send text less frequently, for example, a few times per second. That can be done with a millis timer.

Which modules to you have for the MPU-6050 ?
Do they all have pullup resistors for SDA and SCL ?
Some cheap modules have 2k2 pullup resistors !
Six times 2k2 parallel with internal pullup of 30k makes: 362 Ω
3.3V / 362 Ω = 9 mA. That is not okay, it should not exceed 3 mA.