SAMD21 based board with a 0.91" OLED

Dear all,

I got a SparkFun Mini Breakout Board powered by a SAMD21 microcontroller and I also have a OLED here. I connected them, installed some libraries but can't get a "Hello world" print done.

Any tips? Like a hello world code alone with required libraries. As I saw, those are updating quite often and are not compatible sometimes (?). Also I read about deleting some part in the "SSD1306" library which did not work out for me.


My Board

Thank you

PS: I am new to "arduino" things

Hi tester232,

Adafruit has an excellent library for the SSD1306 OLED.

A comprehensive tutorial can be found here:

To run the OLED, you'll require the Adafruit GFX library:,

...and the SSD1306 library:

The SSD1306 library comes with its own test example sketch, found in the examples directory.

Thats what I already installed. I came accross a post telling me to download a modified SSD1306 package. However then things didnt work.

Now I installed like the most recent one again and get this error when trying to run the example code:

C:\Users\x\Documents\Arduino\libraries\Adafruit_SSD1306\Adafruit_SSD1306.cpp: In member function 'virtual void Adafruit_SSD1306::drawPixel(int16_t, int16_t, uint16_t)':

C:\Users\x\Documents\Arduino\libraries\Adafruit_SSD1306\Adafruit_SSD1306.cpp:114:14: error: 'swap' was not declared in this scope

     swap(x, y);

Thats what I already installed. I came accross a post telling me to download a modified SSD1306 package. However then things didnt work.

You should never believe random stuff from the Internet.

If you do want to "experiment" with random stuff, post a link to it. Then readers can offer advice.

Your title says 0.91 inch. But your link shows the common 0.95 inch SSD1306 (128x64) As the Original Poster, you can correct the title if necessary.

I built the ssd1306_128x64_i2c example from the library. (changing Slave address to 0x3C)

Using library SPI at version 1.0 in folder: C:\Users\David Prentice\AppData\Local\Arduino15\packages\arduino\hardware\samd\1.8.6\libraries\SPI 
Using library Wire at version 1.0 in folder: C:\Users\David Prentice\AppData\Local\Arduino15\packages\arduino\hardware\samd\1.8.6\libraries\Wire 
Using library Adafruit_GFX_Library at version 1.9.0 in folder: C:\Users\David Prentice\Documents\Arduino\libraries\Adafruit_GFX_Library 
Using library Adafruit_SSD1306 at version 2.2.1 in folder: C:\Users\David Prentice\Documents\Arduino\libraries\Adafruit_SSD1306 
Using library Adafruit_BusIO at version 1.3.2 in folder: C:\Users\David Prentice\Documents\Arduino\libraries\Adafruit_BusIO 
"C:\\Users\\David Prentice\\AppData\\Local\\Arduino15\\packages\\arduino\\tools\\arm-none-eabi-gcc\\7-2017q4/bin/arm-none-eabi-size" -A "C:\\Users\\DAVIDP~1\\AppData\\Local\\Temp\\arduino_build_313821/ssd1306_128x64_i2c.ino.elf"
Sketch uses 35152 bytes (13%) of program storage space. Maximum is 262144 bytes.
Global variables use 3660 bytes of dynamic memory.

It built and ran just fine on my M0_Pro. Please compare your library version numbers. Note that Adafruit update their libraries very frequently. (Sometimes breaking their working code.)


Dear David,

Thanks for trying to help, I kept getting the same error when trying to compile example code from the ssd1306 example list. Indepently from what Board I’ve selected I kept getting the same error. I also run the same example sketch like you.

After re-installing all libraries it worked!
I had to change the .h file to select the screen i use (e.g. 128/64 instead of the selected 128/32
Thanks a lot!

For completition:
The previous post where I read something on the internet: I was referring to this (the only OLED SAMD21 post i could find on
Perhaps I misunderstood the post:
This Post here

Also I am unable to confirm what SPI and Wire version I am currently running.

But it runs now!

Thank you David!