Electronic – SSD1306 Display SPI Connection or I2C (According to resistors)

atmegadisplayoled

I bought one of those cheap 0.96" OLED Displays from china, ebay.
In the product description it states that it's a I2C Display, Ebay Link.
I want to use it with an ATmega8.

I connected it accordingly to the tutorials I found online:

  • Pin1, GND: GND
  • Pin2, VCC: VCC (3.3V)
  • Pin3, D0: Pin28, SCL (Pullup to 5V)
  • Pin4, D1: Pin27, SDA (Pullup to 5V)
  • Pin5, RST, PORTB.0
  • Pin6, DC: PORTB.2
  • Pin7, CS: PORTB.1

and this is my code (99% the same as on the library's github page):

#define F_CPU 1000000
#include <util/delay.h>
#include <stdint.h>
#include "libs/SSD1306.h"

int main(void){

    DDRB=0xFF;
    DDRC=0xFF;


    PORTB = PORTB & ~(1<<PB0);
    PORTB = PORTB & ~(1<<PB1);
    PORTB = PORTB | (1 << PB0);
    _delay_ms(100);

    // This is our buffer
    // Each byte = 8 pixels on the screen
    uint8_t buffer[1024];

    // Only two lines of code to initiate the driver
    // and to send our framebuffer
    SSD1306 myDisplay;
    PORTB = PORTB | (1 << PB2);
    myDisplay.sendFramebuffer(buffer);

    PORTB = PORTB & ~(1<<PB2);
    // Hardware function to reverse the pixels
    // (swap black and white pixel)
    myDisplay.invert(1);
    // Revert back to normal display
    myDisplay.invert(0);

    return 0;
}

I use (or want to use) this library: Github
Just because I found it and thought it looked nice, could use another as well.

What I checked so far is:

  • Cable connections are okay and as described above
  • System clock is 1 MHz
  • Tested another display

In every case, the display remains dark and black, not even a flickering.

When I looked at the backside of the display, I thought the description is strange (see the attached image).
Display Backside

There is written, that for IIC connection, resistors R1, R4, R6, R7 and R8 would need to be connected, while, in fact, only R3, R4 are connected, what would correspond to SPI connection. Am I misinterpreting something or was the ebay description wrong?

Can anyone help me?
Kind Regards
Me

Best Answer

Based on previous answer.

  1. Move the resistor from position R3 to R1.

  2. Connect R8.

Result:

enter image description here

Example of usage:

enter image description here

Code (sketch):

#include <Arduino.h>
#include <U8x8lib.h>     //Using u8g2 library

U8X8_SSD1306_128X64_NONAME_SW_I2C u8x8(  /* clock=*/ 12,   /* data=*/ 11, /* reset=*/ U8X8_PIN_NONE);   // OLEDs without Reset of the Display

void setup(void)
{
  u8x8.begin();
  u8x8.setPowerSave(0);

  u8x8.setFont(u8x8_font_pxplusibmcgathin_f);
  u8x8.drawString(0,0,"Hello World 209!");
  u8x8.drawString(0,3,"1234567890123456");
  u8x8.drawString(0,7,"Hello World 209!");
}

void loop(void)
{
}