I can’t get the Expansion board OLED display to show anything using the XIAO RP2040. It works fine with the XIAO ATSAMD21G18A-MU. Any ideas?
I’m having the same problem. I can’t try an alternative microcontroller at this point in time other than the XIAO RP2040, but the rest of the expansion board seems fine apart from the OLED. I’ve been trying so many different approaches/libraries that I am now exhausted. Almost ready to de-fenestrate the whole thing and try with another product.
Ah good to know I’m not the only one, sounds like its a defect in the supposedly “pin compatible” RP2040
I found a way around this by not using the core Arduino code. I configured the RP2040 and a Thonny environment (along with Windows with Python 3.9 [had to downgrade due to compatibility issues]), downloaded a couple of .py ‘library’ files, uploaded them via rshell (rshell does not work on Windows with the latest Python, so have to keep it below 3.10 - so many hours of pain) and everything sort of started working!
For latest MP XIAO RP2040 boot loader:
For loading the libraries and code:
Really not much fun approaching this with any other language. It seems that you mainly need access to rshell (which was the biggest hurdle for me).
Hope this helps you or anyone else!!
Thanks Simon, I will have a go.
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]
Test_OLED_u8x8lib.zip (1.7 KB)
Excellent, I’m glad you found this, my OLED is working with the XIAO RP2040 now! Took me a while to work out there were two files I needed to change (U8x8lib.h and pins_arduino.h) and to find them on my mac.
Just got around to tinkering and looking into this again (after my adventures in MicroPython). I thought I was at another dead end for a little while as I was just looking at the test output and seemed to be getting the following:
It all looked right except I wasn’t getting the expected 0’s.
I thought I would just try your display code quick for the screen and it looks like I was worrying mostly about nought! Fantastic!
Thank you so much for bringing that all together for us
Seeed told me they had released a new version of the Arduino Core for this so I downloaded the new version for board manager but it still didn’t work with their default sketch that they suggested in their wiki page. The problem seems to be the definition at the top of the sketch. If you change it to the following it works, but only after doing the mods here I think.
U8X8_SSD1306_128X64_NONAME_2ND_HW_I2C u8x8(/* reset=*/ U8X8_PIN_NONE);