I’d like to make use of the Qwiic interface within my MicroPython scripts.
IIRC during the webinar there were demonstrations of several sample programs that used the Qwiic interface. Is the code for those demos available? If so, where can I find that demo code, hardware details, etc.?
Are there other resources for Qwiic programming on the XRP? I looked in the getting started doc and the WPI intro to robotics v2 course materials, and skimmed through the XRPLib documentation and did not see that covered, but perhaps I have somehow missed it.
The stuff we demoed during the DigiKey webinar was from our initial testing, but we’re actively working on a solution that should make it easy to use Qwiic products with the XRP in MicroPython. This is planned for the next software release of the XRP. If you’re eager to get started, the final implementation is planned to use this Python I2C driver package along with almost any of the Qwiic device drivers here. You’ll have to manually install the correct files into the /lib/ folder of the XRP. Do note that if you decide to do this yourself right now, some things may be broken, and there will be limited support until the official software release.
Edit: see my next post for more detailed instructions on how to do this. Again, some things may not work, and support will be limited.
Thank you for sharing your project with the community! While you go into great detail on some aspects of the project, your description of auxiliary board brackets is pretty brief:
I modified the file for the line-follower sensor mount in Fusion 360 to create snap-fit mounts for these two boards. The STL files for these can be found here: XRP Accessory Mounts by DigiKey - Thingiverse. These mounts snap into the rail system on the robot, so they are very easy to move around to fit new components as needed.
I appreciate the .STL files at Thingiverse but want to learn how to make my own design modifications, too. Did you start from the .STL files at Printables or did you start with the original Solidworks CAD files?
For those who want to dive into using Qwiic devices right now, here’s a quick set of instructions that should get you up and running. This is along the lines of how we’re planning to implement it in the next software release (subject to change), except the installation process should be automated once finalized. Please understand that if you choose to do this before the next software release, some things may not work and there will be limited support.
Add Qwiic_I2C_Py Driver
In XRPCode, connect to the XRP. In the filesystem browser, right-click the lib/ folder and click New Folder. Name it qwiic_i2c.
Download 3 files from the Qwiic_I2C_Py package: __init__.py, i2c_driver.py, and micropython_i2c.py
Upload those 3 files to the qwiic_i2c/ folder created in step 1. In XRPCode, click File → Upload to XRP, select the 3 files from your computer (can select all at the same time), then select the qwiic_i2c/ folder on the XRP. The files will be uploaded.
Download __future__.py from here and upload it to the lib/ folder on the XRP. This is needed because the Qwiic_I2C_Py package has backwards compatibility with Python 2, but MicroPython doesn’t include __future__ by default. This is just a dummy implementation that helps prevent things from breaking.
(Optional, to verify installation) In the shell window at the bottom of XRPCode, type import qwiic_i2c, then i2cDriver = qwiic_i2c.getI2CDriver(), then i2cDriver.scan(). If all goes well, there should be no errors, and it should print [107] (that’s the decimal I2C address of the IMU on the control board).
Add Qwiic Device Drivers
Find the Python driver for the device(s) you want to use in this list of drivers.
Not all of these have been tested in MicroPython. If you discover a problem, please create an issue in the corresponding repository.
Not all Qwiic devices are included in this list. If there’s a device you’d like to have added, please post something on this Discourse thread (we may have a better place for posting these requests in the future, but here is fine for now).
Download the device driver library from the corresponding repository. This is typically a single .py file in the root directory of the repo that closely matches the repo name (eg. in the Qwiic_Relay_Py repo, download qwiic_relay.py)
Upload the device driver files to the lib/ folder on the XRP. In XRPCode, click File → Upload to XRP, select the device driver files from your computer (can select all at the same time), then select the lib/ folder on the XRP. The files will be uploaded.
(Optional) Also download the examples from the device driver repo (in the examples/ folder, grab whichever ones you want) and upload those to the XRP (put them wherever you want, use the root / directory if you’re not sure). You should be able to open these in XRPCode and click the Run button to test them.
Add Qwiic to Your Code
The Qwiic device drivers are all structured similarly to each other, and are designed to be fairly simple to use. For example, here’s the minimum code needed to use the Qwiic Single Relay (because @dangarlen asked ):
# Set up the device, do this once in your code (very similar structure for all Qwiic devices)
import qwiic_relay
myRelay = qwiic_relay.QwiicRelay()
myRelay.begin()
# Use the device (usage differs between devices)
myRelay.set_relay_on()
myRelay.set_relay_off()
Assuming all goes well, this should be enough to get started with Qwiic on the XRP ahead of the official software release. Again, please be aware that some things may not work, and there will be limited support until the official software release. The instructions here are just brief guidance for users who are eager to play with Qwiic devices right now. Hope this helps!
Sorry I missed your post until today. To make the modified brackets, I downloaded the reflectance sensor bracket from Printables and loaded the .3MF file into Fusion 360. From there I converted the mesh over to a solid body. From there, I split the body right in the center and moved the two halves apart to the desired distance and then extruded back to connect the two halves. Here is a rough sketch of where i split the bracket.
Thanks for this explanation. As a relatively new user of Fusion 360, I slowly worked my way through this process and successfully designed and printed a new board bracket that meets my needs. However, there must be a better way for less experienced 3d designers to modify parts to meet their needs.
P.S. A new XRP is out for delivery today. Thanks for your help with that, too.