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
|--------------
| GND	GND
| VCC	5V or 3.3V
| SCL	A3 (SCK)
| SDA	A5 (MOSI)
| 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

Adafruit_SSD1306 display(OLED_MOSI, OLED_CLK, OLED_DC, OLED_RESET, OLED_CS);

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!!!

2 Likes

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