[SOLVED] which OLED display do I have?

I bought an OLED display on eBay from a USA seller.

The description is I2C.

But in the Arduino sketch example that I downloaded, the sketch is using pins 8 and 9.

#include <Adafruit_ssd1306syp.h>
#define SDA_PIN 8
#define SCL_PIN 9
Adafruit_ssd1306syp display(SDA_PIN,SCL_PIN);
void setup()
{
  delay(1000);
  display.initialize();
}
void loop()
{
  display.drawLine(0, 0, 127, 63,WHITE);
  display.update();
  delay(1000);
  display.clear();
  display.setTextSize(1);
  display.setTextColor(WHITE);
  display.setCursor(0,0);
  display.println("Hello, world!");
  display.setTextColor(BLACK, WHITE); // 'inverted' text
  display.println(3.141592);
  display.setTextSize(2);
  display.setTextColor(WHITE);
  display.print("0x"); display.println(0xDEADBEEF, HEX);
  display.update();
  delay(2000);
  display.clear();
}

I looked on Adafruit website, but I don’t see a similar display.

Which library should I be using?

In researching this further, it looks like I have the choice of using u8g2 library or the Adafruit ssd1306 + GFX libraries.

And that I need to use I2C address of 0x3C instead of 0x78 because that is how the library is written.

For u8g2, use u8g2.setI2CAddress to change the address:

Also note that 0x03c and 0x078 are the same address, but for u8g2 use 0x078 as noted in the manual (0x03c multiplied by 2).

Oliver

What board are you using? Please notice that Uno and Mega have proper SCL and SDA marked pins, while on Nano you can use A4 and A5.

I'm quite sure you can't send SDA and SCL out of the digital pins O.o

About the library and oled model, I quote olikraus and add that if it's a no brand Oled (a chinese "clone" of the "original" Adafruit (even though the Adafruit is a clone of a commercial chinese Oled), you'll have to uncomment the "I2C/noname" one.

olikraus:
For u8g2, use u8g2.setI2CAddress to change the address:

u8g2reference · olikraus/u8g2 Wiki · GitHub

Also note that 0x03c and 0x078 are the same address, but for u8g2 use 0x078 as noted in the manual (0x03c multiplied by 2).

Oliver

Thank you.

Nicola_Fu:
I’m quite sure you can’t send SDA and SCL out of the digital pins O.o

I didn’t think so either. :slight_smile:

But that was in the sketch that I downloaded from the eBay seller’s webpage.
It could be code for a different display.

I am going to start with u8g2 library.

Wanted to provide an update.

The u8g2 library works.
I didn't do anything fancy. Tried the Hello World example.

Thank you, olikraus for giving us this library.

Just adding an update, which is that there is yet another library (quite recent)

which claims to be optimised for minimum resource use, for small controllers with skimpy RAM.

I'm trying it out right now and it seems to work fine.