Help getting started with a I2C OLED

I ordered a few of these OLEDs off ebay:

In the picture they have 4 pins , but the ones I received have 6 (GND, VCC, D0, D1, RST, DC)

I'm having a hard time getting this display to work. the listing has a link to the u8glib github for arduino source code and hook up guide, but it doesn't mention I2C displays at all. I downloaded the library and uploaded the Hello World example using U8GLIB_SSD1306_128X64 u8g(U8G_I2C_OPT_NONE);

The screen stayed black and so since I know adafruit's OLEDs use a reset pin, I tried their library but still no luck. after poking around the forum I found this:

I tried using Oliver's modified library that gets around the no acknowledgement but still I appear to be SOL.

I'm sure I have VCC, GND, D0 and D1 hooked up correctly, based on the datasheet D0 is the SCLK and D1 is SDA. For the DC pin I tried connecting it between ground and 3.3V to see if either of those were the right addresses but neither worked. Here's the datasheet:

I did also try using the I2C sniffer code, to see if I could find out what the address is, but because there's no acknowledge, the code doesn't detect the display.

Can anyone help me figure out what I'm missing or what I need to do to get these up and running?

To me this looks more like a SPI version of the OLED. This would explain, why all attempts with I2C will fail. You display also does not look like the version on ebay.

Maybe U8GLIB_SSD1306_128X64(sck, mosi, cs, a0, reset) will work. sck = d0 mosi = d1 a0 = dc reset = rst cs = ???

the missing cs pin is an issue. Sometimes these displays have another pad on the backside, which is labeld "CS". How does the other side of the display look like? If there is a CD pad on the other side, this should be also connected to a digital out pin of the Arduino board (and the pin number must be given as 3rd arg to the u8glib constructor).


Thanks for the response.

Here's a picture of the bottom of the board.

I still think it's set up as an I2C, not sure why mine doesn't look like the picture. If you go to page 13 and 14 of the datasheet they list the pinout of the controller. And So it makes sense that they brought out those pin for I2C

For I2C, the DC line is not required, however it is mandatory for SPI, this is why i still think, that this is a SPI device.


Thank you Oliver for insisting on SPI. Your profile quote seems relevant, and I’ve given you a +1 on your karma.

I also referenced off another OLED forum post you commented in:

I used U8GLIB_SSD1306_128X64 u8g(10, 9, 2); // HW SPI Com: CS = 10, A0 = 9 (Hardware Pins are SCK = 13 and MOSI = 11)
After ignoring CS and A0=DC and connecting reset to 2, my display is working.

Good, that David's wisdom has helped somehow and good to see, that you display is working now.


I know this is an old thread, but I ran across one of these too and the above wasn't overly clear for a newbie so I thought I'd add a couple comments to maybe help other newbies. (note: D2 was used in my sketch, so I use D12)

OLED -> Arduino

GND -> GND VCC -> 3.3 or 5V D0 (SCL) -> D13 D1(MOSI) -> D11 RST (RESET) -> D12 DC (DATA) -> D9 Not connected, but the software uses D10, so don't use it in your sketch.

If using the U8GLIB they have several settings commented out and tell you to uncomment the one you need. The one you need isn't there, use this one:

U8GLIB_SSD1306_128X64 u8g(10, 9, 12);

If using the ADAFruit library it comes setup for software SPI and you need to comment that section out and uncomment and modify the hardware SPI section. Here's how it should look:

// If using software SPI (the default case): //#define OLED_MOSI 9 //#define OLED_CLK 10 //#define OLED_DC 11 //#define OLED_CS 12 //#define OLED_RESET 13 //Adafruit_SSD1306 display(OLED_MOSI, OLED_CLK, OLED_DC, OLED_RESET, OLED_CS);

// Uncomment this block to use hardware SPI // With hardware SPI pin 13 hooks to D0 (SCL) // and pin 11 hooks to D1 (MOSI) in additon to the // following pin hookups

define OLED_DC 9

define OLED_CS 10 //not hooked up to 6 pin OLED, but still used by software

define OLED_RESET 12

Adafruit_SSD1306 display(OLED_DC, OLED_RESET, OLED_CS); //

The U8GLIB examples are broke down into examples for specific things, the ADAfruit one has them all combined and you need to extract what you want to do.

The ADAfruit library imports a GFX library also, though I haven't experimented yet, I wonder if it couldn't be left out if you aren't doing graphics, just doing text to the screen. If so then a space savings may be had.

olikraus: For I2C, the DC line is not required, however it is mandatory for SPI, this is why i still think, that this is a SPI device.

Actually the 1306 supports "3-wire" SPI where the D/C bit is passed as part of the data stream instead of being implemented as a separate line.