Arduino not working with OLED display

I have 3 arduino nano clones (Lafvin Nano), none of which seem to work with OLED screens. I purchased an OLED screen off of amazon, tried an Adafruit example with all 3 of my nanos, and it didnt work. I made sure my wiring was correct, and I am almost 100% sure that I am wiring it up correctly through my tens of times checking it against the diagrams, with the pulldown resistors and everything. Eventually, I assumed the display must be broken, so I sent it back and ordered 3 more. To my surprise, these screens did not work either! Is it possible that my clones are not compatible with OLED screens?

Post a link to your Nano e.g. Ebay sale Post a link to your OLED e.g. Amazon sale

Post a photo of your wiring.

I am impressed with anyone sending items back. Ok for a local shop. But expensive and slow if you are returning to China.

It is wiser to ask for help on the Forum first. If the item is proved to be faulty, ask for your money back from Ebay, Amazon, .... More sensible than returning items to a foreign country.

David.

I had a similar problem: OLED arrived - ultracheap stuff via Aliexpress - no documentation

Very important: which driver? My OLED display is a 7-pin SPI 128x64 OLED display controlled by a SSD1308, with a 128x16 upper strip yellow pixels and below that a 128x48 whitish-blue pixel field

// pins on the Arduino
#define OLED_SCK 13
#define OLED_MOSI 11 // MOSI eauivalent of pin SDA
#define OLED_CS 10
#define OLED_DC 9
#define OLED_RES 8

u8glib constructor : U8GLIB_SSD1306_128X64 u8g(OLED_SCK, OLED_MOSI, OLED_CS, OLED_DC, OLED_RES);

It took some hours of headache, but now it is working fine :slight_smile:

photoncatcher:
I had a similar problem: OLED arrived - ultracheap stuff via Aliexpress - no documentation

Very important: which driver? My OLED display is a 7-pin SPI 128x64 OLED display controlled by a SSD1308, with a 128x16 upper strip yellow pixels and below that a 128x48 whitish-blue pixel field

Whether you bought from Ebay, AliExpress, Amazon, … you can provide a link to your particular item.

Even if you bought from a local shop, you can still find the exact item on Ebay etc.
Or at least say “it looks similar except for X, Y, Z, … difference”

It is important for readers to be able to see the pcb. Not 100%. But it is a pretty good identification if you can compare pcb layout, traces, printed legends …

Do you really have SSD1308 ?
You seem to use a SSD1306 constructor.

David.

My arduino clones: https://www.amazon.com/LAFVIN-Board-ATmega328P-Micro-Controller-Arduino/dp/B07G99NNXL/ref=sr_1_3?keywords=arduino+nano&qid=1565585522&s=gateway&sr=8-3

The OLED Screens: https://www.amazon.com/dp/B076PNP2VD/ref=twister_B07HRDC7DC?_encoding=UTF8&th=1

Photo of my wiring attached

IMG_3147.jpg

You trying to save electrons?

Remove the two resistors. There are already pullups on the display pcb.

The Slave address is 0x3C. If you are using Adafruit_SSD1306 library:

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

void setup()
{
   oled.begin(SSD1306_SWITCHCAPVCC, 0x3C);
   ...

Buy some new coloured jumper wire. e.g. use Red for VCC. Black for GND.
The Red and Blue power lines on your breadboard are normally used for + and -

Following colour conventions will make your head hurt less.

It looks as if your resistors are pulldown (connected to 0V). Hence the problem. Removing them will let the onboard pullup resitors work properly.

David.

[quote author=david_prentice date=1565644718 link=msg=4273099

… Do you really have SSD1308 ? You seem to use a SSD1306 constructor.

David.
[/quote]

Oops, a SSD1306, definitely, sorry, David! Here is a picture of front and back of ‘my’ Ali 128x96 OLED

and here is the sketch:
// OLED_128x64_nano_bare

// for use with SSD1308 Monochrome OLEDs
// essential fragments found on Henry’s Bench -
// this sketch by Floris Wouterlood
// august 12, 2019
// public domain

// libraries
#include “U8glib.h”

// pins on the Arduino
#define OLED_SCK 13
#define OLED_MOSI 11
#define OLED_CS 10
#define OLED_DC 9
#define OLED_RES 8
int j = 0;

// U8GLIB constructor OLED display
U8GLIB_SSD1306_128X64 u8g(OLED_SCK, OLED_MOSI, OLED_CS, OLED_DC, OLED_RES);

void draw(void) {

// led control
digitalWrite(3, HIGH);
delay(500);
digitalWrite(3, LOW);

u8g.setFont(u8g_font_unifont); // select font

// yellow rings in upper strip
for (j=28; j<109;j= j+10){
u8g.drawCircle( j,7,7);
}

// smiley
u8g.drawCircle(110, 50, 12); // contour
u8g.drawDisc (105, 50, 2); // eye
u8g.drawDisc (115, 50, 2); // eye
u8g.drawLine (106, 56, 108, 56); // mouth
u8g.drawLine (113, 56, 115, 56); // mouth
u8g.drawLine (107, 57, 14, 57); // mouth
u8g.drawPixel (105, 55); // mouth
u8g.drawPixel (116, 55); // mouth
u8g.drawStr( 0, 55, “Hello World”);
}

void setup(void) {
pinMode(3, OUTPUT);
u8g.setFont(u8g_font_unifont);
u8g.setColorIndex(1); // Instructs the display to draw with a pixel on. 0 = OFF, 1 = ON

}

void loop(void) {
u8g.firstPage();
do {
draw();
} while( u8g.nextPage() );
delay(500);
}

I have removed the resistors I had in place, and I purchased an actual name brand arduino nano from amazon. I am just trying to run the example code from the Adafruit SSD1306 library for the 128x64 I2C display type. It is still not working!
Another image of my setup:

I figured it out! Thanks to david_prentice who said that the address must be 0x3C. The example code had the address as 0x3D, not 0x3C. This simple change made it work. Thank you to everyone who contributed!

I have exactly the same pcb as the image in your link:

You could connect VCC pin to the Nano 5V pin instead of the 3.3V pin. The regulator (U2) will provide the correct voltage to the SSD1306.

I am sure that your Nano(s) will be 100%.

Most boards from China are made very well.

David.

I found a reasons for my case:
4-pins OLED & Adruino nano,
<Adafruit_GFX.h> and <Adafruit_SSD1306.h>
OLED_RESET 4 Address:0x3C

It works with nano Atmega328 (all four vendors) but fails with Atmega168 (all two vendors)

Of course it will fail. Your 128x64 requires 1024 bytes for a buffer. The mega168 has only got 1024 bytes of SRAM.

Most Arduino programs allocate memory at compile-time. Which means it can tell you if you are low in available memory.

The Adafruit_SSD1306 library used to work this. However it now chooses to allocate memory at run-time. Which means you do not get any prior warning that it will fail.

If you have a Serial port open, the Adafruit library prints a warning (I think) Otherwise, the program just crashes.

David.