Home CodeCircuitpython Raspberry Pi Pico and Pico-10DOF-IMU circuitpython example

Raspberry Pi Pico and Pico-10DOF-IMU circuitpython example

by rp2040guy71

The Pico-10DOF-IMU is an IMU sensor expansion module which i sdesigned for the Raspberry Pi Pico. It has 2 sensors which provide gyroscope, accelerometer, magnetometer, baroceptor functionality and uses I2C bus for communication.

When you combine this module with the Raspberry Pi Pico, it can be used to collect environment sensing data like temperature and barometric pressure or you can create a robot that detects motion gestures and orientations.

  • 1) ICM20948
    • 9-axis motion sensor
  • 2) LPS22HB
    • barometric pressure sensor
  • 3) RT9193-33
    • 3.3V linear voltage regulator
  • 4) LSF0204PWR
    • 4-ch voltage translator
  • 5) RT9193-18
    • 1.8V linear voltage regulator
  • 6) Power indicator
  • 7) Raspberry Pi Pico header
    • For attaching to Raspberry Pi Pico, this is stackable – you can fit another module

Features

Raspberry Pi Pico header supports Raspberry Pi Pico series
Onboard ICM20948 (3-axis gyroscope, 3-axis accelerometer, and 3-axis magnetometer) for detecting motion gesture, orientation, and magnetic field
Onboard LPS22HB barometric pressure sensor, for sensing the atmospheric pressure of the environment

Specifications

Operating voltage: 5V

Accelerometer:

resolution: 16-bit
measuring range (configurable): ±2, ±4, ±8, ±16g
operating current: 68.9uA

Gyroscope:

resolution: 16-bit
measuring range (configurable): ±250, ±500, ±1000, ±2000°/sec
operating current: 1.23mA

Magnetometer:

resolution: 16-bit
measuring range: ±4900µT
operating current: 90uA

Baroceptor:

measuring range: 260 ~ 1260hPa
measuring accuracy (ordinary temperature): ±0.025hPa
measuring speed: 1Hz – 75Hz

Pinout

Parts Required

The sensor you can pick up in the $6 price range – you can connect to the sensor using a standard header the classic dupont style jumper wire.

I used a Qwiic cable – since a few sensors seem to use these but this is optional

 

Name Link
Pico Raspberry Pi Pico Development Board

Pico 10DOF IMU

Waveshare 10-DOF IMU Sensor Module For Raspberry Pi Pico, Onboard ICM20948 And LPS22HB Chip, an IMU sensor expansion module

 

Code

The module comes with a link with C++ and Micropython examples

Here are some circuitpython examples

I used Thonny for development

ICM20948 example

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

This is the basic example which comes with the library – slightly adapted

import time
import board
import adafruit_icm20x
import busio
 
# Create sensor object, communicating over the board's default I2C bus
i2c = busio.I2C(scl=board.GP7, sda=board.GP6)
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)

Here is the output

Acceleration: X:-0.25, Y: -0.10, Z: -9.84 m/s^2
Gyro X:0.02, Y: 0.01, Z: -0.01 rads/s
Magnetometer X:-38.55, Y: -46.95, Z: -63.15 uT

Acceleration: X:-6.62, Y: 0.85, Z: -5.85 m/s^2
Gyro X:1.97, Y: 8.73, Z: -1.01 rads/s
Magnetometer X:-6.00, Y: -47.55, Z: -64.35 uT

Acceleration: X:0.05, Y: 0.05, Z: -8.43 m/s^2
Gyro X:0.40, Y: -0.28, Z: 0.20 rads/s
Magnetometer X:-37.65, Y: -51.75, Z: -62.55 uT

LPS22HB Example

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

This is the basic example which comes with the library – slightly adapted

import time
import board
import adafruit_lps2x
import busio
 
# Create sensor object, communicating over the board's default I2C bus
i2c = busio.I2C(scl=board.GP7, sda=board.GP6)
lps = adafruit_lps2x.LPS22(i2c, 0x5C)
 
while True:
    print("Pressure: %.2f hPa" % lps.pressure)
    print("Temperature: %.2f C" % lps.temperature)
    time.sleep(1)

Here is the output

Pressure: 759.87 hPa
Temperature: 20.47 C
Pressure: 991.05 hPa
Temperature: 20.85 C
Pressure: 990.99 hPa
Temperature: 20.91 C
Pressure: 990.97 hPa
Temperature: 20.95 C

Links

You may also like

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