RP2040 and I2C pins change

Hello all,

I'm having a very difficult time getting I2C working properly on the rpi pico RP2040 (not NanoRP2040).

I have tried in PlatformIO and Arduino IDE, using Earles Arduino-Pico core and the official Arduino core.

I got it going using Earles core, because I had to change the I2C pins from 4/5 to 0/1 for the specific PCB that I developed by using the Wire.setSDA(pin) and Wire.setSCL(pin) functions in that core.

But I am having so many issues on my windows machine not that I cannot get anything to work or upload from that machine. So I have switched to a Linux machine that can upload.

But I would like to use the official Arduino core, but I cannot find any way to switch the i2c pins.
I tried changing the variables in the pins_arduino.h in teh variants folder, but it did not work.

Is there any way to change the SDA and SCL pins when using the official Arduino core for RP2040?

SDA is pin 4
SCL is pin 5

What is the problem, you don't like those pin ? :wink:

Arduino is on top of Mbed, the variant for the Raspberry Pi Pico is here: https://github.com/arduino/ArduinoCore-mbed/tree/main/variants/RASPBERRY_PI_PICO

Have you tried changing "PIN_WIRE_SDA" and "PIN_WIRE_SCL" ?
They are here : https://github.com/arduino/ArduinoCore-mbed/blob/main/variants/RASPBERRY_PI_PICO/pins_arduino.h#L55

Hi Koepel,

Yes, I have tried changing them by defining them before. I am working on a PCB of my own design and have i2c on pins 0/1.

I can get SDA to pulse on GPIO0, but SCL is not pulsing.

Here is my code (without loop)

#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>

#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 64 // OLED display height, in pixels
#define OLED_RESET     -1 // Reset pin # (or -1 if sharing Arduino reset pin)
#define SCREEN_ADDRESS 0x3C ///< See datasheet for Address; 0x3D for 128x64, 0x3C for 128x32


MbedI2C i2c(0,1);

Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &i2c, OLED_RESET);

#define PIN_WIRE_SDA 0
#define PIN_WIRE_SCL 1

uint32_t last;

void setup() {
  // put your setup code here, to run once:
  
  i2c.begin();
  
  //Serial.begin(115200);
  if(!display.begin(SSD1306_SWITCHCAPVCC, SCREEN_ADDRESS)) {
    //Serial.println(F("SSD1306 allocation failed"));
    for(;;); // Don't proceed, loop forever
  }
  display.clearDisplay();
 last = millis();
}
1 Like

If I try to flash using Arduino IDE v2.1.1 I get this error:

Exception executing udisksctl. Exception: [Errno 2] No such file or directory: 'udisksctl'
No drive to deploy.

It is a reason why you shouldn't make PCB before complete test on breadboard.

I'm sorry, I see I have not expressed myself correct.

I am not working on a rpi Pico, but I am using the RP2040 MCU, but on a board I made which has i2c0 on GP0 and GP1. Therefore I want to change the i2c pins to those pins while also using the Arduino Core for the RP2040.

But I cannot find a way to do this that works. I tried defining PIN_WIRE_SDA and SCL to 0 and 1.

After defining PIN_WIRE_Sxx BEFORE #include <Wire.h>, I now get pulsing on SCL, but the voltage only drops about 1V on the 3V3 line when pulsing.

Could this be caused by other peripherals claiming the pin too?

Or could it be the screen that may not be initialized correct and keeping the pin high...

Arduino creates Serial1 on pin 0 and 1.
It should not be created if Serial1 is not used, but I don't understand when and if Serial1 is created.

The pins_arduino.h has:

// Serial
#define PIN_SERIAL_TX (0ul)
#define PIN_SERIAL_RX (1ul)

#define SERIAL_HOWMANY		1
#define SERIAL1_TX			(digitalPinToPinName(PIN_SERIAL_TX))
#define SERIAL1_RX			(digitalPinToPinName(PIN_SERIAL_RX))

and they are used in Serial.h and Serial.cpp

Hi,

Yes I have also tried to comment that out completely.

I am trying to get an 128x64 OLED working with the SSD1306 using Adafruit libs for those parts. I have an EEPROM working on the board on i2c0 pina 0/1, but when I try with just the display and associated code, I cannot get the i2c to work. I have also tried many other ssd306 libs, but there is not always something that does not work.
If I change the core to the official Arduino code for RP2040, there is a missing file in the adafruit lib "pgmspace.h" and it won't compile.

I was ordering a new board version anyway, so I have moved the i2c pins to GPIO4/5 instead.

Anyway,

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.