128x32 Oled just won't work with Nano

Hello all.

Got a Nano connected to a 128x32 OLED. I know they work, as I have used them many times before (I have them on my breadboards).

Simple connections, including 4k7 pullups to +5v

But.... refuses to work

Checked the address with I2C scanner and that is correct

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

#define OLED_RESET     -1                     
Adafruit_SSD1306 display(128, 32, &Wire, OLED_RESET);                                                        



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

  if (!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) {
    Serial.println(F("SSD1306 allocation failed"));
    for (;;); 
  }

  //display.setTextWrap(false);
  display.setTextColor(SSD1306_WHITE);
  //display.setRotation(0);
  display.clearDisplay();
  display.drawRect(0, 0, 128, 32, SSD1306_WHITE);
  //display.drawRect(16, 0, 96, display.height(), SSD1306_WHITE);
  //display.setFont();
  //display.setTextSize(1);
}

void loop() {
}

Sometimes it is the line Adafruit_SSD1306 display(128, 32, &Wire, OLED_RESET); Occasionally I have found this actually needs to be Adafruit_SSD1306 display(128, 64, &Wire, OLED_RESET);

But... nothing. Just a blank screen with dots.

Any ideas?

Goddam.... I have literally been on this for 90 minutes.....

It's missing display.display(); after the draw command

:roll_eyes:

1 Like

Hi baffled2023
Well, your'e not the oinly one. happende to me several times.
Else . . . . . .device kaputt !
ciao, Photoncatcher

Always run an example sketch from the library to test your hardware before testing your own code.

1 Like

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.