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 Arduino 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.
// SPDX-FileCopyrightText: 2021 Carter Nelson for Adafruit Industries // SPDX-FileCopyrightText: 2022 Kattni Rembor for Adafruit Industries // // SPDX-License-Identifier: MIT // -------------------------------------- // PiCowbell Proto and Pico I2C scan code. // // Modified from https://playground.arduino.cc/Main/I2cScanner/ // -------------------------------------- #include <Wire.h> // Wire uses GPIO4 (SDA) and GPIO5 (SCL) automatically. #define WIRE Wire void setup() { WIRE.begin(); Serial.begin(9600); while (!Serial) delay(10); Serial.println("\nPiCowbell Proto Pico I2C Scanner"); } void loop() { byte error, address; int nDevices; Serial.println("Scanning..."); nDevices = 0; for(address = 1; address < 127; address++ ) { // The i2c_scanner uses the return value of // the Write.endTransmission to see if // a device did acknowledge the address. WIRE.beginTransmission(address); error = WIRE.endTransmission(); if (error == 0) { Serial.print("I2C device found at address 0x"); if (address<16) Serial.print("0"); Serial.print(address,HEX); Serial.println(" !"); nDevices++; } else if (error==4) { Serial.print("Unknown error at address 0x"); if (address<16) Serial.print("0"); Serial.println(address,HEX); } } if (nDevices == 0) Serial.println("No I2C devices found\n"); else Serial.println("done\n"); delay(5000); // wait 5 seconds for next scan }
Upload the sketch to your board and open up the Serial Monitor (Tools -> Serial Monitor) at 115200 baud. You should see something like the following.
The MCP9808 default I2C address is 0x18. You've now verified your PiCowbell Proto and Pico are assembled properly, and that Arduino is detecting the I2C device you connected! Now you're ready to jump into whatever project you have planned!
Note that Wire
represents both of the pins used by the STEMMA QT connector, which are GPIO4 (SDA) and GPIO5 (SCL). For more details on how Wire
works, check out the Arduino Pico Wire documentation.
Text editor powered by tinymce.