Now that you've assembled your PiCowbell Proto and Pico, you're ready to connect one of many breakouts to the STEMMA QT connector and get going with no further soldering needed!
This page shows you how to use CircuitPython to scan I2C to show the address of any connected devices, which will indicate whether your breakout is connected and your PiCowbell is assembled correctly.
Wiring
This diagram uses the MCP9808. You can replace it with any STEMMA QT breakout and get similar results; the I2C address returned below may be different with a different breakout.
Simply connect your STEMMA QT cable from the MCP9808 STEMMA QT connector to the PiCowbell Proto STEMMA QT connector.
I2C Scan Code
You'll need to load the example below onto your Raspberry Pi Pico, and connect to the serial console to see the results printed out. To do so, click the Download Project Bundle button below to download the necessary libraries and the code.py file in a zip file. Extract the contents of the i2c_scan.zip zip file, and navigate to the directory PiCowbell_Proto/i2c_scan. Then open on the directory within that matches the version of CircuitPython you're using and copy the contents of that directory to your CIRCUITPY drive.
# SPDX-FileCopyrightText: 2022 Kattni Rembor for Adafruit Industries # SPDX-License-Identifier: MIT """CircuitPython I2C Device Address Scan for PiCowbell Proto and Pico""" import time import board i2c = board.STEMMA_I2C() while not i2c.try_lock(): pass try: while True: print( "I2C addresses found:", [hex(device_address) for device_address in i2c.scan()], ) time.sleep(2) finally: # unlock the i2c bus when ctrl-c'ing out of the loop i2c.unlock()
Once everything is saved to the CIRCUITPY drive, connect to the serial console to see the data printed out!
The MCP9808 default I2C address is 0x18. You've now verified your PiCowbell Proto and Pico are assembled properly, and that CircuitPython is detecting the I2C device you connected! Now you're ready to jump into whatever project you have planned!
I2C Object Creation using board.STEMMA_I2C()
One thing worth noting about this code, that will help you in all of your future STEMMA QT project endeavors, is the I2C object creation.
i2c = board.STEMMA_I2C()
To create the I2C object, you assign board.STEMMA_I2C()
to a i2c
variable for use later in the code. Simple! But, how does it work?
As noted previously in this guide, the STEMMA QT connector on the PiCowbell Proto is connected to GPIO5 (SCL) and GPIO4 (SDA). In CircuitPython, we have assigned board.STEMMA_I2C()
to use GPIO5 and GPIO4 to allow you a simpler way to create the I2C object when using the STEMMA QT connector.
Page last edited January 20, 2025
Text editor powered by tinymce.