# CircuitPython Libraries on any Computer with MCP2221

## Overview

![](https://cdn-learn.adafruit.com/assets/assets/000/086/358/medium800/sensors_4471_top_ORIG_2019_12.jpg?1577054356)

This guide will show you how to use an MCP2221(A) to connect to I2C sensors and breakouts from your desktop PC running Windows, Mac OSX, or Linux. The MCP2221 also allows for general purpose digital input and output (GPIO) for things like buttons and LEDs, analog to digital conversion (ADC), and digital to analog (DAC).

The cool part about this is that you can then use any of the CircuitPython Libraries that have been written for the numerous I2C sensors and breakouts. You can bring that data directly into your PC for any kind of powerful analysis or presentation.

Info: 

## CircuitPython and CircuitPython Libraries

As you are going through this guide, keep in mind the difference between CircuitPython and CircuitPython Libraries:

- **CircuitPython** - a microprocessor specific implementation of Python written in C. [Here's the source code](https://github.com/adafruit/circuitpython). And here's the [main CircuitPython guide](https://learn.adafruit.com/welcome-to-circuitpython).
- **CircuitPython Libraries** - sensor and breakout specific code written in Python using the CircuitPython hardware API. There are a lot of these - [check out the bundle](https://github.com/adafruit/Adafruit_CircuitPython_Bundle).

There are various hardware combinations that allow for running CircuitPython and CircuitPython Libraries. In this guide we will **not** be using the actual CircuitPython firmware. But we will be using CircuitPython Libraries.

## CircuitPython Libraries on Personal Computers

This is essentially the same idea as discussed&nbsp; in the [FT232H Guide](https://learn.adafruit.com/circuitpython-on-any-computer-with-ft232h/overiew). How can we directly connect common hardware items like buttons and I2C breakouts to a PC?

![](https://cdn-learn.adafruit.com/assets/assets/000/085/902/medium800/sensors_board_pc.png?1576619897)

The MCP2221 provides another way to do this by utilizing the USB bus. The MCP2221 just makes different trade offs relative to the FT232H. The biggest being **no hardware SPI support**. But you do gain ADC and DAC support. Also, it's much cheaper than the FT232H.

So you end up with something like this:

![](https://cdn-learn.adafruit.com/assets/assets/000/085/901/medium800/sensors_usb_to_mcp2221.png?1576619527)

Great! Let's get everything setup so we can actually do some fun stuff.

### Adafruit MCP2221A Breakout - General Purpose USB to GPIO ADC I2C

[Adafruit MCP2221A Breakout - General Purpose USB to GPIO ADC I2C](https://www.adafruit.com/product/4471)
Wouldn't it be cool to drive a [tiny&nbsp;OLED display](https://www.adafruit.com/categories/98), read a [color...](https://www.adafruit.com/products/1334)

In Stock
[Buy Now](https://www.adafruit.com/product/4471)
[Related Guides to the Product](https://learn.adafruit.com/products/4471/guides)
![Adafruit MCP2221A Breakout - General Purpose USB to GPIO ADC I2C connected to a computer with an IMU sensor that is streaming data to some graphing program](https://cdn-shop.adafruit.com/product-videos/640x480/4471-04.jpg)

# CircuitPython Libraries on any Computer with MCP2221

## Running CircuitPython Code without CircuitPython

There are two parts to the CircuitPython ecosystem:

- **CircuitPython firmware** , written in C and built to run on various microcontroller boards (not PCs). The firmware includes the CircuitPython interpreter, which reads and executes CircuitPython programs, and chip-specific code that controls the hardware peripherals on the microcontroller, including things like USB, I2C, SPI, GPIO pins, and all the rest of the hardware features the chip provides.
- **CircuitPython libraries,** written in Python to use the native (built into the firmware) modules provided by CircuitPython to control the microcontroller peripherals and interact with various breakout boards.

But suppose you'd like to use CircuitPython **libraries** on a board or computer that does not have a native CircuitPython **firmware** build. For example, on a PC running Windows or macOS. Can that be done? The answer is yes, via a separate piece of software called **Blinka**. Details about Blinka follow, however it is important to realize that the **CircuitPython firmware is never used**.

Info: 

# Adafruit Blinka: a CircuitPython Compatibility Library

Enter **Adafruit**  **Blinka**. Blinka is a software library that emulates the parts of CircuitPython that control hardware. Blinka provides non-CircuitPython implementations for `board`, `busio`, `digitalio`, and other native CircuitPython modules. You can then write Python code that looks like CircuitPython and uses CircuitPython libraries, without having CircuitPython underneath.

There are multiple ways to use Blinka:&nbsp;

- Linux based Single Board Computers, for example a Raspberry Pi
- Desktop Computers + specialized USB adapters
- Boards running MicroPython

More details on these options follow.

## Raspberry Pi and Other Single-Board Linux Computers

On a Raspberry Pi or other single-board Linux computer, you can use Blinka with the regular version of Python supplied with the Linux distribution. Blinka can control the hardware pins these boards provide.

## Desktop Computers&nbsp;

On Windows, macOS, or Linux desktop or laptop ("host") computers, you can use special USB adapter boards that that provide hardware pins you can control. These boards include [MCP221A](https://learn.adafruit.com/circuitpython-libraries-on-any-computer-with-mcp2221)&nbsp;and [FT232H](https://learn.adafruit.com/adafruit-ft232h-breakout) breakout boards, and [Raspberry Pi Pico boards running the **u2if** software](https://learn.adafruit.com/circuitpython-libraries-on-any-computer-with-raspberry-pi-pico). These boards connect via regular USB to your host computer, and let you do GPIO, I2C, SPI, and other hardware operations.

## MicroPython

You can also use Blinka with MicroPython, on [MicroPython-supported boards](https://learn.adafruit.com/circuitpython-libraries-on-micropython-using-the-raspberry-pi-pico). Blinka will allow you to import and use CircuitPython libraries in your MicroPython program, so you don't have to rewrite libraries into native MicroPython code. Fun fact - this is actually the original use case for Blinka.

# Installing Blinka

Installing Blinka on your particular platform is covered elsewhere in this guide. The process is different for each platform. Follow the guide section specific to your platform and make sure Blinka is properly installed before attempting to install any libraries.

Info: 

# Installing CircuitPython Libraries

Once Blinka is installed the next step is to install the CircuitPython libraries of interest. How this is down is different for each platform. Here are the details.

## Linux Single-Board Computers

On Linux single-board computers, such as Raspberry Pi, you'll use the Python `pip3`&nbsp;program (sometimes named just `pip`) to install a library. The library will be downloaded from [pypi.org](https://pypi.org) automatically by `pip3`.

How to install a particular library using `pip3` is covered in the guide page for that library. For example, [here is the `pip3` installation information](https://learn.adafruit.com/adafruit-lis3dh-triple-axis-accelerometer-breakout/python-circuitpython#python-installation-of-lis3dh-library-2997958) for the library for the LIS3DH accelerometer.

The library name you give to `pip3` is usually of the form `adafruit-circuitpython-libraryname`. This is not the name you use with `import`. For example, the LIS3DH sensor library is known by several names:

- The GitHub library repository is [Adafruit\_CircuitPython\_LIS3DH](https://github.com/adafruit/Adafruit_CircuitPython_LIS3DH).
- When you import the library, you write `import adafruit_lis3dh`.
- The name you use with `pip3` is `adafruit-circuitpython-lis3dh`. This the name used on [pypi.org](https://pypi.org).

Libraries often depend on other libraries. When you install a library with `pip3`, it will automatically install other needed libraries.

## Desktop Computers using a USB Adapter

When you use a desktop computer with a USB adapter, like the MCP2221A, FT232H, or u2if firmware on an RP2040, you will also use pip3. However, **do _not_ install the library with `sudo pip3`** , as mentioned in some guides. Instead, just install with `pip3`.&nbsp;

## MicroPython

For MicroPython, you will not use `pip3`. Instead you can get the library from the CircuitPython bundles. See [this guide page](https://learn.adafruit.com/welcome-to-circuitpython/circuitpython-libraries) for more information about the bundles, and also see the [Libraries page on circuitPython.org](https://circuitpython.org/libraries).

# CircuitPython Libraries on any Computer with MCP2221

## Setup

The support for the MCP2221 in Blinka utilizes the [hidapi library](https://pypi.org/project/hidapi/). This in turn relies on a few other things which vary for different OS's. So before we can actually use the MCP2221, we need to get everything setup. See the OS specific sections for what we went through to get things working for each.

## Additional Information

Just for reference, here's the README from the hidapi source code repo, which has some install information:

[hidapi README](https://github.com/trezor/cython-hidapi/blob/master/README.rst)
 **But first try the install instructions on the pages that follow for your OS.**

# CircuitPython Libraries on any Computer with MCP2221

## Windows

# Have Python 3 Installed

We assume you already have Python 3 installed on your computer. **Note we do not support Python 2** - it's deprecated and no longer supported!

At your command line prompt of choice, check your Python version with `python --version`

![](https://cdn-learn.adafruit.com/assets/assets/000/086/166/medium800/sensors_image.png?1576862171)

# Install hidapi

From the command line, manually install **hidapi** with

```python
pip3 install hidapi
```

![](https://cdn-learn.adafruit.com/assets/assets/000/086/167/medium800/sensors_image.png?1576862364)

If the install fails with text that ends with something like:

> distutils.errors.DistutilsError: Setup script exited with error: Microsoft Visual C++ 14.0 is required. Get it with "Microsoft Visual C++ Build Tools": [https://visualstudio.microsoft.com/downloads/](https://visualstudio.microsoft.com/downloads/)

then you will need to also install the Microsoft Visual C++ Build Tools. Thanks to **@jklem** for pointing this out [in the forums](https://forums.adafruit.com/viewtopic.php?f=19&t=161344#p793969).

Download it from here (same link as in text):

[Microsoft Visual Studio Downloads](https://visualstudio.microsoft.com/downloads/)
 **NOTE: You do not need the full Visual Studio IDE. Just the Build Tools.**

- Scroll down to where it says **Tools for Visual Studio 2019**.
- Expand the list to show the sub options.
- Click the Download button for **Build Tools for Visual Studio 2019**.

![sensors_build_tools.jpg](https://cdn-learn.adafruit.com/assets/assets/000/089/173/medium640/sensors_build_tools.jpg?1583878908)

This downloads a .exe file with a name like **vs\_BuildTools.exe**. Run that to install the build tools and then try the pip install again.

## Install Blinka

To install Blinka and its dependencies, run:

```python
pip3 install adafruit-blinka
```

![](https://cdn-learn.adafruit.com/assets/assets/000/086/168/medium800/sensors_image.png?1576862425)

# Set Environment Variable

You must do this every time before running circuitpython code, you can set it permanently in windows if you like, for now just type into the same cmd window you're using with Python

`set BLINKA_MCP2221=1`

![](https://cdn-learn.adafruit.com/assets/assets/000/086/169/medium800/sensors_image.png?1576862520)

If you are using Windows Powershell, the syntax is a little different. In that case do:

`$env:BLINKA_MCP2221=1`

Info: 

# Check Platform was detected

In the same command window you `set BLINKA_MCP2221=1` env var, run `python` and run

`import boarddir(board)```

at the Python REPL. If you get no errors, and you see a list of all the pins available - you're good to go!

![](https://cdn-learn.adafruit.com/assets/assets/000/086/177/medium800/sensors_image.png?1576863500)

# CircuitPython Libraries on any Computer with MCP2221

## Mac OSX

# Python 3 Check

We assume you already have Python 3 installed on your computer.&nbsp; **Note we do not support Python 2** &nbsp;- it's deprecated and no longer supported!

At your command line prompt of choice, check your Python version with&nbsp;`python3 --version`

![](https://cdn-learn.adafruit.com/assets/assets/000/086/361/medium800/sensors_1__fish___Users_brentrubell__fish_.png?1577117311)

# Install hidapi

From the command line, manually install [hidapi](https://github.com/signal11/hidapi) with:

```python
pip3 install hidapi
```

![](https://cdn-learn.adafruit.com/assets/assets/000/086/362/medium800/sensors_1__fish___Users_brentrubell__fish_.png?1577117387)

# Install Blinka

To install [Blinka](https://github.com/adafruit/Adafruit_Blinka) and its dependencies, run:

```python
pip3 install adafruit-blinka
```

![](https://cdn-learn.adafruit.com/assets/assets/000/086/363/medium800/sensors_blinka_mcp_install.png?1577117473)

# Set Environment Variable&nbsp;

You'll need to set this variable every time before running CircuitPython code. To do this, we set the environment variable to BLINKA\_MCP2221.,

You can set the variable by running:

```python
export BLINKA_MCP2221="1"
```

Then, verify that the variable is set by running:

```python
echo $BLINKA_MCP2221
```

![](https://cdn-learn.adafruit.com/assets/assets/000/086/364/medium800/sensors_1__bash___Users_brentrubell__bash_.png?1577118375)

Danger: 

# Check that Platform was detected

In the same terminal window you ran `export BLINKA_MCP2221="1"`, run `python3`.

At the REPL, run:

`import board`

`dir(board)`

![](https://cdn-learn.adafruit.com/assets/assets/000/086/365/medium800/sensors_1__bash___Users_brentrubell__python3_6_.png?1577118577)

If you get no errors and see a list of all the pins available, you're good to go!

# CircuitPython Libraries on any Computer with MCP2221

## Linux

The following shows a typical run through installing and setting things up on Linux.

## Install libusb and libudev

Run the following to install required libraries:

```none
sudo apt-get install libusb-1.0 libudev-dev
```

and answer **Y** to the prompt. This should install libusb and libudev.

## Setup udev rules

A udev rule is needed to adjust the permissions to allow non-root access to the MCP2221. This is just a text file. Use a text editor to create and edit the file **/etc/udev/rules.d/99-mcp2221.rules** and add the following contents.

The specific udev rule syntax that works may vary with linux distribution. This is the original udev rule that worked at the time this guide was first written:

```python
SUBSYSTEM=="usb", ATTRS{idVendor}=="04d8", ATTR{idProduct}=="00dd", MODE="0666"
```

If the [Post Install Checks](https://learn.adafruit.com/circuitpython-libraries-on-any-computer-with-mcp2221/post-install-checks) fail with a "open failed" message for the MCP2221, then try changing to this udev rule:

```auto
SUBSYSTEMS=="usb", ACTION=="add", ATTRS{idVendor}=="04d8", ATTRS{idProduct}=="00dd", GROUP="plugdev", MODE="0666"
```

The following screen shots show an example of creating the udev rule file using nano. Replace the actual udev rule text as needed (see above).

![](https://cdn-learn.adafruit.com/assets/assets/000/085/903/medium800/sensors_udev1.jpg?1576621068)

and add the contents from above:

![](https://cdn-learn.adafruit.com/assets/assets/000/085/904/medium800/sensors_udev2.jpg?1576621075)

and then press **CTRL-X** and **Y** to save and exit.

![](https://cdn-learn.adafruit.com/assets/assets/000/085/905/medium800/sensors_udev3.jpg?1576621082)

The settings will take effect the next time you plug in the MCP2221.

## Install hidapi

To install hidapi, run:

```python
pip3 install hidapi
```

![](https://cdn-learn.adafruit.com/assets/assets/000/085/907/medium800/sensors_hidapi.jpg?1576622277)

## Remove Native MCP2221 Driver

Starting with **Linux Kernel 5.7** , a native MCP2221 driver (hid\_mcp2221) is included with the installation. This will interfere with the HID generic driver (hid\_generic) used by Blinka.&nbsp; The native driver can be _ **temporarily** _ removed (disabled) with:

```python
sudo rmmod hid_mcp2221
```

To prevent the driver from loading again at boot or when reinserting the MCP2221, update the kernel module blacklist configuration. Add this line to **/etc/modprobe.d/blacklist.conf**

```python
blacklist hid_mcp2221
```

Then run the following command to also update the configuration in initramfs ([details](https://wiki.debian.org/KernelModuleBlacklisting)):

```auto
sudo update-initramfs -u
```

Reboot the system.

## Install Blinka

To install Blinka and its dependencies, run:

```python
pip3 install adafruit-blinka
```

![](https://cdn-learn.adafruit.com/assets/assets/000/085/906/medium800/sensors_pip.png?1576622119)

## Set environment variable

We need to manually signal to Blinka that we have a MCP2221 attached. To do this, we set the environment variable **BLINKA\_MCP2221**. The value doesn't matter, just use 1:

```python
export BLINKA_MCP2221=1
```

Danger: 

## Run the sanity check.

Now move on to the Post Install Checks section and run the commands there to make sure everything is installed correctly.

# CircuitPython Libraries on any Computer with MCP2221

## Thonny

Using the MCP2221 with the [Thonny Python IDE](https://thonny.org/) should be possible with the following caveats:

- Thonny must be installed into the same Python environment where Blinka was installed.
- The `BLINKA_MCP2221` environment variable must be set.

To set the `BLINKA_MCP2221` environment variable:

- In Thonny, go to Tools -\> Options...
- Go to the General tab in the Options dialog.

- Set BLINKA\_MCP2221=1 in the Environment variables.

- Restart Thonny.

![](https://cdn-learn.adafruit.com/assets/assets/000/137/944/medium640/sensors_thonny.png?1750867630)

- Once Thonny has been restarted, it should be possible to access the MCP2221 in the normal way.

![](https://cdn-learn.adafruit.com/assets/assets/000/137/946/medium640/sensors_thonny2.png?1750867669)

# CircuitPython Libraries on any Computer with MCP2221

## Post Install Checks

After going through all the install steps for your OS, run these checks as simple tests to make sure everything is installed correctly. See the rest of the page for some potential hiccups you may run into.

Go ahead and plug in your MCP2221 to a USB port on your PC.

Most of these tests are done via the Python REPL, at the \>\>\> prompt. To get there, simply launch Python:

```python
$ python3
Python 3.6.9 (default, Nov  7 2019, 10:44:02) 
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
&gt;&gt;&gt;
```

## Check that hidapi is installed correctly

At the Python REPL, type:

```python
import hid
hid.enumerate()
```

![](https://cdn-learn.adafruit.com/assets/assets/000/085/911/medium800/sensors_hidapi_test1.jpg?1576623236)

You should get a dump of everything attached to your USB ports.

## Check that MCP2221 can be found

At the Python REPL, type:

```python
import hid
device = hid.device()
device.open(0x04D8, 0x00DD)
```

it should run without any errors:

![](https://cdn-learn.adafruit.com/assets/assets/000/085/912/medium800/sensors_hidapi_test2.jpg?1576623511)

If for some reason the MCP2221 can not be found, you might see something like this:

![](https://cdn-learn.adafruit.com/assets/assets/000/085/913/medium800/sensors_hidapi_test3.jpg?1576623551)

Check your USB cable connection. On linux based systems, this may be due to the udev rule not working and hitting a permissions issue. So double check the&nbsp;[udev rule setup](https://learn.adafruit.com/circuitpython-libraries-on-any-computer-with-mcp2221/linux#setup-udev-rules-3049707).

## Check environment variable within Python

At the Python REPL, type:

```python
import os
os.environ["BLINKA_MCP2221"]
```

If you get a KeyError it means you did not set the environment variable right:

![](https://cdn-learn.adafruit.com/assets/assets/000/085/914/medium800/sensors_enviro_test1.jpg?1576623753)

If you have set it correctly, you'll get a value back:

![](https://cdn-learn.adafruit.com/assets/assets/000/085/915/medium800/sensors_enviro_test2.jpg?1576623766)

# CircuitPython Libraries on any Computer with MCP2221

## Pinout

![](https://cdn-learn.adafruit.com/assets/assets/000/086/077/medium800/sensors_mcp2221_pinout.png?1576791586)

Info: 

## Power Pins

- **5V** - this is the 5V power from the USB input.
- **3V** - this is the 3.3V power output from the voltage regulator.
- **GND** - this is the common ground for all power and logic.
- **RST** - reset pin, pulled high internally, set low to reset

## GPIO Pins

- **G0** to **G3** - can be used as either digital inputs or outputs, logic level is 3.3V by default but can be changed to 5V

**The GPIO pins do not have internal pull-up or pull-down support!** If you need pull resistors, add them externally.

## I2C Pins

- **SCL** - the I2C clock signal, there's a 5.1K pullup resistor on this pin to whatever the logic level is (default 3.3V)
- **SDA** - the I2C data signal, there's a 5.1K pullup resistor on this pin to whatever the logic level is (default 3.3V)

## UART Pins

- **TX** - transmit (out from board)
- **RX** - receive (in to board)

The uart is totally separate from the GPIO pins, it's controlled as a USB CDC device not as the USB HID interface so it shows up as a serial COM/tty port like any other USB-to-serial converter

## ADC Pins

- **ADC1** to **ADC3** - can be used as analog inputs (10 bit)

## DAC Pins

- **DAC** - there is a single 5 bit DAC which outputs on both of these pins

# Logic Level

The default logic level is 3.3V - this is for digital, analog, I2C and UART data. You can change it to 5V by cutting the jumper on the bottom from 3V and soldering it to the 5V side:

![](https://cdn-learn.adafruit.com/assets/assets/000/086/359/medium800/sensors_4471_quarter_ORIG_2019_12.jpg?1577054529)

# CircuitPython Libraries on any Computer with MCP2221

## Examples

All right, now that all that annoying install stuff is done, let's have some fun.

The following sections will provide some basic examples for the main use cases - GPIO, I2C, ADC, and DAC.

Danger: 

## Installing Libraries for Breakouts

The general process for installing the CircuitPython library you are interested in will be the same as shown in the Python section of the Learn guide for your sensor. Just use `pip3`.

# CircuitPython Libraries on any Computer with MCP2221

## GPIO

## Digital Output

Let's blink a LED!

Here's the bread board layout. The resistor can be something around 1kOhm. We don't need to make the LED super bright.

![](https://cdn-learn.adafruit.com/assets/assets/000/085/988/medium800/sensors_gpio_led_bb.png?1576711431)

First, let's do things interactively so you can see how it all works one line at a time. Start by launching Python:

```python
python3
```

Then, at the Python **\>\>\>** prompt, enter the following to import the needed modules:

```python
import board
import digitalio
```

Next we'll create our LED digital pin and set the mode to output:

```python
led = digitalio.DigitalInOut(board.G0)
led.direction = digitalio.Direction.OUTPUT
```

And that should be it. You should be able to turn ON the LED with:

```python
led.value = True
```

And turn it OFF with:

```python
led.value = False
```

And here's a complete blink program you can run to make the LED blink forever.

```python
import time
import board
import digitalio
     
led = digitalio.DigitalInOut(board.G0)
led.direction = digitalio.Direction.OUTPUT
     
while True:
    led.value = True
    time.sleep(0.5)
    led.value = False
    time.sleep(0.5)
```

Save it as something like **blink.py** and then you can run it with:

```python
python3 blink.py
```

The LED should blink on and off.

## Digital Input

Let's read a button!

Here's the bread board layout. Use something like a 10kOhm resistor.

![](https://cdn-learn.adafruit.com/assets/assets/000/085/989/medium800/sensors_gpio_button_bb.png?1576711463)

Warning: 

We'll do this interactively also. So launch python:

```python
python3
```

Then, at the Python **\>\>\>** prompt, enter the following to import the needed modules:

```python
import board
import digitalio
```

And now we create our button digital pin and set it to input.

```python
button = digitalio.DigitalInOut(board.G0)
button.direction = digitalio.Direction.INPUT
```

And that's it. To read the current state of the button use:

```python
button.value
```

This will return **False** when the button is not pressed and **True** when it is pressed.

## Digtal Input and Output

Ok, let's put those two together and make the button turn on the LED. So we'll use two digital pins - one will be an input (button) and one will be an output (LED).

Here's the bread board layout.

![](https://cdn-learn.adafruit.com/assets/assets/000/086/096/medium800/sensors_gpio_led_button_bb.png?1576797972)

And here's the code.

```python
import board
import digitalio

led = digitalio.DigitalInOut(board.G0)
led.direction = digitalio.Direction.OUTPUT

button = digitalio.DigitalInOut(board.G1)
button.direction = digitalio.Direction.INPUT

while True:
    led.value = button.value
```

Save that to a file with a name like **button\_and\_led.py** and then you can run it with:

```python
python3 button_and_led.py
```

and the button should turn on the LED when pressed.

# CircuitPython Libraries on any Computer with MCP2221

## I2C

Warning: 

Let's talk to an I2C sensor.

We'll use the [MSA301 sensor](https://www.adafruit.com/product/4344) which can read acceleration. Since the MCP2221 and the MSA301 both have [STEMMA QT](https://learn.adafruit.com/introducing-adafruit-stemma-qt) connectors, you have two options for making the connections.

You can either wire everything up on a breadboard, like this:

![](https://cdn-learn.adafruit.com/assets/assets/000/085/991/medium800/sensors_i2c_bb.png?1576711530)

Or use a STEMMA QT cable:

### STEMMA QT / Qwiic JST SH 4-Pin Cable - 200mm Long

[STEMMA QT / Qwiic JST SH 4-Pin Cable - 200mm Long](https://www.adafruit.com/product/4401)
This 4-wire cable is a little over 200mm / 7.8" long and fitted with JST-SH female 4-pin connectors on both ends. Compared with the chunkier JST-PH these are 1mm pitch instead of 2mm, but still have a nice latching feel, while being easy to insert and remove.

<a...></a...>

In Stock
[Buy Now](https://www.adafruit.com/product/4401)
[Related Guides to the Product](https://learn.adafruit.com/products/4401/guides)
![Angled shot of JST SH 4-Pin Cable - 200mm Long.](https://cdn-shop.adafruit.com/640x480/4401-04.jpg)

### STEMMA QT / Qwiic JST SH 4-pin Cable - 100mm Long

[STEMMA QT / Qwiic JST SH 4-pin Cable - 100mm Long](https://www.adafruit.com/product/4210)
This 4-wire cable is a little over 100mm / 4" long and fitted with JST-SH female 4-pin connectors on both ends. Compared with the chunkier JST-PH these are 1mm pitch instead of 2mm, but still have a nice latching feel, while being easy to insert and remove.

<a...></a...>

Out of Stock
[Buy Now](https://www.adafruit.com/product/4210)
[Related Guides to the Product](https://learn.adafruit.com/products/4210/guides)
![Angled shot of STEMMA QT / Qwiic JST SH 4-pin Cable.](https://cdn-shop.adafruit.com/640x480/4210-00.jpg)

### STEMMA QT / Qwiic JST SH 4-Pin Cable - 50mm Long

[STEMMA QT / Qwiic JST SH 4-Pin Cable - 50mm Long](https://www.adafruit.com/product/4399)
This 4-wire cable is&nbsp;50mm / 1.9" long and fitted with JST SH female 4-pin connectors on both ends. Compared with the chunkier JST PH these are 1mm pitch instead of 2mm, but still have a nice latching feel, while being easy to insert and remove.

<a...></a...>

In Stock
[Buy Now](https://www.adafruit.com/product/4399)
[Related Guides to the Product](https://learn.adafruit.com/products/4399/guides)
![Angled of of JST SH 4-Pin Cable.](https://cdn-shop.adafruit.com/640x480/4399-00.jpg)

## Install MSA301 Library

To install the MSA301 library, run the following:

```python
sudo pip3 install adafruit-circuitpython-msa301
```

Note that this step is the same as shown in the [main MSA301 guide](https://learn.adafruit.com/msa301-triple-axis-accelerometer/python-circuitpython#circuitpython-installation-of-msa301-library-6-7). You would do the same general process for any other sensor with a CircuitPython library.

## Example Code

And then we can run the example from the library. Download it from here:

[MSA301 Simple Test Example](https://raw.githubusercontent.com/adafruit/Adafruit_CircuitPython_MSA301/master/examples/msa301_simpletest.py)
save it as **msa301\_simpletest.py** and run it with:

```python
python3 msa301_simpletest.py
```

Pick up the board and spin it around. You should see the values change:

![](https://cdn-learn.adafruit.com/assets/assets/000/086/084/medium800/sensors_msa301_test.png?1576793541)

# CircuitPython Libraries on any Computer with MCP2221

## ADC

Let's read an analog signal!

For this, we'll use a small [10k trim pot](https://www.adafruit.com/product/356) to set up a voltage divider. Here's the wiring diagram:

![](https://cdn-learn.adafruit.com/assets/assets/000/085/993/medium800/sensors_gpio_adc_bb.png?1576712031)

And here's the code:

```python
import time
import board
from analogio import AnalogIn

knob = AnalogIn(board.G1)

def get_voltage(raw):
    return (raw * 3.3) / 65536

while True:
    raw = knob.value
    volts = get_voltage(raw)
    print("raw = {:5d} volts = {:5.2f}".format(raw, volts))
    time.sleep(0.5)
```

Save that as something like **adc.py** and then run it with:

```python
python3 adc.py
```

Spin the knob and the values should change.

![](https://cdn-learn.adafruit.com/assets/assets/000/086/100/medium800/sensors_adc_example.png?1576798438)

Note that even though the MCP2221's ADC is only 10 bits, the value is scaled to 16 bits to comply with the CircuitPython API.

# CircuitPython Libraries on any Computer with MCP2221

## DAC

Let's generate an analog signal!

Well, don't get too excited. There's only a single DAC and it's a whopping 5 bits! So don't expect super awesome high fidelity audio block rockin' beats or anything.

Here's a simple sine wave generator you can try:

```python
import time
import math
import board
from analogio import AnalogOut

dac = AnalogOut(board.G3)

while True:
    dac.value = int((2**16 - 1) * (0.5 + 0.5 * math.sin(time.monotonic()*10)))
```

Save that as something like **dac.py** and run it with:

```python
python3 dac.py
```

And connect the G3 pin to an oscilloscope. You should see something like this:

![](https://cdn-learn.adafruit.com/assets/assets/000/086/048/medium800/sensors_DAC_example.jpg?1576782753)

Note that even though the MCP221's DAC is only 5 bits, you set it using a 16 bit value to comply with the CircuitPython API.

# CircuitPython Libraries on any Computer with MCP2221

## UART

But wait! There's more!

The MCP2221 also provides a USB-to-UART bridge capability. When you plug in the MCP2221, it will show up as two devices:

- **HID Device** - This is what we used for GPIO/I2C/SPI/ADC/DAC
- **CDC Device** - This is how you use the UART

We've already covered all the cool stuff the HID interface provides. So it's this second item were are interested in here. It is how you can use the **TX** and **RX** pins on the MCP2221 breakout.

## Install pySerial

We will use the Python library pySerial to access the MCP2221's UART. So, first install that. Here's a link to installation instructions from the libraries homepage:

[pySerial Installation](https://pythonhosted.org/pyserial/pyserial.html#installation)
## Find COM port in Linux

After plugging in the MCP2221, run `dmesg` and look in the output.

```none
dmesg | tail
```

Like this:

![](https://cdn-learn.adafruit.com/assets/assets/000/088/155/medium800/sensors_find_com_linux.png?1581036538)

Look for something with a name like **ttyACMx**. An entry for that device will have been created in your **/dev** folder. So in your code, you'll want to use `/dev/ttACMx` (replace x with the number). In the example output above, the MCP2221's UART is available on `/dev/ttyACM0`. It may be slightly different on your specific linux set up.

## Find COM port in Windows

After plugging in the MCP2221, look in **Device Manager** under **Ports (COM & LPT)**. If you already have a lot of entries there, it may help to also look before plugging in the MCP2221. That way you can compare and look for the new entry.

It should show up as something like this:

![](https://cdn-learn.adafruit.com/assets/assets/000/088/157/medium800/sensors_find_com_win.jpg?1581038586)

In the above example, it shows up as `COM3`. That's the value you'll use in your code.

## UART Example with GPS

In this example we show how to use the MCP2221's UART to talk to an [Ultimate GPS Breakout Module](https://www.adafruit.com/product/746). Here is how to wire the GPS module to the MCP2221.

![](https://cdn-learn.adafruit.com/assets/assets/000/088/154/medium800/sensors_uart_gps_bb.png?1581034303)

Once you've found your COM port and have the MCP2221 and GPS breakout wired as above, you can then follow the example here:

[GPS UART Usage](https://learn.adafruit.com/adafruit-ultimate-gps/circuitpython-python-uart-usage)
 **NOTE: You will have to make some changes to the code.**

You will want to follow the same general information as for the Raspberry Pi. So comment / uncomment the code as described so that you are using pySerial. Then, when you open the serial port, use the information above for your specific COM port location.

For example, on linux it will generally look the same as the Raspberry Pi example:

```python
import serial
uart = serial.Serial("/dev/ttyUSB0", baudrate=9600, timeout=10)
```

On Windows, you'll want use something like this:

```python
import serial
uart = serial.Serial("COM3", baudrate=9600, timeout=10)
```

And that should be it. If you run the example, it should use the MCP2221's UART to talk to the GPS and evenutally, once it gets a fix, you should see GPS output.

# CircuitPython Libraries on any Computer with MCP2221

## FAQ & Troubleshooting

There's a few oddities when running Blinka/CircuitPython on Linux. Here's a list of stuff to watch for that we know of!

This FAQ covers all the various platforms and hardware setups you can run Blinka on. Therefore, some of the information may not apply to your specific setup.

## Update Blinka/Platform Libraries

**Most issues can be solved by forcing Python to upgrade to the latest `blinka` / `platform-detect` libraries**. Try running

`sudo python3 -m pip install --upgrade --force-reinstall adafruit-blinka Adafruit-PlatformDetect`

### Getting an error message about 'board' not found or 'board' has no attribute

Somehow you have ended up with either the wrong&nbsp; **board** &nbsp;module or no&nbsp; **board** &nbsp;module at all.

**DO NOT** &nbsp;try to fix this by manually installing a library named&nbsp;`board`. There is&nbsp;[one out there](https://pypi.org/project/board/)&nbsp;and it has nothing to do with Blinka. You will break things if you install that library!

The easiest way to recover is to simply force a reinstall of Blinka with:  
`python3 -m pip install --upgrade --force-reinstall adafruit-blinka`

Additionally, and especially if you are using a more recent version of Python, you may run into this error if you either do not have a Virtual Environment active or setup. See the [Python Virtual Environment Usage on Raspberry Pi](https://learn.adafruit.com/python-virtual-environment-usage-on-raspberry-pi) guide for more information or check out the guide's Installation page.

### 
       
       
       
       
       
       
       
       
       
       Mixed SPI mode devices 
       
        
       
     
       
        
       
     
       
        
       
     
       
        
       
     
       
        
       
     
       
        
       
     
       
        
       
     
       
        
       
     
       
        
       
     
       
        
       
    

Due to the way we share an SPI peripheral, you cannot have two SPI devices with different 'mode/polarity' on the same SPI bus - you'll get weird data

95% of SPI devices are mode 0, check the driver to see mode or polarity settings. For example:

- [LSM9DS1 is mode 1](https://github.com/adafruit/Adafruit_CircuitPython_LSM9DS1/blob/master/adafruit_lsm9ds1.py#L408), please use in I2C mode instead of SPI
- [MAX31865 is phase 1](https://github.com/adafruit/Adafruit_CircuitPython_MAX31865/blob/master/adafruit_max31865.py#L97), try using this on a separate SPI device, or read data twice.

### 
       
       
       
       
       
       
       
       
       
       Why am I getting AttributeError: 'SpiDev' object has no attribute 'writebytes2'? 
       
        
       
     
       
        
       
     
       
        
       
     
       
        
       
     
       
        
       
     
       
        
       
     
       
        
       
     
       
        
       
     
       
        
       
     
       
        
       
    

This is due to having an older version of [spidev](https://pypi.org/project/spidev/). You need at least version 3.4. This should have been [taken care of](https://github.com/adafruit/Adafruit_Blinka/blob/8a4686cbc7ebd7f338f64517fa42db4dc5b5c78c/requirements.txt#L6) when you installed Blinka, but in some cases it does not seem to happen.

To check what version of spidev Python is using:

> `$ python3`  
> `Python 3.6.8 (default, Oct 7 2019, 12:59:55) `  
> `[GCC 8.3.0] on linux`  
> `Type "help", "copyright", "credits" or "license" for more information.`  
> `>>> import spidev`  
> `>>> spidev. __version__ `  
> `'3.4'`  
> `>>>`

If you see a version lower then 3.4 reported, then try a force upgrade of spidev with (back at command line):

`sudo python3 -m pip install --upgrade --force-reinstall spidev`

### No Pullup/Pulldown support on some Linux boards or MCP2221

Some Linux boards, for example, AllWinner-based, do not have support to set pull up or pull down on their GPIO. Use an external resistor instead!

### Getting OSError: read error with MCP2221

If you are getting a stack trace that ends with something like:

> `return self._hid.read(64)`  
> `File "hid.pyx", line 122, in hid.device.read`  
> `OSError: read error`

Try setting an environment variable named **BLINKA\_MCP2221\_RESET\_DELAY** to a value of **0.5 or higher**.

Windows:

`set BLINKA_MCP2221_RESET_DELAY=0.5`

Linux:

`export BLINKA_MCP2221_RESET_DELAY=0.5`

This is a value in seconds to wait between resetting the MCP2221 and the attempt to reopen it. The reset is seen by the operating system as a hardware disconnect/reconnect. Different operating systems can need different amounts of time to wait after the reconnect before the attempt to reopen. Setting the above environment variable will override the default reset delay time, allowing it to be increased as needed for different setups.

### 
       
       
       
       
       
       
       
       
       
       Using FT232H with other FTDI devices. 
       
        
       
     
       
        
       
     
       
        
       
     
       
        
       
     
       
        
       
     
       
        
       
     
       
        
       
     
       
        
       
     
       
        
       
     
       
        
       
    

Blinka uses the libusbk driver to talk to the FT232H directly. If you have other FTDI devices installed that are using the FTDI VCP drivers, you may run into issues. See here for a possible workaround:

[https://forums.adafruit.com/viewtopic.php?f=19&t=166999](https://forums.adafruit.com/viewtopic.php?f=19&t=166999)

### 
       
       
       
       
       
       
       
       
       
       Getting 

This is probably only an issue for older versions of Windows. If you run into something like this, see this issue thread:

[https://github.com/pyusb/pyusb/issues/120](https://github.com/pyusb/pyusb/issues/120)

which describes copying the 32bit and 64bit DLLs into specific folders. ([example for Win7](https://github.com/pyusb/pyusb/issues/120#issuecomment-322058585))

### 
       
       
       
       
       
       
       
       
       
        Getting 

Check out this issue thread:

[https://github.com/pyusb/pyusb/issues/355](https://github.com/pyusb/pyusb/issues/355 "https://github.com/pyusb/pyusb/issues/355")

which has **lots** of discussion. It is probably worth reading through it all to determine what applies for your setup.&nbsp; Most solutions seem to rely on setting the **DYLD\_LIBRARY\_PATH** environment variable.

This issue thread has further information:

[https://github.com/orgs/Homebrew/discussions/3424](https://github.com/orgs/Homebrew/discussions/3424)

### 
       
       
       
       
       
       
       
       
       
       I can't get neopixel, analogio, audioio, rotaryio, displayio or pulseio to work! 
       
        
       
     
       
        
       
     
       
        
       
     
       
        
       
     
       
        
       
     
       
        
       
     
       
        
       
     
       
        
       
     
       
        
       
     
       
        
       
    

Some CircuitPython modules like may not be supported.

- Most SBCs do not have analog inputs so there is no `analogio`
- Few SBCs have `neopixel` support so that is only available on Raspberry Pi (and any others that have low level neopixel protocol writing
- Rotary encoders (`rotaryio`) is handled by interrupts on microcontrollers, and is not supported on SBCs at this time
- Likewise `pulseio` PWM support is not supported on many SBCs, and if it is, it will not support a carrier wave (Infrared transmission)
- For display usage, we suggest using python `Pillow` library or `Pygame`, we do not have `displayio` support

We aim to have, at a minimum, `digitalio` and `busio` (I2C/SPI). This lets you use the vast number of driver libraries

For analog inputs,[the MCP3xxx library](https://github.com/adafruit/Adafruit_CircuitPython_MCP3xxx) will give you `AnalogIn` objects. For PWM outputs, [try the PCA9685](https://github.com/adafruit/Adafruit_CircuitPython_PCA9685). For audio, use pygame or other Python3 libraries to play audio.

Some libraries, like [Adafruit\_CircuitPython\_DHT](https://github.com/adafruit/Adafruit_CircuitPython_DHT) will try to bit-bang if pulsein isn't available. Slow linux boards (\<700MHz) may not be able to read the pins fast enough), you'll just have to try!

### 
       
       
       
       
       
       
       
       
       
       Help, I'm getting the message 

It looks like **libgpiod** may not be installed on your board.

Try running the command: `sudo apt-get install libgpiod2`

### 
       
       
       
       
       
       
       
       
       
       = v5.5.0

Be sure you have the latest libgpiod.py script and run it with the `-l` or `--legacy` flag:

`sudo python3 libgpiod.py --legacy`

All Raspberry Pi Computers Have:

- 1 x I2C port with **busio** (but clock stretching is not supported in hardware, so you must set the I2C bus speed to 10KHz to 'fix it')
- 2 x SPI ports with **busio** 
- 1 x UART port with **serial** - note this is shared with the hardware console
- **pulseio.pulseIn** using gpiod
- **neopixel** support on a few pins
- No AnalogIn support (Use an MCP3008 or similar to add ADC)
- No PWM support (Use a PCA9685 or similar to add PWM)

![sensors_raspberry_pi.jpg](https://cdn-learn.adafruit.com/assets/assets/000/077/099/medium640/sensors_raspberry_pi.jpg?1560709288)

Google Coral TPU Dev Boards Have:

- 1 x I2C port with **busio**
- 1 x SPI ports with **busio** 
- 1 x UART port with **serial** - note this is shared with the hardware console
- 3 x PWMOut support
- No NeoPixel support
- No AnalogIn support (Use an MCP3008 or similar to add ADC)

![sensors_google_coral.jpg](https://cdn-learn.adafruit.com/assets/assets/000/077/100/medium640/sensors_google_coral.jpg?1560709528)

Orange Pi PC Plus Boards Have:

- 1 x I2C port with **busio**
- 1 x SPI ports with **busio** 
- 1 x UART port with **serial**
- No NeoPixel support
- No AnalogIn support (Use an MCP3008 or similar to add ADC)
- No PWM support (Use a PCA9685 or similar to add PWM)

![sensors_47688275371_ab6f25d2f2_k.jpg](https://cdn-learn.adafruit.com/assets/assets/000/077/102/medium640/sensors_47688275371_ab6f25d2f2_k.jpg?1560709858)

Orange Pi R1 Boards Have:

- 1 x I2C port with **busio**
- 1 x SPI port with **busio** 
- 1 x UART port with **serial**
- No NeoPixel support
- No AnalogIn support (Use an MCP3008 or similar to add ADC)
- No PWM support (Use a PCA9685 or similar to add PWM)

![sensors_orange_pi_r1.jpg](https://cdn-learn.adafruit.com/assets/assets/000/077/105/medium640/sensors_orange_pi_r1.jpg?1560710441)

ODROID C2 Boards Have:

- 1 x I2C port with&nbsp; **busio**
- No SPI support
- 1 x UART port with **serial** - note this is shared with the hardware console
- No NeoPixel support
- No AnalogIn support (Use an MCP3008 or similar to add ADC)
- No PWM support (Use a PCA9685 or similar to add PWM)

![sensors_product.jpg](https://cdn-learn.adafruit.com/assets/assets/000/077/107/medium640/sensors_product.jpg?1560710758)

DragonBoard 410c Boards Have:

- 2 x I2C port with&nbsp; **busio**
- 1 x SPI port with&nbsp; **busio**
- 1 x UART port with&nbsp; **serial**
- No NeoPixel support
- No AnalogIn support (Use an MCP3008 or similar to add ADC)
- No PWM support (Use a PCA9685 or similar to add PWM)

![sensors_dragonboard410c.jpg](https://cdn-learn.adafruit.com/assets/assets/000/077/714/medium640/sensors_dragonboard410c.jpg?1562085887)

NVIDIA Jetson Nano Boards Have:

- 2 x I2C port with&nbsp; **busio**
- 2 x SPI ports with **busio**
- 2 x UART port with&nbsp; **serial** &nbsp;- note one of these is shared with the hardware console
- No NeoPixel support
- No AnalogIn support (Use an MCP3008 or similar to add ADC)
- No PWM support (Use a PCA9685 or similar to add PWM)

![sensors_faq_troubleshooting.jpg](https://cdn-learn.adafruit.com/assets/assets/000/080/798/medium640/sensors_faq_troubleshooting.jpg?1568157791)

FT232H Breakouts Have:

- 1x I2C port **OR** SPI port with **busio**
- 12x GPIO pins with **digitalio**
- No UART
- No AnalogIn support
- No AnalogOut support
- No PWM support

If you are using [Blinka in FT232H mode](https://learn.adafruit.com/circuitpython-on-any-computer-with-ft232h), then keep in mind these basic limitations.

- SPI and I2C can not be used at the same time since they share the same pins.
- GPIO speed is not super fast, so trying to do arbitrary bit bang like things may run into speed issues.
- There are no ADCs.
- There are no DACs.
- UART is not available (its a different FTDI mode)

![sensors_2264-04.jpg](https://cdn-learn.adafruit.com/assets/assets/000/081/745/medium640/sensors_2264-04.jpg?1569886041)

MCP2221 Breakouts Have:

- 1x I2C port with **busio**
- 4x GPIO pins with **digitalio**
- 3x AnalogIn with **analogio**
- 1x AnalogOut with **analogio**
- 1x UART with **pyserial**
- No PWM support
- No hardware SPI support

If you are using Blinka in MCP2221 mode, then keep in mind these basic limitations.

- GPIO speed is not super fast, so trying to do arbitrary bit bang like things may run into speed issues.
- UART is available via `pyserial`, the serial COM port shows up as a second USB device during enumeration

![sensors_mcp2221_small_iso.jpg](https://cdn-learn.adafruit.com/assets/assets/000/086/115/medium640/sensors_mcp2221_small_iso.jpg?1576799406)

# CircuitPython Libraries on any Computer with MCP2221

## Downloads

Files:

- [MCP2221 Datasheet](http://ww1.microchip.com/downloads/en/DeviceDoc/20005292C.pdf)
- [EagleCAD files on GitHub](https://github.com/adafruit/Adafruit-MCP2221-PCB)
- [Fritzing object in Adafruit Fritzing Library](https://github.com/adafruit/Fritzing-Library/blob/master/parts/Adafruit%20MCP2221A%20USB%20to%20GPIO-I2C-ADC-DAC%20breakout.fzpz)
- [3D models on GitHub](https://github.com/adafruit/Adafruit_CAD_Parts/tree/main/4471%20MCP2221A%20Breakout)

# Schematic, Fab Print and 3D model
![](https://cdn-learn.adafruit.com/assets/assets/000/086/215/medium800/sensors_MCP2221_sch.png?1576869574)

![](https://cdn-learn.adafruit.com/assets/assets/000/086/216/medium800/sensors_MCP2221_fab_print.png?1576869583)

![](https://cdn-learn.adafruit.com/assets/assets/000/135/741/medium800/sensors_4471_MCP2221A_Breakout.jpg?1741885316)


## Primary Products

### Adafruit MCP2221A Breakout - General Purpose USB to GPIO ADC I2C

[Adafruit MCP2221A Breakout - General Purpose USB to GPIO ADC I2C](https://www.adafruit.com/product/4471)
Wouldn't it be cool to drive a [tiny&nbsp;OLED display](https://www.adafruit.com/categories/98), read a [color...](https://www.adafruit.com/products/1334)

In Stock
[Buy Now](https://www.adafruit.com/product/4471)
[Related Guides to the Product](https://learn.adafruit.com/products/4471/guides)

## Featured Products

### STEMMA QT / Qwiic JST SH 4-pin to Premium Male Headers Cable

[STEMMA QT / Qwiic JST SH 4-pin to Premium Male Headers Cable](https://www.adafruit.com/product/4209)
This 4-wire cable is a little over 150mm / 6" long and fitted with JST-SH female 4-pin connectors on one end and premium Dupont male headers on the other. Compared with the chunkier JST-PH these are 1mm pitch instead of 2mm, but still have a nice latching feel, while being easy to insert...

In Stock
[Buy Now](https://www.adafruit.com/product/4209)
[Related Guides to the Product](https://learn.adafruit.com/products/4209/guides)
### STEMMA QT / Qwiic JST SH 4-pin Cable with Premium Female Sockets

[STEMMA QT / Qwiic JST SH 4-pin Cable with Premium Female Sockets](https://www.adafruit.com/product/4397)
This 4-wire cable is a little over 150mm / 6" long and fitted with JST-SH female 4-pin connectors on one end and premium female headers on the other. Compared with the chunkier JST-PH these are 1mm pitch instead of 2mm, but still have a nice latching feel, while being easy to insert and...

In Stock
[Buy Now](https://www.adafruit.com/product/4397)
[Related Guides to the Product](https://learn.adafruit.com/products/4397/guides)
### STEMMA QT / Qwiic JST SH 4-Pin Cable - 50mm Long

[STEMMA QT / Qwiic JST SH 4-Pin Cable - 50mm Long](https://www.adafruit.com/product/4399)
This 4-wire cable is&nbsp;50mm / 1.9" long and fitted with JST SH female 4-pin connectors on both ends. Compared with the chunkier JST PH these are 1mm pitch instead of 2mm, but still have a nice latching feel, while being easy to insert and remove.

<a...></a...>

In Stock
[Buy Now](https://www.adafruit.com/product/4399)
[Related Guides to the Product](https://learn.adafruit.com/products/4399/guides)
### STEMMA QT / Qwiic JST SH 4-pin Cable - 100mm Long

[STEMMA QT / Qwiic JST SH 4-pin Cable - 100mm Long](https://www.adafruit.com/product/4210)
This 4-wire cable is a little over 100mm / 4" long and fitted with JST-SH female 4-pin connectors on both ends. Compared with the chunkier JST-PH these are 1mm pitch instead of 2mm, but still have a nice latching feel, while being easy to insert and remove.

<a...></a...>

Out of Stock
[Buy Now](https://www.adafruit.com/product/4210)
[Related Guides to the Product](https://learn.adafruit.com/products/4210/guides)
### STEMMA QT / Qwiic JST SH 4-Pin Cable - 200mm Long

[STEMMA QT / Qwiic JST SH 4-Pin Cable - 200mm Long](https://www.adafruit.com/product/4401)
This 4-wire cable is a little over 200mm / 7.8" long and fitted with JST-SH female 4-pin connectors on both ends. Compared with the chunkier JST-PH these are 1mm pitch instead of 2mm, but still have a nice latching feel, while being easy to insert and remove.

<a...></a...>

In Stock
[Buy Now](https://www.adafruit.com/product/4401)
[Related Guides to the Product](https://learn.adafruit.com/products/4401/guides)

## Related Guides

- [Google Docs Sensor Logging From Your PC](https://learn.adafruit.com/gdocs-sensor-logging-from-your-pc.md)
- [CircuitPython Libraries and Jupyter Notebook on any Computer with MCP2221](https://learn.adafruit.com/jupyter-on-any-computer-with-circuitpython-libraries-and-mcp2221.md)
- [Adafruit I2S Amplifier BFF](https://learn.adafruit.com/i2s-amplifier-bff.md)
- [CircuitPython 101: Functions](https://learn.adafruit.com/circuitpython-101-functions.md)
- [Bubble Table with LED Animations and IR Remote Control](https://learn.adafruit.com/bubble-table-with-led-animations-and-ir-remote-control.md)
- [Star Fragment IoT Lamp](https://learn.adafruit.com/star-fragment-iot-lamp.md)
- [Bricktunes: LEGO Synthesizer Glove](https://learn.adafruit.com/bricktunes-lego-glove-synthesizer.md)
- [Mini Weather Station ESP32-S3 TFT](https://learn.adafruit.com/mini-weather-station-esp32-s2-tft.md)
- [Animatronic Hand](https://learn.adafruit.com/animatronic-hands.md)
- [CircuitPython Media Dial](https://learn.adafruit.com/media-dial.md)
- [CircusPython: Jump through Hoops with CircuitPython Bluetooth LE](https://learn.adafruit.com/circuspython-jump-through-hoops-with-bluetooth-le.md)
- [CircuitPython Libraries on MicroPython using the Raspberry Pi Pico](https://learn.adafruit.com/circuitpython-libraries-on-micropython-using-the-raspberry-pi-pico.md)
- [PyPortal Winamp MP3 Player](https://learn.adafruit.com/pyportal-winamp-mp3-player.md)
- [PB Gherkin 30% keyboard with KMK, CircuitPython, & KB2040](https://learn.adafruit.com/pb-gherkhin-30-keyboard-with-kmk-circuitpython-kb2040.md)
- [Navi10 MacroPad with KB2040 and KMK CircuitPython keyboard firmware](https://learn.adafruit.com/navi10-macropad-with-kb2040-and-kmk-circuitpython-keyboard-firmware.md)
