Python
Attention
If this is your first time working with Python, there are quite a few useful tutorials on getting started. The Python Programming Section of our Getting Started with the Raspberry Pi Tutorial has some good basic information and resources for getting started with Python.
Linux/Raspberry Pi Variants
We've written a python package to get you started with the SparkFun Optical Tracking Odometry Sensor. It's been included in the SparkFun Qwiic Python package, which aggregates all Python Qwiic drivers/modules to provide a single entity for Qwiic within a Python environment. The Qwiic_Py GitHub Library ReadMe has more information on the Qwiic Python package.
If you already have your Qwiic Python package installed, you can update it with the following command:
If you don't have the Qwiic Python package installed already, you can install it with the following command:
If you prefer to install just this package, use the following command:
If you prefer downloading the code to build and install the package manually, you can grab them from the GitHub Repository.
Attention
If you are working with a Raspberry Pi and are using the new Bookworm distribution of the Raspberry Pi OS, refer to these instructions to setup a virtual environment.
Make sure to include the --system-site-packages flag:python3 -m venv
Then it is possible to install the packages using pip.
XRP/MicroControllers
If you are working with the XRP or other microcontroller, pip will not work for you. Instead, you'll need to install the Qwiic_I2C_Py driver as well as the Qwiic_OTOS driver.
Attention
These instructions are written for the XRP using the XRPCode IDE. However the setup process is very similar for MicroPython and CircuitPython on any other board, so you should be able to follow along with these instructions using your IDE of choice!
Install Qwiic_I2C_Py
Qwiic_I2C_Py is a generic I2C driver we have created to work on various platforms (such as MicroPython). Our Qwiic Python device drivers take advantage of Qwiic_I2C_Py to function correctly on any of the supported platforms, so it is a required dependency to use our OTOS Python driver.
Fist, go to the Qwiic_I2C_Py repository and download it as a .zip file. Once downloaded, extract the qwiic_i2c
folder within.
Connect your XRP to your computer over USB, navigate to the XRPCode IDE, and connect to your XRP. For usage information, see the XRPCode User Guide.
Create a new folder within the lib
directory (right-click on the folder), and name it qwiic_i2c
.
Upload the files from the previously extracted qwiic_i2c
folder into the new folder you just created on the XRP. From the File menu, choose the Upload to XRP option:
Then select the extracted files:
Then choose the newly created qwiic_i2c
folder on the XRP:
Uploading...
You can test to confirm correct installation by typing import qwiic_i2c
followed by qwiic_i2c.get_i2c_driver().scan()
in the Shell. If no errors are printed, then the Qwiic_I2C_Py driver has been installed correctly!
Install Qwiic_OTOS_Py
Fist, go to the Qwiic_OTOS_Py repository and download just the qwiic_otos.py
file.
Connect your XRP to your computer over USB, navigate to the XRPCode editor, and connect to your XRP. For usage information, see the XRPCode User Guide.
Upload the qwiic_otos.py
file into the lib
folder on the XRP. From the File menu, choose the Upload to XRP option:
Select the qwiic_otos.py file:
Then select the lib folder on the XRP:
Updating...
You can test to confirm correct installation by typing import qwiic_otos
followed by qwiic_otos.QwiicOTOS().is_connected()
in the Shell. If no errors are printed, then the Qwiic_OTOS_Py driver has been installed correctly!
Testing the install:
Visualization
In addition to the package provided here, we have written a Python script that allows you to visualize the XRP in real time. Download via the button below.