1

I have a strange issue while trying to run the hello world code on an arduino nano connected to an OLED display.

This is the code I used:

    #include <Adafruit_SSD1306.h>
Adafruit_SSD1306 display = Adafruit_SSD1306(128, 64, &Wire);

void setup() {

  // SSD1306_SWITCHCAPVCC = generate display voltage from 3.3V internally
  display.begin(SSD1306_SWITCHCAPVCC, 0x3C); // Address 0x3C for 128x32

  display.display();
  delay(2000);

  display.clearDisplay();      //this line to clear previous logo
  display.setTextColor(WHITE); //without this no display
  display.print("Hello World!");//your TEXT here
  display.display();            //to shows or update your TEXT
}

void loop() {

 }

But I get this on the display. OLED

enter image description here

Any idea what I could be missing?

Thanks !

zanga
  • 21
  • 4
  • Do you have the product link of your display? – Fahad Oct 18 '21 at 08:37
  • I had this display laying around for a while, unfortunately I can't find the product link. – zanga Oct 18 '21 at 08:44
  • Is the driver IC SSD1306? Can you see that at the back of the display? – Fahad Oct 18 '21 at 08:48
  • Not sure where can I see that, I added a picture with the back. – zanga Oct 18 '21 at 08:57
  • Why are you using Adafruit_SSD1306 library? It is possible that the display driver is not SSD1306. Also, from your second picture, it looks like the address is `0x78`. In the code, you are using `0x3C`. Also, show us how did you connect the display with Arduino Nano. – Fahad Oct 18 '21 at 09:24
  • Also, check if the display I2C pins have pull-ups. – Fahad Oct 18 '21 at 09:29
  • @Fahad This doesn't look like an I2C problem, but rather something with the font handling (note that the "H" and "W" are correct, but the rest of the letters are somewhat off (L=E, S=L, etc.) I'd try reinstalling the library. – PMF Oct 18 '21 at 09:54
  • Good point. I have seen other people said sometimes Chinese manufactured display have the address `0x7A` but works with `0x3C`. But the pull-up can be a problem. If there is no pull-up, the floating state can generate `garbage` data. – Fahad Oct 18 '21 at 10:10
  • 3
    0x7A is 0x3C << 1 which is correct. I2C addresses are 7 bits and the 8th bit (rightmost) is use as a R/W flag. So you shift the I2C address one to the left and then add a 1 or 0 to the left for read/write operation (I forget which way around it is). The Arduino library does that for you, so you need to provide the "unshifted" address of 0x3C. – Majenko Oct 18 '21 at 14:07

1 Answers1

1

Mystery solved :)

After some more reading it appears that the display driver is actually SH1106, so after using the right library I got the display working.enter image description here

zanga
  • 21
  • 4