Raspberry Pi Pico I2C

Pico has several I2C lines. In Arduino, when I scan I2C lines it is scanned only on 0 and 1, as default. How to force Wire.begin() to take say, 6 and 7? According to this page, it should be addressed, but I don't know how. For 2 and 3, the address is 0x30.

I checked the datasheet, but obviously had no luck.

Which Arduino boards platform are you using to add support for the Pico to the Arduino IDE.

I know of two prominent ones:

Both ways can not compile if I add int as a pin number in Wire.begin(). I can with hex, but I don't know what hex value to use for 6 and 7.

It sound like you're using the 3rd party (earlephilhower) library. If you try with the mbed (official Arduino) library, take a look at this thread, which deals with modifying the pins_arduino.h file, found here in Windows installations of Arduino IDE: C:\Users\USERNAME\AppData\Local\Arduino15\packages\arduino\hardware\mbed_rp2040\2.5.2\variants\RASPBERRY_PI_PICO, to specify Wire and Wire1 pins for use in I2C connections:


The code referenced is for Earle's core. The 0x30 is the sensor/device I2C address being connected

// Simple I2C master and slave demo - Earle F. Philhower, III
// Released into the public domain
// Using both onboard I2C interfaces, have one master and one slave
// and send data both ways between them
// To run, connect GPIO0 to GPIO2, GPIO1 to GPIO3 on a single Pico

#include <Wire.h>

void setup() {

static char buff[100];
void loop() {
    static int p;
    char b[90];

    // Write a value over I2C to the slave
    sprintf(b, "pass %d", p++);
    Wire.write(b, strlen(b));

    // Ensure the slave processing is done and print it out
    Serial.printf("buff: '%s'\r\n", buff);

    // Read from the slave and print out
    Wire.requestFrom(0x30, 6);
    Serial.print("\nrecv: '");
    while(Wire.available()) {

// These are called in an **INTERRUPT CONTEXT** which means NO serial port
// access (i.e. Serial.print is illegal) and no memory allocations, etc.

// Called when the I2C slave gets written to
void recv(int len) {
    int i;
    // Just stuff the sent bytes into a global the main routine can pick up and use
    for (i=0; i<len; i++) buff[i] = Wire1.read();
    buff[i] = 0;

// Called when the I2C slave is read from
void req() {
    static int ctr = 765;
    char buff[7];
    // Return a simple incrementing hex value
    sprintf(buff, "%06X", (ctr++) % 65535);
    Wire1.write(buff, 6);