Skip to content

Python module for the SparkFun 9DoF IMU Breakout - ICM-20948 (Qwiic)

License

Notifications You must be signed in to change notification settings

sparkfun/Qwiic_9DoF_IMU_ICM20948_Py

Repository files navigation

Qwiic_9DoF_IMU_ICM20948_Py

follow on Twitter

SparkFun 9DoF IMU Breakout - ICM-20948 (Qwiic)

Python module for the qwiic ICM-20948 sensor, which is included on the SparkFun 9DoF IMU Breakout - ICM-20948 (Qwiic)

This python package is a port of the existing SparkFun ICM-20948 Arduino Library

This package can be used in conjunction with the overall SparkFun qwiic Python Package

New to qwiic? Take a look at the entire SparkFun qwiic ecosystem.

Contents

Supported Platforms

The qwiic ICM20948 Python package current supports the following platforms:

Dependencies

This driver package depends on the qwiic I2C driver: Qwiic_I2C_Py

Documentation

The SparkFun qwiic ICM20948 module documentation is hosted at ReadTheDocs

Installation

PyPi Installation

This repository is hosted on PyPi as the sparkfun-qwiic-icm20948 package. On systems that support PyPi installation via pip, this library is installed using the following commands

For all users (note: the user must have sudo privileges):

sudo pip install sparkfun-qwiic-icm20948

For the current user:

pip install sparkfun-qwiic-icm20948

Local Installation

To install, make sure the setuptools package is installed on the system.

Direct installation at the command line:

python setup.py install

To build a package for use with pip:

python setup.py sdist

A package file is built and placed in a subdirectory called dist. This package file can be installed using pip.

cd dist
pip install sparkfun_qwiic_icm20948-<version>.tar.gz
  

Example Use

See the examples directory for more detailed use examples.

from __future__ import print_function
import qwiic_icm20948
import time
import sys

def runExample():

	print("\nSparkFun 9DoF ICM-20948 Sensor  Example 1\n")
	IMU = qwiic_icm20948.QwiicIcm20948()

	if IMU.connected == False:
		print("The Qwiic ICM20948 device isn't connected to the system. Please check your connection", \
			file=sys.stderr)
		return

	IMU.begin()

	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)\
			)
			time.sleep(0.03)
		else:
			print("Waiting for data")
			time.sleep(0.5)

if __name__ == '__main__':
	try:
		runExample()
	except (KeyboardInterrupt, SystemExit) as exErr:
		print("\nEnding Example 1")
		sys.exit(0)

SparkFun - Start Something

About

Python module for the SparkFun 9DoF IMU Breakout - ICM-20948 (Qwiic)

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages