Reading sensor data off a ICM-20948 via i2c with Arduino uno
51 views (last 30 days)
So I have a project where I have to read Sparkfun's ICM-20948's data (Gyro, accelerometer, and magnetometer) through matlab, and down the line, I need to perform calculations with those numbers. Im not too familiar with matlab, but the sensor does work with arduino IDE. I have the sensor hooked up via I2C pins. This is my code so far:
a = arduino("COM4","Uno","Libraries","I2C")
s.BaudRate = 115200;
fs = 100;
IMU = device(a,'I2CAddress','0x69');
write(IMU, 0x0, 'uint8');
data = read(IMU, 4, 'uint16')
the output from data was [234, 0, 16384, 65]. Im not sure what these numbers mean. The ICM-20948 was suppose to be a "upgrade" to the mpu9250 according to adafruit's website, but the mpu() command that matlab has does not work with this sensor. My uno is also from sparkfun. The pinout diagram provided by arduino explorer app seems to have SDL and SDH flipped, so im not sure if that would cause any problems? Any ideas on what I should do?
Gayatri Menon on 13 Mar 2022
Edited: Gayatri Menon on 6 Jun 2022
Even though ICM20948 is the recommended sensor over MPU9250, the register settings for both the sensors are different. Hence using mpu9250() wouldn't work since this functionality is implemented considering MPU9250 registers.
ICM20948 sensor is supported in MATLAB & Simulink from R2022a.
a = arduino
imu = icm20948(a)
See below links for more info
Hope this helps