Qwiic SHIM Kit for Raspberry Pi Hookup Guide

Pages
Contributors: bboyho
Favorited Favorite 0

Example: ICM-20948 Readings

To start, there are basic examples written in Python for the ICM-20948 and SerLCD. We'll go over one for each to see if the Qwiic-enabled devices are working as expected.

Reading the Data with the ICM-20948

In your terminal window, type the following to download the basic example code from the GitHub repository. Otherwise, you can manually download the example code.

language:bash
git clone https://github.com/sparkfun/Qwiic_9DoF_IMU_ICM20948_Py

Then navigate to examples folder by entering the following command.

language:bash
cd Qwiic_9DoF_IMU_ICM20948_Py/examples

Using the ls command will list the examples in the folder. As of the writing from this tutorial, there's only one so we will enter the following command to run the example.

language:bash
python ex1_qwiic_ICM20948.py

You should see an output similar to image below. Depending on how the sensor is oriented, the values might be different. Moving the sensor around will change the raw values in the terminal window. The window will probably be too small and wrap around to the next row. To slow the output down, stop the code by typing CTRL + C and adjust the value for the delay after the print() function where it says time.sleep(0.03) to a larger number. Once the code has been adjusted, try running the code again.

9DoF Readings Through Terminal

You could also navigate to the example folder, open the example in Thonny, and hit the Run button. The readings will show up in the shell.

Thonny IDE 9DoF ICM20948 Readings