I am currently trying to use two MPU 6050s (IMU sensors) with my Arduino. I have managed to get each sensor to read individually. My hardware I have wired as:
(Arduino) GND --> (IMU 1) GND --> (IMU 2) AD0
(Arduino) 3.3V --> (IMU 1) AD0 --> (IMU 2) 3.3V
(Arduino) A5 --> (IMU 1) SCL --> (IMU 2) SCL
(Arduino) A4 --> (IMU 1) SDA --> (IMU 2) SDA
From what I've seen online, I believe I've done this for the differing I2C addresses (0x68 & 0x69). I have also attempted to apply a Kalman filter and for the data to be in quaternions. For some reason (I hope its nothing too stupid), the data for all 3 IMU chips comes from one. I have attached my code and was just wondering if anyone could help me, thank you!
I was also going to try and plot the quaternions - Not sure if thats possible.
CODE
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
clc
clear
%% This code reads multiple IMU
%Put the 3.3v into the +, ground into -, then align the SCL and SDA
%% on the sensor --> change one ground to AD0, and on the other change VCC to AD0, this gives them different I2C addresses
%this code scans the address of the devices on the I2C
%a = arduino();
%addr = scanI2CBus(a,0); %scans location on the I2C
a = arduino('COM6','Nano33IoT','Libraries','I2C'); %creates an arduino object in the I2C Library
scanI2CBus(a); %without the ;, this shows the addresses of the bus
imu_board = lsm6ds3(a); %this is the arduino board imu sensor
imu1 = mpu6050(a,"I2CAddress",'0x68'); %this creates two imus on different i2c addresses
imu2 = mpu6050(a,"I2CAddress",'0x69'); % 0x68 is red led, 0x69 is green
%% created two variables above for the IMUs, this part tries to read them all at once
for i = 0:0.1:15
acceleration1 = readAcceleration(imu1); % reading the IMU
acceleration2 = readAcceleration(imu2); % reading the IMU
acceleration_board = readAcceleration(imu_board); %reading the Arduino
angularVelocity1 = readAngularVelocity(imu1); % reading the IMU
angularVelocity2 = readAngularVelocity(imu2); % reading the IMU
angularVelocity_board = readAngularVelocity(imu_board); %reading the Arduino
%performs an IMU data fusion, kalman filter
FUSE = imufilter; %generates a variable to fuse the imu data
%shows, in quaternions, of the fused algorithm
q1 = FUSE(acceleration1,angularVelocity1);
q2 = FUSE(acceleration2,angularVelocity2);
q3 = FUSE(acceleration_board,angularVelocity_board);
end
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''