Adafruit_SSD1306 128x32 screen artifacts over time

I’m using the Adafruit_SSD1306 128x32 display and have noticed over time that an artifact appears at the bottom of the screen over time. Normally my display shows the following:

SENSORS
FOUND
10

Over time it looks something like this:

SENSORS
FOUND
10


It is almost like the top row of pixels for the word SENSORS has ended up in the bottom row of the display.

My code within the loop to write to the display looks like this:

// START DISPLAY
display.clearDisplay();
display.setTextColor(WHITE);
display.setCursor(0,0);
display.println("SENSORS");
display.setCursor(0,12);
display.println("FOUND");
display.setCursor(0,24);
display.println(highWaterMark);
display.display();
// END DISPLAY

Any ideas why it is getting corrupted over time and what I can do inside the loop since I’m already clearing it before printing to it?
Thanks,
Tim

@sensorcheck, since you are setting the cursor before “printing” each item, you might want to use print() instead of println(). BTW, the “different” display examples don’t seem different. You may want to post pictures of the screen instead.

Good catch, thank you. Picture attached.
sensorcheck_ssd1306

It behaves like vertical drift which makes no sense since each iteration clears and then reprints the display. I will use print instead of println and report back.

Hi @sensorcheck

Maybe you should show us the code that you use to define and setup the display object?

1 Like

Hi @bko
Sure:

#define OLED_RESET D2
#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 32 // OLED display height, in pixels
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);

void setup() {    
    // Set needed pins for OLED
    // D0 - SDA
    // D1 - SCL
    // D2 - RST
    // D3 - GND
    // D4 - NUL
    // D5 - VIN
    pinMode(D3, OUTPUT);
    digitalWrite(D3, LOW);   // ground
    pinMode(D5, OUTPUT);
    digitalWrite(D5, HIGH);  // voltage

    // Splash screen
    delay(1000);
    display.begin();  // 128x32
    display.clearDisplay();
    display.setTextSize(1);
    display.setRotation(2);
    display.setTextColor(WHITE);
    display.setCursor(0,0);
    display.print("SENSOR CHECK");
    display.setCursor(0,12);
    display.print("COLLECTOR");
    display.setCursor(0,24);
    display.print(FIRMWARE);
    display.display();
    delay(5000);.
.
.
.
}

BTW, nice thing about this pin assignment with the display is that the pins align perfectly allowing for a female header on the breadboard and a male header on the display - no wiring.

The “print” appears to have solved the issue - so far looking good!

1 Like

@sensorcheck, a) what Particle device are you using? b) you should not be powering the OLED from GPIO pins if using Gen3 devices. If you are using a Photon, this is possible since the GPIO max current is higher.

1 Like

Hi @peekay123,
This is a boron running OS V2.0.1. Also, the artifact is back after continuous running. Screen shot attached.
screen_shot_scc_2

As peekay123 pointed out, are you really powering the display directly from the GPIO pins, not using a MOSFET or other transistor?

A SSD1306 can draw up to 25 mA and the pin drive strength on the nRF52840 (Boron) is 2 mA. Even in high drive mode it’s 9 mA, not enough to drive the display reliably.

1 Like

Hi @rickkas7, the voltage was a match and the pin alignment perfect. Thank you both for pointing out the draw mismatch. That said, do we think this is related to the artifact at the bottom of the display?

It wouldn’t surprise me if under-powering the display caused it to behave unpredictably, including display artifacts.

At least use pinSetDriveState to set both power pins to high drive. It may help.

Done. I also set display.dim(true) - not sure if this will lower power consumption given the simple text use case. Finally (and I think this speaks to the original symptom of the top line of pixels “drifting/wrapping”) I changed the first setCursor to start on row 1 instead of row 0. So far no artifacts!

1 Like