Pi Pico Oled screen which i2c?

Hello, trying to program the first Pi pico rp2040 with a 0.96 single color oled screen. The problem I'm having is there are a few i2c lines it shows on the board. I don't know which ones do I use for the oled screen. Can someone please help me out to figure out which one and which code should I use to make this work?

Joseph

If it's not marked on the board, use an I2C scanner to find out. I googled one for you.

https://learn.adafruit.com/scanning-i2c-addresses/arduino

Does the OLED screen connect to the pico through wires or plug in headers?
What is its part number?

@sonofcy Its been a while since I played around with i2c. When I got these pico boards in I didn't know which I2C I can use as a default i2c. I have tired the other pins and they did find them but not the default i2c pins. I tired GP4 and GP5 on the pin and it showed up as the default i2c pins. which I saw in one of the google search pages. So I have tried and got this as a result.

I2C Scanner
Scanning...
I2C device found at address 0x3C !
done

Thank you for the scanner. the old one I was using doesn't work. It works on my uncle and leonardo boards but not the pico boards.

@EmilyJane The scanner from @sonofcy help me to identify the i2c pins I needed it. Thank you.

So which pins are they?

@EmilyJane GP4 and GP5. Pins 6 and 7.

And in case someone finds this topic and wonders what OLED screen that was, why don't you post the Model and a picture?

@EmilyJane You are right my fault there. I did not post about the screen itself. It is a 0.96 white OLED screen. This is where I got mine from is Amazon in the USA.

https://www.amazon.com/ELEGOO-Display-Compact-Self-Luminous-Projects/dp/B0FSRQG23K

Yes, those are the default (no code needed) I2C0 pins, but by specifying in the code you have 5 other sets (SDA, SDL) you can use. Then the I2C1 chan has 6 in total as well.

All data pins have I2C functionality.
Pins marked I2C0 correspond to Wire, and those marked I2C1 to Wire1.
The default physical pins on Pico for I2C0 (Wire) are 6 and 7, but keep in mind that you must reference the GPIOs (that is, 4 and 5 respectively).

For more information

the RPi RP2040 Pico default I2C and SPI pins are

SDA 4
SCL 5
MOSI: 19
MISO: 16
SCK: 18
SS: 17

however, you can use the Wire.setSDA() and Wire.setSCL() methods to aselect other pins
e.g. a BMP280 using SDA GPIO20 and SCL GPIO21

// Interfacing RPi pico RP2040 with BMP280 temperature and pressure sensor.

#include <Wire.h>             // include Wire library, required for I2C devices
#include <Adafruit_Sensor.h>  // include Adafruit sensor library
#include <Adafruit_BMP280.h>  // include adafruit library for BMP280 sensor

// define device I2C address: 0x76 or 0x77 (0x77 is library default address)
#define BMP280_I2C_ADDRESS 0x76

// define I2C1 RP2040 pins for BMP280
#define SDA 20  
#define SCL 21  

Adafruit_BMP280 bmp280(&Wire1);

void setup() {
  Serial.begin(115200);
  delay(3000);
  Serial.println(F("RPi pico RP2040 + BMP280"));
  Wire1.setSDA(SDA);    // setup SDA and SCL pins
  Wire1.setSCL(SCL);
  Wire1.begin();
  if (!bmp280.begin(BMP280_I2C_ADDRESS)) {
    Serial.println("Could not find a valid BMP280 sensor, check wiring!");
    while (1)
      ;
  }
  Serial.println("Found BMP280 sensor!");
}

void loop() {
  // get temperature, pressure and altitude from library
  float temperature = bmp280.readTemperature();    // get temperature
  float pressure = bmp280.readPressure();          // get pressure
  float altitude_ = bmp280.readAltitude(1013.25);  // get altitude (this should be adjusted to your local forecast)
  // print data on the serial monitor software
  // 1: print temperature
  Serial.print("Temperature = ");
  Serial.print(temperature);
  Serial.println(" °C");
  // 2: print pressure
  Serial.print("Pressure    = ");
  Serial.print(pressure / 100);
  Serial.println(" hPa");
  // 3: print altitude
  Serial.print("Approx Altitude = ");
  Serial.print(altitude_);
  Serial.println(" m");

  Serial.println();  // start a new line
  delay(2000);       // wait 2 seconds
}

serial monitor output

RPi pico RP2040 + BMP280
Found BMP280 sensor!
Temperature = 24.33 °C
Pressure    = 1001.57 hPa
Approx Altitude = 97.70 m

Temperature = 24.69 °C
Pressure    = 1001.64 hPa
Approx Altitude = 97.10 m

Temperature = 24.71 °C
Pressure    = 1001.62 hPa
Approx Altitude = 97.24 m

Temperature = 24.71 °C
Pressure    = 1001.64 hPa
Approx Altitude = 97.10 m