OLED SPI wiring Electron [SOLVED]

Hello :smile:

I’ve trying to get my OLED via SPI to work, but these pins are very confusing to me.

To the left is what my OLED reads, and on the right is the pins I’ve tried to use on my Electron
Data - D2
Clk - D4
DC/SA0 - D1 (?)
Rst - D6 (guess this can be any output pin?)
CS - D5
3v3 - 3V3
Vin - empty
Gnd - Gnd

Where do I go wrong? I’m interpreting the Data pin on the OLED to be the MOSI, and the DC/SA0 I’m not really sure about…

I’m using the Adafruit_ssd1306 library, with these commands:

#define OLED_MOSI   D2
#define OLED_CLK    D4
#define OLED_RESET D6
#define OLED_CS D5
#define OLED_DC D1

Adafruit_SSD1306 oled(OLED_MOSI, OLED_CLK, OLED_DC, OLED_RESET, OLED_CS); // Doesn't work
//Adafruit_SSD1306 oled(OLED_DC, OLED_RESET, OLED_CS); // Doesn't work either

The code compiles and all. I’m using the same code I’ve been running but on an I2C OLED, so I figure the code itself does not need any change apart from the parts above.

A link to the library you are using will help.

There are several topic that deal with this display and the respective library.
Have a look here

and use the pins in that post (even the comments only)

This is the lib used in that post

And this is how it should look when you build the SPI sample

I’m using the Web IDE and simply imported the Adafruit_SSD1306 lib.

I looked into that thread and copy-based all the definitions;

// use hardware SPI
// OLED_D0 -> A3 (SPI CLK)
// OLED_D1 -> A5 (SPI MOSI)
#define OLED_DC D3
#define OLED_CS D4
#define OLED_RESET D5

Adafruit_SSD1306 display(OLED_DC, OLED_RESET, OLED_CS);

The wiring:

Edit: Also used the example that you posted @ScruffR but no success. From the datasheets I’ve looked at there’s also no difference in pins between the core/photon and electron.

My OLED reads “Bus deafult SPI4”. Does this change something?

When I wrote

I was refering to these comments

// use hardware SPI
// OLED_D0 -> A3 (SPI CLK)
// OLED_D1 -> A5 (SPI MOSI)

A3 & A5 not D0 & D1

CLK -> A3
Data -> A5

1 Like

Did the trick!! Using hardware SPI. :slight_smile: Thanks a bunch!

1 Like

@ScruffR could you advise me on whether this display will work with Electron?

It has one less pin than the SPI display I’m using atm. Is this a 3-wire SPI? And what would I translate SCL & SDA to? Guessing SCL = SPI CLK and SDA = SPI MOSI? But how does the CS/SS work then?

@ftideman, if the link is the exact display, take a look at the back and tell us which of the R1, R2, R3 and R4 resistors are installed on the board. These configure the communication method. As pictured in the link, it is configured for 4-wire SPI.

1 Like

Yeah sorry @peekay123, I noticed that just after posting. Should be more well-read before asking.

So yeah it’s configured for 4-wire SPI. But where did the CS (presuming my translation of the SDA & SCL in my post above were correct) go? And can I run the display without it?

@ftideman, I did some digging and got to their site to download the arduino libraries. They are Adafruit libraries. Based on this, I’m not sure how they get 4-wire SPI but based on their Use demo.txt file:

Wireling Guide:
| OLED	Photon
| VCC	5V or 3.3V
| SCL	A3 (SCK)
| RES	D2 (or any GPIO pin)
| DC	D3 (or any GPIO pin)

#define OLED_CLK   A3  // OLED SCL
#define OLED_MOSI  A5  // OLED SDA
#define OLED_RESET D2  // OLED RES
#define OLED_DC D3     //OLED DC

#define OLED_CS A2     //CS pin has been connected to GND onboard, so we ignore this definition


Notice that there is no CS line. That’s because they tied it to GND on the board meaning you can’t have other devices on the SPI bus!!!


Thanks alot @peekay123 ! You’re gold :slight_smile:

Tried tying my CS line from my current screen to electron’s ground which works. And I’m not going to run any other SPI devices on my current setup so that’s completely fine!

1 Like