QT PY does not work with 128x32 I2C OLED Display

Please tell us which board you are using.
For CircuitPython issues, ask in the Adafruit CircuitPython forum.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
jimk123
 
Posts: 708
Joined: Sun Dec 26, 2010 7:04 pm

QT PY does not work with 128x32 I2C OLED Display

Post by jimk123 »

// Adafruit METRO M0 Express - designed for CircuitPython - ATSAMD21G18 PRODUCT ID: 3505 - WORKED
// Adafruit HUZZAH32 – ESP32 Feather Board - with Stacking Headers PRODUCT ID: 3619 - WORKED
// Adafruit QT Py - SAMD21 Dev Board with STEMMA QT PRODUCT ID: 4600 - FAILS DISPLAY IS BLANK
// Monochrome 0.91" 128x32 I2C OLED Display - STEMMA QT / Qwiic PRODUCT ID: 4440

I am trying to use the OLED display above with the QT PY with the Arduino IDE but nothing displays. I used the same code on the ESP32 and Metro M0 and it is ok. Using the Stemma quick connectors so no wiring per say. The code is a simple test program to display 3 lines of text. I do not get an errors compiling or loading but the display is blank.

I added some serial print lines to setup and it seems to hang on the line:
if(!display.begin(SSD1306_SWITCHCAPVCC, 0x3C))

in the serial window I only see SETUP

The libraries are current:
adafruit ssd1306 2.4.2
adafruit GFX 1.10.4


Thanks

Code: Select all

 
// Adafruit METRO M0 Express - designed for CircuitPython - ATSAMD21G18 PRODUCT ID: 3505 - WORKED !
// Adafruit HUZZAH32 – ESP32 Feather Board - with Stacking Headers PRODUCT ID: 3619 - WORKED !
// Adafruit QT Py - SAMD21 Dev Board with STEMMA QT PRODUCT ID: 4600 - FAILS DISPLAY IS BLANK
// Monochrome 0.91" 128x32 I2C OLED Display - STEMMA QT / Qwiic PRODUCT ID: 4440

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

#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 32 // OLED display height, in pixels


#define OLED_RESET     4 // Reset pin # (or -1 if sharing Arduino reset pin)
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);



void setup() {
   Serial.begin(115200);
  while (!Serial) delay(10);
Serial.println("SETUP");
  // SSD1306_SWITCHCAPVCC = generate display voltage from 3.3V internally
  if(!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) { // Address 0x3C for 128x32
    Serial.println(F("SSD1306 allocation failed"));
    //for(;;); // Don't proceed, loop forever
  }
Serial.println("READY");

  // Show initial display buffer contents on the screen --
  // the library initializes this with an Adafruit splash screen.
  display.display();
  delay(2000); // Pause for 2 seconds

  // Clear the buffer
  display.clearDisplay();

  // Draw a single pixel in white
  display.drawPixel(10, 10, SSD1306_WHITE);

  // Show the display buffer on the screen. You MUST call display() after
  // drawing commands to make them visible on screen!
  display.display();
  delay(2000);
  // display.display() is NOT necessary after every single drawing command,
  // unless that's what you want...rather, you can batch up a bunch of
  // drawing operations and then update the screen all at once by calling
  // display.display(). These examples demonstrate both approaches...

 

 
test();
 // testdrawchar();      // Draw characters of the default font

 

  
}

void test()
{
  display.clearDisplay();
display.setTextSize(1);
 display.setTextColor(SSD1306_WHITE); 
 display.setTextColor(WHITE, BLACK);
display.setCursor(0,0);  // row 1
display.print("Signal quality is 1");    
display.setCursor(0,12);  // row 2
display.print("Network Offline");
display.setCursor(0,24);  // row 3
display.print("22:09;34 19.09.55");
//display.setCursor(0,36);
//display.print("hello world");
//display.setCursor(0,48);
//display.print("sending a new message"); // max message length to fill screen

 display.display();
delay(2000);
}


void loop() {
}





void testdrawchar(void) {
  display.clearDisplay();

  display.setTextSize(1);      // Normal 1:1 pixel scale
  display.setTextColor(SSD1306_WHITE); // Draw white text
  display.setCursor(0, 0);     // Start at top-left corner
  display.cp437(true);         // Use full 256 char 'Code Page 437' font

  // Not all the characters will fit on the display. This is normal.
  // Library will draw what it can and the rest will be clipped.
  for(int16_t i=0; i<256; i++) {
    if(i == '\n') display.write(' ');
    else          display.write(i);
  }

  display.display();
  delay(2000);
}




User avatar
jimk123
 
Posts: 708
Joined: Sun Dec 26, 2010 7:04 pm

Re: QT PY does not work with 128x32 I2C OLED Display

Post by jimk123 »

Adafruit tech support ?

User avatar
adafruit_support_carter
 
Posts: 29168
Joined: Tue Nov 29, 2016 2:45 pm

Re: QT PY does not work with 128x32 I2C OLED Display

Post by adafruit_support_carter »

Just to be sure - this is the OLED you are trying to use?
https://www.adafruit.com/product/4440

User avatar
jimk123
 
Posts: 708
Joined: Sun Dec 26, 2010 7:04 pm

Re: QT PY does not work with 128x32 I2C OLED Display

Post by jimk123 »

Correct, #4440
Thanks

User avatar
adafruit_support_carter
 
Posts: 29168
Joined: Tue Nov 29, 2016 2:45 pm

Re: QT PY does not work with 128x32 I2C OLED Display

Post by adafruit_support_carter »

It could be related to reset behavior. You mention using only the STEMMA QT cable to connect the QT PY to the OLED. But in your code you are defining a reset pin:

Code: Select all

#define OLED_RESET     4 // Reset pin # (or -1 if sharing Arduino reset pin)
Is that actually wired up also? If not, try changing to -1.

4 would be SDA on the QT PY for ref:
https://learn.adafruit.com/adafruit-qt- ... -3073174-3

User avatar
jimk123
 
Posts: 708
Joined: Sun Dec 26, 2010 7:04 pm

Re: QT PY does not work with 128x32 I2C OLED Display

Post by jimk123 »

that was it ! thank you so much !

User avatar
RaphaelTetreault
 
Posts: 1
Joined: Fri Jul 23, 2021 4:42 pm

Re: QT PY does not work with 128x32 I2C OLED Display

Post by RaphaelTetreault »

Just wanted to say this thread helped me out!

Using a generic I2C SSD1306 board wired to a QT PY. #define OLED_RESET -1 did the trick and no pull-up resistors were required.

Locked
Please be positive and constructive with your questions and comments.

Return to “Itsy Bitsy Boards”