Expansion board OLED problem

I have just started with my XIAO RP2040, so I’m sorry if this is too late to help the Original Poster (and the others) with XIAO RP2040 driving the Expansion Board OLED using Arduino code.

Here’s the thing: The OLED on the Expansion board is connected to the XIAO RP2040 pins D5 and D4, which can be connected to the “second” I2C port, i2c1, using the built-in Wire1 object (not the Wire object, which is connected to i2c0).

I spent a little time confirming that with Seeed supplied board package for the '2040, this is not possible. See my “fix” here: https://forum.seeedstudio.com/t/xiao-rp2040-i2c/261907/6

Now, there are several libraries that can be used with an SSD1306, which is the display on the Expansion board. They all have their “little quirks.”

I’ll start you with the u8g2 library. The problem with this one is that there is provision for using Wire1, but you need to add a certain #define somewhere that the library source .cpp file can see it.

My idea is to make minimum changes to published code that lets me add the functionality I need. I modified U8x8lib.h as follows:

After line 65 I added a definition for WIRE_INTERFACES_COUNT

Starting at line 61, here’s what it now looks like.
The first five lines were already in the file. I added the next five:

/* Assumption: All Arduino Boards have "Wire.h" */
#ifndef U8X8_NO_HW_I2C
#define U8X8_HAVE_HW_I2C
#endif

// Added by davekw7x to be able to use Wire1, as
// required on the XIAO RP2040
#ifdef PIN_WIRE1_SDA
#define WIRE_INTERFACES_COUNT 2
#endif

With that in place in the library file and with the changes in arduino_pins.h that I referred to in the other thread, I was able to write to the display.

I attached a photo of the output from the attached sketch.

I hope this helps.

[/begin Editorial comment]
And I wish to heck that the Seeed guys would publish something that they had actually tested so that the rest of us would have an easier time getting started.
[/end Editorial comment]

Regards,

Dave

Test_OLED_u8x8lib.zip (1.7 KB)

1 Like