adafruit_icm20x
Library for the ST ICM20X Motion Sensor Family
Author(s): Bryan Siepert
Implementation Notes
Hardware:
Adafruit’s ICM20649 Breakout: https://adafruit.com/product/4464
Adafruit’s ICM20948 Breakout: https://adafruit.com/product/4554
Software and Dependencies:
Adafruit CircuitPython firmware for the supported boards: https://circuitpython.org/downloads
Adafruit’s Bus Device library: https://github.com/adafruit/Adafruit_CircuitPython_BusDevice
Adafruit’s Register library: https://github.com/adafruit/Adafruit_CircuitPython_Register
- class adafruit_icm20x.CV
struct helper
- classmethod is_valid(value: AccelRange | GyroRange | GyroDLPFFreq | AccelDLPFFreq) bool
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: I2C, address: int)
Library for the ST ICM-20X Wide-Range 6-DoF Accelerometer and Gyro Family
- Parameters:
- property acceleration: Tuple[float, float, float]
The x, y, z acceleration values returned in a 3-tuple and are in \(m / s ^ 2.\)
- property gyro: Tuple[float, float, float]
The x, y, z angular velocity values returned in a 3-tuple and are in \(radians / second\)
- property accelerometer_range: AccelRange
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
- property gyro_range: GyroRange
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
- property accelerometer_data_rate_divisor: int
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.
- property gyro_data_rate_divisor: int
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.
- property accelerometer_data_rate: float
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.
- property gyro_data_rate: float
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.
- property accel_dlpf_cutoff: AccelDLPFFreq
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 filterNote
Readings immediately following setting a cutoff frequency will be inaccurate due to the filter “warming up”
- property gyro_dlpf_cutoff: GyroDLPFFreq
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 filterNote
Readings immediately following setting a cutoff frequency will be inaccurate due to the filter “warming up”
- class adafruit_icm20x.ICM20649(i2c_bus: I2C, address: int = 104)
Library for the ST ICM-20649 Wide-Range 6-DoF Accelerometer and Gyro.
- Parameters:
Quickstart: Importing and using the ICM20649 temperature sensor
Here is an example of using the
ICM2020649class. First you will need to import the libraries to use the sensorimport board import adafruit_icm20x
Once this is done you can define your
board.I2Cobject and define your sensor objecti2c = board.I2C() # uses board.SCL and board.SDA icm = adafruit_icm20x.ICM20649(i2c)
Now you have access to the acceleration using
accelerationattribute and the gyro information using thegyroattribute.acceleration = icm.acceleration gyro = icm.gyro
- class adafruit_icm20x.MagDataRate
Options for
ICM20948.magnetometer_data_rate
- class adafruit_icm20x.ICM20948(i2c_bus: I2C, address: int = 105)
Library for the ST ICM-20948 Wide-Range 6-DoF Accelerometer and Gyro.
- Parameters:
Quickstart: Importing and using the ICM20948 temperature sensor
Here is an example of using the
ICM20948class. First you will need to import the libraries to use the sensorimport board import adafruit_icm20x
Once this is done you can define your
board.I2Cobject and define your sensor objecti2c = board.I2C() # uses board.SCL and board.SDA icm = adafruit_icm20x.ICM20948(i2c)
Now you have access to the acceleration using
accelerationattribute, the gyro information using thegyroattribute and the magnetic information using themagneticattributeacceleration = icm.acceleration gyro = icm.gyro magnetic = icm.magnetic
- property magnetic: Tuple[float, float, float]
The current magnetic field strengths on the X, Y, and Z axes in uT (micro-teslas)
- property magnetometer_data_rate: MagDataRate
The rate at which the magnetometer takes measurements to update its output registers