# adafruit_icm20x¶

Library for the ST ICM20X Motion Sensor Family

• Author(s): Bryan Siepert

## Implementation Notes¶

Hardware:

Software and Dependencies:

class adafruit_icm20x.CV

struct helper

classmethod add_values(value_tuples)

Add CV values to the class

classmethod is_valid(value)

Validate that a given value is a member

class adafruit_icm20x.AccelRange

Options for ICM20X.accelerometer_range

class adafruit_icm20x.GyroRange

Options for ICM20X.gyro_data_range

class adafruit_icm20x.GyroDLPFFreq

Options for ICM20X.gyro_dlpf_cutoff

class adafruit_icm20x.AccelDLPFFreq

Options for ICM20X.accel_dlpf_cutoff

class adafruit_icm20x.ICM20X(i2c_bus, address)

Library for the ST ICM-20X Wide-Range 6-DoF Accelerometer and Gyro Family

Parameters: i2c_bus (I2C) – The I2C bus the ICM20X is connected to. address (int) – The I2C address of the device.
initialize()

Configure the sensors with the default settings. For use after calling reset()

reset()

Resets the internal registers and restores the default settings

acceleration

The x, y, z acceleration values returned in a 3-tuple and are in $$m / s ^ 2.$$

gyro

The x, y, z angular velocity values returned in a 3-tuple and are in $$degrees / second$$

accelerometer_range

Adjusts the range of values that the sensor can measure, from +/- 4G to +/-30G Note that larger ranges will be less accurate. Must be an AccelRange

gyro_range

Adjusts the range of values that the sensor can measure, from 500 Degrees/second to 4000 degrees/s. Note that larger ranges will be less accurate. Must be a GyroRange

accelerometer_data_rate_divisor

The divisor for the rate at which accelerometer measurements are taken in Hz

Note

The data rates are set indirectly by setting a rate divisor according to the following formula:

$\text{accelerometer_data_rate} = \frac{1125}{1 + divisor}$

This function sets the raw rate divisor.

gyro_data_rate_divisor

The divisor for the rate at which gyro measurements are taken in Hz

Note

The data rates are set indirectly by setting a rate divisor according to the following formula:

$\text{gyro_data_rate} = \frac{1100}{1 + divisor}$

This function sets the raw rate divisor.

accelerometer_data_rate

The rate at which accelerometer measurements are taken in Hz

Note

The data rates are set indirectly by setting a rate divisor according to the following formula:

$\text{accelerometer_data_rate} = \frac{1125}{1 + divisor}$

This function does the math to find the divisor from a given rate but it will not be exactly as specified.

gyro_data_rate

The rate at which gyro measurements are taken in Hz

Note

The data rates are set indirectly by setting a rate divisor according to the following formula:

$\text{gyro_data_rate } = \frac{1100}{1 + divisor}$

This function does the math to find the divisor from a given rate but it will not be exactly as specified.

accel_dlpf_cutoff

The cutoff frequency for the accelerometer’s digital low pass filter. Signals above the given frequency will be filtered out. Must be an AccelDLPFCutoff. Use AccelDLPFCutoff.DISABLED to disable the filter

Note

Readings immediately following setting a cutoff frequency will be inaccurate due to the filter “warming up”

gyro_dlpf_cutoff

The cutoff frequency for the gyro’s digital low pass filter. Signals above the given frequency will be filtered out. Must be a GyroDLPFFreq. Use GyroDLPFCutoff.DISABLED to disable the filter

Note

Readings immediately following setting a cutoff frequency will be inaccurate due to the filter “warming up”

class adafruit_icm20x.ICM20649(i2c_bus, address=104)

Library for the ST ICM-20649 Wide-Range 6-DoF Accelerometer and Gyro.

Parameters: i2c_bus (I2C) – The I2C bus the ICM20649 is connected to. address (int) – The I2C address of the device. Defaults to 0x68

Quickstart: Importing and using the ICM20649 temperature sensor

Here is an example of using the ICM2020649 class. First you will need to import the libraries to use the sensor

import board


Once this is done you can define your board.I2C object and define your sensor object

i2c = board.I2C()   # uses board.SCL and board.SDA


Now you have access to the acceleration using acceleration attribute and the gyro information using the gyro attribute.

acceleration = icm.acceleration
gyro = icm.gyro

class adafruit_icm20x.MagDataRate

Options for ICM20948.magnetometer_data_rate

class adafruit_icm20x.ICM20948(i2c_bus, address=105)

Library for the ST ICM-20948 Wide-Range 6-DoF Accelerometer and Gyro.

Parameters: i2c_bus (I2C) – The I2C bus the ICM20948 is connected to. address (int) – The I2C address of the device. Defaults to 0x69

Quickstart: Importing and using the ICM20948 temperature sensor

Here is an example of using the ICM20948 class. First you will need to import the libraries to use the sensor

import board


Once this is done you can define your board.I2C object and define your sensor object

i2c = board.I2C()   # uses board.SCL and board.SDA


Now you have access to the acceleration using acceleration attribute, the gyro information using the gyro attribute and the magnetic information using the magnetic attribute

acceleration = icm.acceleration
gyro = icm.gyro
magnetic = icm.magnetic

magnetic

The current magnetic field strengths onthe X, Y, and Z axes in uT (micro-teslas)

magnetometer_data_rate

The rate at which the magnetometer takes measurements to update its output registers