# (Where) is Qwiic demo code available (such as from the webinar)?

**URL:** <https://xrp.discourse.group/t/where-is-qwiic-demo-code-available-such-as-from-the-webinar/101>\
**Category:** Python programming\
**Created:** [October 22, 2023, 8:04pm UTC](https://xrp.discourse.group/t/where-is-qwiic-demo-code-available-such-as-from-the-webinar/101 "2023-10-22T20:04:26Z")\
**Posts on this page:** 1\
**Showing post:** 6

<div class="post-metadata">

**Author:** ![SparkFro](https://yyz1.discourse-cdn.com/flex011/user_avatar/xrp.discourse.group/sparkfro/32/12_2.png) [@SparkFro](https://xrp.discourse.group/u/SparkFro)\
**Post date:** [October 27, 2023, 8:48pm UTC](https://xrp.discourse.group/t/where-is-qwiic-demo-code-available-such-as-from-the-webinar/101/6 "2023-10-27T20:48:06Z")

</div>

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

1. In [XRPCode](https://xrpcode.wpi.edu/), connect to the XRP. In the filesystem browser, right-click the `lib/` folder and click New Folder. Name it `qwiic_i2c`.
2. Download 3 files from the [Qwiic\_I2C\_Py package](https://github.com/sparkfun/Qwiic_I2C_Py/tree/master/qwiic_i2c): ` __init__.py`, `i2c_driver.py`, and `micropython_i2c.py`
3. 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.
4. Download [` __future__.py` from here](https://github.com/micropython/micropython-lib/blob/master/python-stdlib/ __future__ / __future__.py) 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.
5. (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

1. Find the Python driver for the device(s) you want to use in [this list of drivers](https://github.com/sparkfun/Qwiic_Py/tree/main/qwiic/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).

2. 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](https://github.com/sparkfun/Qwiic_Relay_Py/tree/main), download [`qwiic_relay.py`](https://github.com/sparkfun/Qwiic_Relay_Py/blob/main/qwiic_relay.py))
3. 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.
4. (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 😉):

```auto
# 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!

---

_[View the full topic](https://xrp.discourse.group/t/where-is-qwiic-demo-code-available-such-as-from-the-webinar/101)._
