// 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);
}