Getting started with the Adafruit SSD1306 OLED (as sold in the Maker Kit)

The Particle Maker Kit comes with a cool little monochromatic 0.96" OLED screen but the one I received didn’t match any documentation online. It didn’t even have a model number on the PCB! If you find yourself in the same situation, this post will help you get up and running quickly.

My OLED came on a breakout board with 7 pins. Wire them as follows for Software SPI control:

OLED <-> Photon
  CS <-> D3
  DC <-> D2
 RST <-> D4
  D1 <-> D0
  D0 <-> D1
 VCC <-> 3V3
 GND <-> GND

Next, the demo code for the Adafruit SSD1306 needs some tweaking.
First, find the two #include lines at the top of the file:

#include "Adafruit_GFX.h"
#include "Adafruit_SSD1306.h"

Change them to this:

#include "Adafruit_SSD1306/Adafruit_GFX.h"
#include "Adafruit_SSD1306/Adafruit_SSD1306.h"

Next, comment out the hardware SPI config block and uncomment the software SPI block like so:

// software SPI:
#define OLED_MOSI   D0
#define OLED_CLK    D1
#define OLED_DC     D2
#define OLED_CS     D3
#define OLED_RESET  D4
Adafruit_SSD1306 display(OLED_MOSI, OLED_CLK, OLED_DC, OLED_RESET, OLED_CS);

/*
// hardware SPI
#define OLED_DC     D3
#define OLED_CS     D4
#define OLED_RESET  D5
Adafruit_SSD1306 display(OLED_DC, OLED_RESET, OLED_CS);
*/

Finally, comment out the entire random() function declaration:

int random(int maxRand) {
    return rand() % maxRand;
}

At this point, your code should compile and you can deploy the demo! Good luck!

1 Like

Slightly off-topic, but I just checked and the original repository for this library has been deleted. Also I bet people would appreciate it if your modifications were included in a new library.

Super helpful, thanks!

Got the hardware SPI working on my xenon (it’s radically faster). I had to use the following mappings:
OLED <-> Xenon
CS <-> A5 aka SPI_SS aka AS aka Pin 14
DC <-> D2 (Could be any digital pin) fyi DC=OLED Data/Command control line.
RST <-> D4 (Could be any digital pin)
D1 <-> SPI_MOSI aka MO aka Pin 12.
D0 <-> SPI_CLK aka SCK aka Pin 13.
VCC <-> 3V3
GND <-> GND

I’m not sure how you would ever know that D1 on the OLED is the MOSI or that D0 is the clock without trial and error.

#define OLED_DC D2 //Could be any digital input
#define OLED_CS A5 //SPI_SS
#define OLED_RESET D4 //Could be any digital input
Adafruit_SSD1306 display(OLED_DC, OLED_RESET, OLED_CS);

1 Like