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.

You can access the code by downloading the Project Bundle. To do this, click on the Download Project Bundle button in the window below. It will download as a zipped folder.

# 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
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))

Upload the Code and Libraries to the Arduino Nano RP2040 Connect

After downloading the Project Bundle, plug your board into the computer USB port. You should see a new flash drive appear in the computer's File Explorer or Finder (depending on your operating system) called CIRCUITPY. Unzip the folder and copy the lib folder and file to the Arduino Nano RP2040 Connect's CIRCUITPY drive. Then, rename to

Your Arduino Nano RP2040 Connect CIRCUITPY drive should look like this after copying the lib folder and file.

This guide was first published on Jun 04, 2021. It was last updated on 2021-06-04 14:46:06 -0400.

This page (Accelerometer/Gyroscope) was last updated on May 24, 2022.

Text editor powered by tinymce.