MicroPython ICM20948 Driver¶
ICM20948¶
MicroPython Driver for the ICM20948 Accelerometer/Gyro Sensor
Author(s): Jose D. Montoya
Implementation Notes¶
Software and Dependencies:
This library depends on Micropython
-
class micropython_icm20948.icm20948.ICM20948(i2c, address=
0x69)[source]¶ Main class for the Sensor
- Parameters:¶
- Raises:¶
RuntimeError – if the sensor is not found
Quickstart: Importing and using the device
Here is an example of using the
micropython_icm20948.ICM20948class. First you will need to import the libraries to use the sensorfrom machine import Pin, I2C import micropython_icm20948.icm20948 as icm20948Once this is done you can define your
machine.I2Cobject and define your sensor objecti2c = I2C(1, sda=Pin(2), scl=Pin(3)) icm = icm20948.ICM20948(i2c)Now you have access to the
accelerationattribute andgyroattributeaccx, accy, accz = icm.accelerometer gyro = icm.gyro- property acc_data_rate¶
The rate at which accelerometer measurements are taken in Hz
- property acc_data_rate_divisor : int¶
Accepted values are:
* 7* 10* 15* 22* 31* 63* 127* 255* 513* 1022* 2044* 4095
- property acc_dlpf_cutoff : int¶
The cutoff frequency for the accelerometer’s digital low pass filter. Signals above the given frequency will be filtered out.
Note
Readings immediately following setting a cutoff frequency will be inaccurate due to the filter “warming up”
Mode
Value
icm20948.FREQ_246_00b001icm20948.FREQ_111_40b010icm20948.FREQ_50_40b011icm20948.FREQ_23_90b100icm20948.FREQ_11_50b101icm20948.FREQ_5_70b110icm20948.FREQ_4730b111
- property acc_enabled : str¶
Accelerometer enabled
Mode
Value
icm20948.ACC_ENABLED0b000Accelerometer (all axes) onicm20948.ACC_DISABLED0b111Accelerometer (all axes) disabled
- property acceleration : tuple[float, float, float]¶
Acceleration Property. The x, y, z acceleration values returned in a 3-tuple and are in \(m / s ^ 2.\) :return: Acceleration Values
- property accelerometer_range : str¶
Sensor acceleration_range
Mode
Value
icm20948.RANGE_2G0b00icm20948.RANGE_4G0b01icm20948.RANGE_8G0b10icm20948.RANGE_16G0b11
- property clock_select¶
CLK_SELECT_INTERNAL: Internal 20 MHz oscillator CLK_SELECT_BEST: Auto selects the best available clock source - PLL if ready, else use the Internal oscillator CLK_SELECT_STOP: Stops the clock and keeps timing generator in reset NOTE: CLKSEL should be set to
CLK_SELECT_BESTto achieve full gyroscope performance.Mode
Value
icm20948.CLK_SELECT_INTERNAL0b000icm20948.CLK_SELECT_BEST0b001icm20948.CLK_SELECT_STOP0b111
- property gyro : tuple[float, float, float]¶
Gyro Property. The x, y, z angular velocity values returned in a 3-tuple and are in \(degrees / second\) :return: Angular velocity Values
- property gyro_data_rate¶
The rate at which gyro measurements are taken in Hz
- property gyro_data_rate_divisor : int¶
Accepted values are:
* 1* 2* 3* 4* 5* 7* 8* 10* 15* 16* 22* 31* 32* 63* 64* 255
- property gyro_dlpf_cutoff : int¶
The cutoff frequency for the gyro’s digital low pass filter. Signals above the given frequency will be filtered out.
Note
Readings immediately following setting a cutoff frequency will be inaccurate due to the filter “warming up”
Mode
Value
icm20948.G_FREQ_196_60b000icm20948.G_FREQ_151_80b001icm20948.G_FREQ_119_50b010icm20948.G_FREQ_51_20b011icm20948.G_FREQ_23_90b100icm20948.G_FREQ_11_60b101icm20948.G_FREQ_5_70b110icm20948.G_FREQ_361_40b111
- property gyro_enabled : str¶
Gyro Enabled
Mode
Value
icm20948.GYRO_ENABLED0b000Gyroscope (all axes) onicm20948.GYRO_DISABLED0b111Gyroscope (all axes) disabled
- property gyro_full_scale : str¶
Sensor gyro_full_scale
Mode
Value
icm20948.FS_250_DPS0b00icm20948.FS_500_DPS0b01icm20948.FS_1000_DPS0b10icm20948.FS_2000_DPS0b11
- property reset : int¶
Reset the internal registers and restores the default settings. Write a 1 to set the reset, the bit will auto clear