I am interested in collecting data from 3 MPU9250 via I2C communication protocol. As I've read, I can collect measurements on the same I2C Bus from up to two MPUs. However, how can I collect Synced data from more than 2 MPUs. And if not Arduino what do you recommend?
-
After a short view at the datasheet, it seems that a pulse at the FSYNC pin will trigger a measurement. You could tie all MPU FSYNC pins to one digital output of the Arduino, so that the measurements are triggered at the same time. Then read the data from the MPUs FIFO like normal– chrislDec 9, 2019 at 6:58
-
Thank you for your reply @chrisl can you elaborate on the data reading part?– YvesDDec 11, 2019 at 15:03
1 Answer
The MPU uses a FIFO buffer for the data. So the time of measurement is not necessarily the same as the time of communication. Additionally there is the FSYNC pin. In the MPU9250 datasheet there is nearly nothing described about that pin, only the pin description:
11 FSY Frame synchronization digital input. Connect to GND if unused.
I would interpret this as: If you pulse this pin to high (active high), a measurement is started. I cannot garantee, that it works this way; I also only can look into the datasheet. For my answer I will assume, that the pin really works this way. You will have to test this yourself.
Based on that info I would propose the following solution (without being able to try it myself due to the lack of MPU):
Connect 1 Arduino digital output pin to the FSYNC pins of all MPUs. If you pulse this pin from LOW to HIGH (and then to LOW again after a short time to return to the passive state), the MPUs will start their measurements. Since they all get the same start pulse, they will do the measurement at the same time. (It may be, that you need to configure the MPU for this) When the measurement is done, the data will be placed in the FIFO buffer. Then you need to grab this data from all the MPUs over I2C.
Here come a trick, so that you can effective connect to a great number of MPUs: The address pin of the MPU is also checked during operation. This means, that you can change the address of an MPU during operation by connecting it's address pin to a digital output pin of your Arduino. Do this with every used MPU, one output pin for one MPU address pin. On the Arduino you set all the pins to the same output state (let's say LOW) to keep all the MPUs on the same address. You must not ever call this address through I2C. If you want to communicate with one of the MPUs, you output a HIGH at it's address pin. This specific MPU will change it's address, where you can now communicate like normal. When you are done communicating with it, just output LOW again. Now you can activate the next MPU for communication by outputting HIGH on it's corresponding address pin.
This way you have 1 inactive address and 1 active address, where the MPU's being there change based on your digital outputs.