Due to high demand expect some shipping delays at this time, orders may not ship for 1-2 business days.
0

ssd1306 display
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

ssd1306 display

by gadjet on Wed Oct 27, 2021 3:35 pm

HI,
I have an Arduino running an SSD 128x64 OLED display, the display writes Temp and Humidity values to the screen every 10 seconds or so and everything works fine with the display.setTextSize(2) but if I change the code to display.setTextSize(3) then it works for 2 or 3 updates then just stops, Im sure the Arduino crashes as well because I pulse an LED when the screen updates but the LED stops pulsing as well.

Also the values on the OLED display get slightly corruptes on the last update.

Any thoughts? could it be a bug?

gadjet
 
Posts: 11
Joined: Mon Jan 21, 2019 6:51 pm

Re: ssd1306 display

by adafruit_support_bill on Thu Oct 28, 2021 5:12 am

What kind of Arduino are you using? Also, please post your code.

adafruit_support_bill
 
Posts: 82477
Joined: Sat Feb 07, 2009 10:11 am

Re: ssd1306 display

by gadjet on Thu Oct 28, 2021 10:12 am

It's a custom PCB using an ATMEGA 328P-PU.

The main bit of code is below, in the setup if the setTextSize(2) is changed to setTextSize(3) it crashes after a few updates, left at 2 it runs day and night without issue.
Code: Select all | TOGGLE FULL SIZE
void setup() {
  pinMode(LED_BUILTIN, OUTPUT);
  display.begin(SSD1306_SWITCHCAPVCC, 0x3C);  // initialize with the I2C addr 0x3D (for the 128x64)
  aht.begin();
  display.clearDisplay();
  display.display();
  display.setTextSize(2);             // Draw 2X-scale text
  display.setTextColor(SSD1306_WHITE, SSD1306_BLACK);
}

void loop() {
  // Clear the buffer
  display.clearDisplay();
  sensors_event_t humidity, temp;
  aht.getEvent(&humidity, &temp);// populate temp and humidity objects with fresh data
  display.setCursor(0, 15);
  display.print(temp.temperature);
  display.println(" C");
  display.setCursor(0, 40);
  display.print(humidity.relative_humidity);
  display.print(" %rH");
  //display.print(F("0x")); display.println(0xDEADBEEF, HEX);
  display.display();
  //pulseLED();
  delay(20000);
}

2021-10-28 12.13.52-1small.jpg
2021-10-28 12.13.52-1small.jpg (558.72 KiB) Viewed 67 times

gadjet
 
Posts: 11
Joined: Mon Jan 21, 2019 6:51 pm

Re: ssd1306 display

by adafruit_support_bill on Thu Oct 28, 2021 11:32 am

Most likely a memory issue. The 328 has only 2K of SRAM and the 128x64 display takes up half of that just for the frame buffer.

This guide has some tips for diagnosing memory problems and optimizing memory usage: https://learn.adafruit.com/memories-of- ... ot-dot-dot

adafruit_support_bill
 
Posts: 82477
Joined: Sat Feb 07, 2009 10:11 am

Re: ssd1306 display

by gadjet on Thu Oct 28, 2021 12:41 pm

Thanks I'll have a read

gadjet
 
Posts: 11
Joined: Mon Jan 21, 2019 6:51 pm

Please be positive and constructive with your questions and comments.