The Arduino Nano RP2040 Connect has an onboard IMU (inertial measurement unit), the LSM6DSOXTR, which can measure accelerometer and gyroscope data. There is a CircuitPython library for this sensor. You can use the example code from the library to begin logging movement data for your projects.
In the example below, click the Download Project Bundle button below to download the necessary libraries and the code.py file in a zip file. Extract the contents of the zip file, open the directory examples/ and then click on the directory that matches the version of CircuitPython you're using and copy the contents of that directory to your CIRCUITPY drive.
CIRCUITPY drive should now look similar to the following image:

# SPDX-FileCopyrightText: Copyright (c) 2020 Bryan Siepert for Adafruit Industries # # SPDX-License-Identifier: MIT import time import board from adafruit_lsm6ds.lsm6dsox import LSM6DSOX i2c = board.I2C() # uses board.SCL and board.SDA # i2c = board.STEMMA_I2C() # For using the built-in STEMMA QT connector on a microcontroller sensor = LSM6DSOX(i2c) while True: print("Acceleration: X:%.2f, Y: %.2f, Z: %.2f m/s^2" % (sensor.acceleration)) print("Gyro X:%.2f, Y: %.2f, Z: %.2f radians/s" % (sensor.gyro)) print("") time.sleep(0.5)
Page last edited January 22, 2025
Text editor powered by tinymce.