Memorial day is 05/25/2015 – Orders will ship out on May 26th. There will not be any deliveries or shipping on Monday. Any order placed after 11am ET on Friday May 22nd will not start to ship out until Tuesday May 26th.

SSD1306 garbled bitmap & clearDisplay resets
Moderators: adafruit_support_bill, adafruit

SSD1306 garbled bitmap & clearDisplay resets

by gary4132 on Tue Mar 12, 2013 5:11 pm

I recently purchased a Monochrome 1.3" 128x64 OLED graphic display, item 938 from adafruit and I'm having a couple issues that I've been unable to resolve.

The first one I came across is that whenever I use the display.clearDisplay(); command, even in the setup portion of the program, the program seems to reset. It proceeds no further and jumps back to the start. In the example below, I never get the "Display cleared" message. This is plugged into an Arduino Nano with an Atmega168, by the way.

// 128x64 oled test
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
//#include <RTClib.h>

//! OLED display wired per tutorial.
#define OLED_DC 11
#define OLED_CS 12
#define OLED_CLK 10
#define OLED_MOSI 9
#define OLED_RESET 13

//! Initialize the sketch.
void setup() {
// Initialize the serial connection for debugging.
Serial.println(F("Serial initialized"));

// Initialize the OLED.
Serial.println(F("OLED initialized"));

// Clear the display and draw hour/minute clock rectangles.
Serial.println(F("Display cleared"));

//! Main execution loop.
void loop() {

Which is why I inserted the display.display(); line, to make sure the display was actually working at all. But problem two is that the splashscreen comes out garbled. I checked all my wiring and it all looks fine. Can anybody clue me in on what might be happening here?

ssd1306.JPG (165.23 KiB) Viewed 613 times

Posts: 1
Joined: Tue Mar 12, 2013 4:38 pm

Re: SSD1306 garbled bitmap & clearDisplay resets

by adafruit_support_bill on Sun Mar 17, 2013 7:42 am

Double-check all the connections. Breadboard connections tend to be flakey. If the jumper isn't firmly gripped by the spring connectors, try and adjacent hole.

Posts: 37483
Joined: Sat Feb 07, 2009 10:11 am

Re: SSD1306 garbled bitmap & clearDisplay resets

by adafruit_support_rick on Sun Mar 17, 2013 10:50 am

Actually, the problem is the ATmega168 on the Nano. The 168 only has 1K of SRAM, and with the 128x64 display, the SSD1306 library requires 1K of SRAM for the display buffer alone.

The garbled image you see is essentially the entire contents of SRAM. Calling clearDisplay () wipes out the entire contents of SRAM.

Posts: 18369
Joined: Tue Mar 15, 2011 11:42 am
Location: Buffalo, NY

Re: SSD1306 garbled bitmap & clearDisplay resets

by buton on Tue Mar 26, 2013 8:29 am

indeed, the adafruit library is great but eats lots of RAM.

my solution to that is getting a bigger microconcontroller like the mega 2560... and then no problems at all. it cost money but is worth it.
Posts: 54
Joined: Fri May 11, 2012 8:06 am