Try to avoid hot plugging I2C sensors. The MCP2221 doesn't seem to like that. Remove USB power first.

Let's talk to an I2C sensor.

We'll use the MSA301 sensor which can read acceleration. Since the MCP2221 and the MSA301 both have STEMMA QT connectors, you have two options for making the connections.

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

Or use a STEMMA QT cable:

Angled shot of JST SH 4-Pin Cable - 200mm Long.
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...
$1.25
In Stock
Angled shot of STEMMA QT / Qwiic JST SH 4-pin Cable.
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...
$0.95
In Stock
Angled of of JST SH 4-Pin Cable.
This 4-wire cable is 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...
Out of Stock

Install MSA301 Library

To install the MSA301 library, run the following:

sudo pip3 install adafruit-circuitpython-msa301

Note that this step is the same as shown in the main MSA301 guide. 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:

save it as msa301_simpletest.py and run it with:

python3 msa301_simpletest.py

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

This guide was first published on Dec 22, 2019. It was last updated on Dec 22, 2019.

This page (I2C) was last updated on Dec 17, 2019.

Text editor powered by tinymce.