OLED full color, DHT11 and UNO problem

Hello all. I think my OLED full color display is defective. When I load the code it displays for a second then goes dark. If I reset the UNO it may (or may not) display for a second, and go blank. I have the UNO unplugged for 24 hours and when I connected this morning it worked for about 2-3 minutes, then went dark.

Below is the code. I am not a programmer, so I also suspect the OLED might be fine, and its just my poor code. The libraries are the most recent…I double checked.

If anyone can help (confirm it should work, or if code is wrong) I would appreciate it. Thanks!

//*************************************************************
//THIS CODE WORKS - Serial monitor displays the temp and humidity, but the OLED appears to be dead.
//*************************************************************

#include <DHT.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1331.h>
#include <SPI.h>

// You can use any (4 or) 5 pins
#define sclk 13
#define mosi 11
#define cs 10
#define rst 9
#define dc 8

#define DHTPIN 2 // do not connect to pin 0 or pin 1
#define DHTTYPE DHT11 // Define DHT11 module

// Color definitions
#define BLACK 0x0000
#define BLUE 0x001F
#define RED 0xF800
#define GREEN 0x07E0
#define CYAN 0x07FF
#define MAGENTA 0xF81F
#define YELLOW 0xFFE0
#define WHITE 0xFFFF
Adafruit_SSD1331 display = Adafruit_SSD1331(&SPI, cs, dc, rst);
//Adafruit_SSD1331 display = Adafruit_SSD1331(cs, dc, mosi, sclk, rst);
float p = 3.1415926;

DHT dht(DHTPIN, DHTTYPE);

void setup() {
dht.begin();
display.begin();
Serial.begin(9600);
Serial.println(“DHT11 Sensor”);
Serial.println(“setup section”);

}

void loop() {
float h = dht.readHumidity();
float f = dht.readTemperature(true); // Read temperature as degrees Fahrenheit (set to “true”)
delay(2000); // 2 second delay between readings
Serial.println("In the void/display loop ");
Serial.print("H ");
Serial.println(h);
Serial.print("T ");
Serial.println (f);

display.fillScreen(BLACK);
display.setCursor(0, 5);
display.setTextColor(GREEN);
display.setTextSize(3);
display.println("DISP!AY ");
display.print("H “);
display.print(” ");
display.println(f);
display.println(h);
delay(1000);
// display.endWrite();
}

Could you take a few moments to Learn How To Use The Forum.
It will help you get the best out of the forum in the future.
Other general help and troubleshooting advice can be found here.