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)) print("") time.sleep(0.5)
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 lsm6ds_lsm6dsox_simpletest.py file to the Arduino Nano RP2040 Connect's CIRCUITPY drive. Then, rename lsm6ds_lsm6dsox_simpletest.py to code.py.
Your Arduino Nano RP2040 Connect CIRCUITPY drive should look like this after copying the lib folder and code.py file.