0.96" OLED. No sign of life. -solved

So i got this 128x64 OLED from ebay. All i know that its SSD1306 and seller stated address to be 0x27 but back of display its 0x78?

I do have 4.7k pullups for SDA and SCL but the display is black.

I've tried adafruit and u8glib libraries but i dont even find how to define the display address?

adafruit lib gives me this error:

/*********************************************************************
This is an example for our Monochrome OLEDs based on SSD1306 drivers
************************************************************/

#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>

#define OLED_RESET 4
Adafruit_SSD1306 display(OLED_RESET);

#define NUMFLAKES 10
#define XPOS 0
#define YPOS 1
#define DELTAY 2


#define LOGO16_GLCD_HEIGHT 16 
#define LOGO16_GLCD_WIDTH  16 
static const unsigned char PROGMEM logo16_glcd_bmp[] =
{ B00000000, B11000000,
  B00000001, B11000000,
  B00000001, B11000000,
  B00000011, B11100000,
  B11110011, B11100000,
  B11111110, B11111000,
  B01111110, B11111111,
  B00110011, B10011111,
  B00011111, B11111100,
  B00001101, B01110000,
  B00011011, B10100000,
  B00111111, B11100000,
  B00111111, B11110000,
  B01111100, B11110000,
  B01110000, B01110000,
  B00000000, B00110000 };

#if (SSD1306_LCDHEIGHT != 64)
#error("Height incorrect, please fix Adafruit_SSD1306.h!");
#endif

void setup()   {                
  Serial.begin(9600);

  // by default, we'll generate the high voltage from the 3.3v line internally! (neat!)
  display.begin(SSD1306_SWITCHCAPVCC, [i]0x78[/i]);  // initialize with the I2C addr 0x3D (for the 128x64) // [i]might be the right place to put address?[/i]
  // init done
  
  display.display(); // show splashscreen
  delay(2000);
  display.clearDisplay();   // clears the screen and buffer

  // draw a single pixel
  display.drawPixel(10, 10, WHITE);
  display.display();
  delay(2000);
  display.clearDisplay();

  // draw many lines
  testdrawline();
  display.display();
  delay(2000);
  display.clearDisplay();

  // draw rectangles
  testdrawrect();
  display.display();
  delay(2000);
  display.clearDisplay();

  // draw multiple rectangles
  testfillrect();
  display.display();
  delay(2000);
  display.clearDisplay();

  // draw mulitple circles
  testdrawcircle();
  display.display();
  delay(2000);
  display.clearDisplay();

  // draw a white circle, 10 pixel radius
  display.fillCircle(display.width()/2, display.height()/2, 10, WHITE);
  display.display();
  delay(2000);
  display.clearDisplay();

  testdrawroundrect();
  delay(2000);
  display.clearDisplay();

  testfillroundrect();
  delay(2000);
  display.clearDisplay();

  testdrawtriangle();
  delay(2000);
  display.clearDisplay();
   
  testfilltriangle();
  delay(2000);
  display.clearDisplay();

  // draw the first ~12 characters in the font
  testdrawchar();
  display.display();
  delay(2000);
  display.clearDisplay();

  // draw scrolling text
  testscrolltext();
  delay(2000);
  display.clearDisplay();

  // text display tests
  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.display();
  delay(2000);

  // miniature bitmap display
  display.clearDisplay();
  display.drawBitmap(30, 16,  logo16_glcd_bmp, 16, 16, 1);
  display.display();

  // invert the display
  display.invertDisplay(true);
  delay(1000); 
  display.invertDisplay(false);
  delay(1000); 

  // draw a bitmap icon and 'animate' movement
  testdrawbitmap(logo16_glcd_bmp, LOGO16_GLCD_HEIGHT, LOGO16_GLCD_WIDTH);
}


void loop() {
  
}


void testdrawbitmap(const uint8_t *bitmap, uint8_t w, uint8_t h) {
  uint8_t icons[NUMFLAKES][3];
 
  // initialize
  for (uint8_t f=0; f< NUMFLAKES; f++) {
    icons[f][XPOS] = random(display.width());
    icons[f][YPOS] = 0;
    icons[f][DELTAY] = random(5) + 1;
    
    Serial.print("x: ");
    Serial.print(icons[f][XPOS], DEC);
    Serial.print(" y: ");
    Serial.print(icons[f][YPOS], DEC);
    Serial.print(" dy: ");
    Serial.println(icons[f][DELTAY], DEC);
  }

  while (1) {
    // draw each icon
    for (uint8_t f=0; f< NUMFLAKES; f++) {
      display.drawBitmap(icons[f][XPOS], icons[f][YPOS], logo16_glcd_bmp, w, h, WHITE);
    }
    display.display();
    delay(200);
    
    // then erase it + move it
    for (uint8_t f=0; f< NUMFLAKES; f++) {
      display.drawBitmap(icons[f][XPOS], icons[f][YPOS],  logo16_glcd_bmp, w, h, BLACK);
      // move it
      icons[f][YPOS] += icons[f][DELTAY];
      // if its gone, reinit
      if (icons[f][YPOS] > display.height()) {
	icons[f][XPOS] = random(display.width());
	icons[f][YPOS] = 0;
	icons[f][DELTAY] = random(5) + 1;
      }
    }
   }
}


void testdrawchar(void) {
  display.setTextSize(1);
  display.setTextColor(WHITE);
  display.setCursor(0,0);

  for (uint8_t i=0; i < 168; i++) {
    if (i == '\n') continue;
    display.write(i);
    if ((i > 0) && (i % 21 == 0))
      display.println();
  }    
  display.display();
}

void testdrawcircle(void) {
  for (int16_t i=0; i<display.height(); i+=2) {
    display.drawCircle(display.width()/2, display.height()/2, i, WHITE);
    display.display();
  }
}

void testfillrect(void) {
  uint8_t color = 1;
  for (int16_t i=0; i<display.height()/2; i+=3) {
    // alternate colors
    display.fillRect(i, i, display.width()-i*2, display.height()-i*2, color%2);
    display.display();
    color++;
  }
}

void testdrawtriangle(void) {
  for (int16_t i=0; i<min(display.width(),display.height())/2; i+=5) {
    display.drawTriangle(display.width()/2, display.height()/2-i,
                     display.width()/2-i, display.height()/2+i,
                     display.width()/2+i, display.height()/2+i, WHITE);
    display.display();
  }
}

void testfilltriangle(void) {
  uint8_t color = WHITE;
  for (int16_t i=min(display.width(),display.height())/2; i>0; i-=5) {
    display.fillTriangle(display.width()/2, display.height()/2-i,
                     display.width()/2-i, display.height()/2+i,
                     display.width()/2+i, display.height()/2+i, WHITE);
    if (color == WHITE) color = BLACK;
    else color = WHITE;
    display.display();
  }
}

void testdrawroundrect(void) {
  for (int16_t i=0; i<display.height()/2-2; i+=2) {
    display.drawRoundRect(i, i, display.width()-2*i, display.height()-2*i, display.height()/4, WHITE);
    display.display();
  }
}

void testfillroundrect(void) {
  uint8_t color = WHITE;
  for (int16_t i=0; i<display.height()/2-2; i+=2) {
    display.fillRoundRect(i, i, display.width()-2*i, display.height()-2*i, display.height()/4, color);
    if (color == WHITE) color = BLACK;
    else color = WHITE;
    display.display();
  }
}
   
void testdrawrect(void) {
  for (int16_t i=0; i<display.height()/2; i+=2) {
    display.drawRect(i, i, display.width()-2*i, display.height()-2*i, WHITE);
    display.display();
  }
}

void testdrawline() {  
  for (int16_t i=0; i<display.width(); i+=4) {
    display.drawLine(0, 0, i, display.height()-1, WHITE);
    display.display();
  }
  for (int16_t i=0; i<display.height(); i+=4) {
    display.drawLine(0, 0, display.width()-1, i, WHITE);
    display.display();
  }
  delay(250);
  
  display.clearDisplay();
  for (int16_t i=0; i<display.width(); i+=4) {
    display.drawLine(0, display.height()-1, i, 0, WHITE);
    display.display();
  }
  for (int16_t i=display.height()-1; i>=0; i-=4) {
    display.drawLine(0, display.height()-1, display.width()-1, i, WHITE);
    display.display();
  }
  delay(250);
  
  display.clearDisplay();
  for (int16_t i=display.width()-1; i>=0; i-=4) {
    display.drawLine(display.width()-1, display.height()-1, i, 0, WHITE);
    display.display();
  }
  for (int16_t i=display.height()-1; i>=0; i-=4) {
    display.drawLine(display.width()-1, display.height()-1, 0, i, WHITE);
    display.display();
  }
  delay(250);

  display.clearDisplay();
  for (int16_t i=0; i<display.height(); i+=4) {
    display.drawLine(display.width()-1, 0, 0, i, WHITE);
    display.display();
  }
  for (int16_t i=0; i<display.width(); i+=4) {
    display.drawLine(display.width()-1, 0, i, display.height()-1, WHITE); 
    display.display();
  }
  delay(250);
}

void testscrolltext(void) {
  display.setTextSize(2);
  display.setTextColor(WHITE);
  display.setCursor(10,0);
  display.clearDisplay();
  display.println("scroll");
  display.display();
 
  display.startscrollright(0x00, 0x0F);
  delay(2000);
  display.stopscroll();
  delay(1000);
  display.startscrollleft(0x00, 0x0F);
  delay(2000);
  display.stopscroll();
  delay(1000);    
  display.startscrolldiagright(0x00, 0x07);
  delay(2000);
  display.startscrolldiagleft(0x00, 0x07);
  delay(2000);
  display.stopscroll();
}

But i dont even have the reset pin on my display?
And that sketch gives me errors about arduinorobot.cpp.

Images of the display


error about arduinorobot:

D:\Dropbox\arduino\arduino-1.0.5\libraries\Robot_Control\ArduinoRobot.cpp: In constructor 'RobotControl::RobotControl()':
D:\Dropbox\arduino\arduino-1.0.5\libraries\Robot_Control\ArduinoRobot.cpp:8: error: 'LCD_CS' was not declared in this scope
D:\Dropbox\arduino\arduino-1.0.5\libraries\Robot_Control\ArduinoRobot.cpp:8: error: 'DC_LCD' was not declared in this scope
D:\Dropbox\arduino\arduino-1.0.5\libraries\Robot_Control\ArduinoRobot.cpp:8: error: 'RST_LCD' was not declared in this scope
D:\Dropbox\arduino\arduino-1.0.5\libraries\Robot_Control\ArduinoRobot.cpp: In member function 'void RobotControl::begin()':
D:\Dropbox\arduino\arduino-1.0.5\libraries\Robot_Control\ArduinoRobot.cpp:18: error: 'MUXA' was not declared in this scope
D:\Dropbox\arduino\arduino-1.0.5\libraries\Robot_Control\ArduinoRobot.cpp:18: error: 'MUXB' was not declared in this scope
D:\Dropbox\arduino\arduino-1.0.5\libraries\Robot_Control\ArduinoRobot.cpp:18: error: 'MUXC' was not declared in this scope
D:\Dropbox\arduino\arduino-1.0.5\libraries\Robot_Control\ArduinoRobot.cpp:18: error: 'MUXD' was not declared in this scope
D:\Dropbox\arduino\arduino-1.0.5\libraries\Robot_Control\ArduinoRobot.cpp:19: error: 'MUX_IN' was not declared in this scope
D:\Dropbox\arduino\arduino-1.0.5\libraries\Robot_Control\ArduinoRobot.cpp:22: error: 'BUZZ' was not declared in this scope
D:\Dropbox\arduino\arduino-1.0.5\libraries\Robot_Control\ArduinoRobot.cpp:25: error: 'Serial1' was not declared in this scope

The "Hello world" example from u8glib uploads fine but no dont see anything from my screen. Where do i even define address for it?

edit: ran the i2c scanner. hmm nothing found.

One of the problems indeed is, that the OLED might not react on the scanner. By default u8glib will use 0x78 (=0x03c*2), which is defined at the beginning of the file u8g_com_arduino_ssd_i2c.c.

#define I2C_SLA		(0x3c*2)

How did you connect the OLED?

Oliver

And what do i change the 0x3c*2 to if the display says 0x78?

Im using Arduino Nano and i got D5 = SCL and D4 = SDA. 4.7k pullups on SDA and SCL


Dont mind about the extra wiring. Its a testeb of mine :stuck_out_tongue:

And what do i change the 0x3c*2 to if the display says 0x78?

You can not change this, both values are equal: 0x3c multiplied with 2 will be 0x78. If you really want to, you can exchange 0x3c2 with 0x78.
Here is the prove for equality: 0x3c * 2 is equal to 0x30
2 + 0x0c*2
0x30 * 2 will be 0x60
0x0c * 2 is more complicated: hex 0xc equals 12 in decimal, multiplied with 2 is 24 (dezimal) which is 16 + 8 (both decimal). 16 (dezimal) is 0x10 hex and 8 is still 8,so 24 (dezimal) is 0x18 (hex).
Now we just have to add 0x60 with 0x018 which will be 0x78. QED.

You could also use a desktop calculator in hex mode to multiply 0x03c with 2

Actually, i am not sure about your wiring. I think it is not D4 and D5 but instead A4 and A5. Reconnect SDA and SCL to A4 and A5 of your board and try u8glib again
SDA = 18 = A4
SCL = 19 = A5

Oliver

Thanks for the reply.

Im all out of knowledge on this hex numbering. But i believe you that 0x3c*2 is ok for me.

About the pinout. According to this

the i2c is D5 and D4. Or is it?

I cant get my hands on to my board now but i might try later if you think i should.

Unfortunately your picture is wrong. See this picture from http://arduino.cc/en/Hacking/PinMapping168

I2C pins are shared with A4 and A5 (upper right).

The problem already exists on the Arduino web page for this device: http://arduino.cc/en/Main/ArduinoBoardNano: It mentions 4 and 5 instead of A4 and A5. See the comment "Nickerbocker 10.6.2013" on this page.

Oliver

Oh wow!

I even had to get up from bed to try this and guess what! Im reading "Hello World" very nicely here!

So i was on the right track but i got fooled :slight_smile: Its a shame that i googled that picture of nano and it was wrong. Could have saved me a lot. I did check the arduino's site about nano but still i thought that 4, and 5 was analog and not digital. Maybe because of the picture i watched before it.

Thank you very much for the library and for the help here!

Very good. Glad to read that it works now.

Oliver

same display... respond to scanner... but this is what appear :frowning:

Hi

It is good, that the device is seen by a scanner. But maybe your library has been setup incorrectly. Which library do you use and how did you setup the library?

Oliver

U8GLIB_SSD1306
i tried also the adafruit lib, the funny thing is that you can change library, but this random pixel stay as the same, no movements or changes...

from the seller:
Type OLED Display
Interface I2C
LED Colour White
Resolution 128x64
Viewing Angle 160°
Power Consumption 0.08W
Voltage 3-5V DC
Working Temperature -30 to 70°C
Driver IC SSD1306
Dimensions 27x27x4mm

Hi

If the random pixel apper, then usually some basic setup has happend, but data transfer does not work.
It might be the case, that you do not have sufficient power for the OLED. Once activated it draws a lot of current and with an unreliable power source, the voltage might drop so much, that the comminiction gets interrupted.

How do you power the OLED? maybe try to apply an external soruce.

Do you use level shifters?

Oliver

Hey Oliver, can you PLZ help me? I tried everything to solve this problem as far as I know. So, basically, I have 0.5 inch oled and arduino nano I tried the hello world on u8g. The OLed is not even blinking.

Alfredyoon:
Hey Oliver, can you PLZ help me? I tried everything to solve this problem as far as I know. So, basically, I have 0.5 inch oled and arduino nano I tried the hello world on u8g. The OLed is not even blinking.

Hi Alfredyoon

This is your second post, so please allow me to point out some tips in this forum. It makes sense to follow the ideas here: http://forum.arduino.cc/index.php/topic,148850.0.html

Especially you should not append your (new) problem to an existing thread. Instead, start a new thread.

Second, the only valid answer to your statement "I tried everything" is: The display is damaged, buy a new one.
So the question is: Is your sentence "I tried everything" correct?

Anyhow: If you want a better answer, you should provide much more information, see also the link above.

Oliver