raw data format Qwiic icm20948 IMU

I am starting to work with the Qwiic IMU icm20948 and using the python code example on the GitHub page. The part of the code that displays the readings is shown below. Either I need to cast the raw data to a different type, or there is an issue with the readings because they don’t make physical sense.

In the library for the sensor, there are functions and comments about taking the 16 bit unsigned integer values and changing them to 32 bit signed integers for python. Is this the print out format I’m seeing (example attached)? How to I convert to physical real-world values?

The columns are raw Ax, Ay, Az, Gx, Gy, Gz, Mx, My, Mz, and Temperature

**** Example code snippet *****

while True:

if IMU.dataReady():

IMU.getAgmt() # read all axis and temp from sensor, note this also updates all instance variables

print(\

‘{: 06d}’.format(IMU.axRaw)\

, ‘\t’, ‘{: 06d}’.format(IMU.ayRaw)\

, ‘\t’, ‘{: 06d}’.format(IMU.azRaw)\

, ‘\t’, ‘{: 06d}’.format(IMU.gxRaw)\

, ‘\t’, ‘{: 06d}’.format(IMU.gyRaw)\

, ‘\t’, ‘{: 06d}’.format(IMU.gzRaw)\

, ‘\t’, ‘{: 06d}’.format(IMU.mxRaw)\

, ‘\t’, ‘{: 06d}’.format(IMU.myRaw)\

, ‘\t’, ‘{: 06d}’.format(IMU.mzRaw)\

, ‘\t’, ‘{: 06d}’.format(IMU.tmpRaw)\

)

time.sleep(0.03)

It’s not letting me upload a .jpg of my output screenshot, so I will just write the last row of output:

01088, -00080, 16792, -00240, -00130, -00078, -00437, -00357, 00371, 03088

Hi - sounds like you are able to get the raw values and just want to convert them to physical units…

Try these conversion functions from the Arduino library (you will have to re-write them in Python)

[getMagUT

[ getAccMG

[ getGyrDPS

[ getTempC](SparkFun_ICM-20948_ArduinoLibrary/src/ICM_20948.cpp at 4d5f843753ec01c0c16484c97b6d7b6e459d260d · sparkfun/SparkFun_ICM-20948_ArduinoLibrary · GitHub)](SparkFun_ICM-20948_ArduinoLibrary/src/ICM_20948.cpp at 4d5f843753ec01c0c16484c97b6d7b6e459d260d · sparkfun/SparkFun_ICM-20948_ArduinoLibrary · GitHub)](SparkFun_ICM-20948_ArduinoLibrary/src/ICM_20948.cpp at 4d5f843753ec01c0c16484c97b6d7b6e459d260d · sparkfun/SparkFun_ICM-20948_ArduinoLibrary · GitHub)](SparkFun_ICM-20948_ArduinoLibrary/src/ICM_20948.cpp at 4d5f843753ec01c0c16484c97b6d7b6e459d260d · sparkfun/SparkFun_ICM-20948_ArduinoLibrary · GitHub)