Raspberry Pi Pico and ICM-20948 MotionTracking device circuitpython example

In this article we connect a ICM-20948 9-axis MotionTracking device to a Raspberry Pi Pico running Circuitpython

Sensor Information

The ICM-20948 is the world’s lowest power 9-axis Motion Tracking device that is ideally suited for Smartphones, Tablets, Wearable Sensors, and IoT applications.

  • 1/3 the power of existing 9-axis devices
  • 3-axis gyroscope, 3-axis accelerometer, 3-axis compass, and a Digital Motion Processor™ (DMPTM) in a 3x3x1mm (24-pin QFN) package
  • DMP offloads computation of motion processing algorithms from the host processor, improving system power performance
  • Software drivers are fully compliant with Google’s latest Android release
  • EIS FSYNC support

ICM-20948 supports an auxiliary I2C interface to external sensors, on-chip 16-bit ADCs, programmable digital filters, an embedded temperature sensor, and programmable interrupts. The device features an operating voltage range down to 1.71V. Communication ports include I 2C and high speed SPI at 7MHz.

Features

• Lowest Power 9-Axis Device at 2.5 mW
• 3-Axis Gyroscope with Programmable FSR of ±250 dps, ±500 dps, ±1000 dps, and ±2000 dps
• 3-Axis Accelerometer with Programmable FSR of ±2g, ±4g, ±8g, and ±16g
• 3-Axis Compass with a wide range to ±4900 µT
• Onboard Digital Motion Processor (DMP)
• Android support
• Auxiliary I2C interface for external sensors
• On-Chip 16-bit ADCs and Programmable Filters
• 7 MHz SPI or 400 kHz Fast Mode I²C
• Digital-output temperature sensor
• VDD operating range of 1.71V to 3.6V

Parts Required

 

Name Link
Pico Raspberry Pi Pico Development Board
ICM20948 ICM-20948 Sensor Module Low Power 9 Axis MEMS Motion Tracking Device Sensor
Connecting cables Aliexpress link

Amazon.com link

Ebay link

 

Schematic/Connection

Black for GND
Red for V+
Blue for SDA
Yellow for SCL

So color coded for ease of use, this layout shows a connection to the module

rp2040 and ICM20948

Code Example

I used Thonny for development

The following is based on a library , I copied the adafruit_icm20x.mpy library for this device to the lib folder on my Raspberry Pi Pico – https://circuitpython.org/libraries

[codesyntax lang=”python”]

import time
import board
import busio
import adafruit_icm20x

# Create sensor object, using the board's default I2C bus.
i2c = busio.I2C(board.GP1, board.GP0)  # SCL, SDA
icm = adafruit_icm20x.ICM20948(i2c,0x68)

while True:
    print("Acceleration: X:%.2f, Y: %.2f, Z: %.2f m/s^2" % (icm.acceleration))
    print("Gyro X:%.2f, Y: %.2f, Z: %.2f rads/s" % (icm.gyro))
    print("Magnetometer X:%.2f, Y: %.2f, Z: %.2f uT" % (icm.magnetic))
    print("")
    time.sleep(0.5)

[/codesyntax]

Output

Here is what I saw in Thonny REPL window

Acceleration: X:-2.78, Y: -9.25, Z: 2.60 m/s^2
Gyro X:-0.03, Y: 0.00, Z: -0.01 rads/s
Magnetometer X:-23.55, Y: -56.40, Z: 27.00 uT

Acceleration: X:-2.77, Y: -9.26, Z: 2.67 m/s^2
Gyro X:-0.03, Y: 0.01, Z: 0.00 rads/s
Magnetometer X:-25.35, Y: -57.15, Z: 27.75 uT

Acceleration: X:-2.79, Y: -9.21, Z: 2.61 m/s^2
Gyro X:-0.03, Y: -0.00, Z: -0.01 rads/s
Magnetometer X:-23.10, Y: -57.75, Z: 27.60 uT

Links

https://invensense.tdk.com/wp-content/uploads/2016/06/DS-000189-ICM-20948-v1.3.pdf

Related posts

Raspberry Pi Pico and MMC5603 3-axis AMR magnetic sensor circuitpython example

Raspberry Pi Pico and LTR329 UV Light Sensor circuitpython example

Raspberry Pi Pico and LTR303 UV Light Sensor circuitpython example

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Read More