How to reset crashed OLED

I just posted this topic but in the wrong section, but its already gone, so here in the right section

I have an OLED shield for the WEMOS D1 mini. I have it in I2C mode connected together with a BME280 sensor on pins D1 and D2.

Everything works!!

However after a 'while' (haven't watched it happen yet) the screen turns black. The ESP is still communicating everthing, so thats still working.

When I reset the Wemos the screen pops on back on again.

2 Questions:

  1. how do i reset the wemos display ( one solution could simply be resetting the screen every hours or so)
  2. does anyone know the cause for this problem and how to resolve it?

In case its relevant:

Using U8G2 libs to run the OLED. with the following constructor:

U8G2_SSD1306_64X48_ER_F_HW_I2C u8g2(U8G2_R0);

And here's the code:

void updateOLED(){
  char output[16] = "";

  //full screen buffer method
  u8g2.clearBuffer();
  
  //show the dots on the screen edges
  drawOledBoundingboxes();

  //draw the current temp LARGE
  //arduino does not support floats, so convert to two integers pre and post dot. 
  int preDot = (int)currentT;
  int postDot = int((currentT - int(currentT))*10+0.5);
  snprintf(output,  sizeof(output), "%d.%d", preDot,postDot);
  u8g2.setFont(u8g2_font_helvB24_te);
  u8g2.drawStr(1,25,output);

  //draw the target temp small
  preDot = (int)targetT;
  postDot = int((targetT - int(targetT))*10+0.5);
  snprintf(output,  sizeof(output), "%d.%d", preDot,postDot);
  u8g2.setFont(u8g2_font_7x14_tr);
  u8g2.drawStr(1,47,output);  

  /*NOT RELEASED YET: U8G2 VERSION 2.22
  u8g2.setFont(open_iconic_thing_2x);
  u8g2.drawGlyph(33, 47, 0x004E);  // flame
  u8g2.setFont(open_iconic_weather_2x);
  u8g2.drawGlyph(16, 47, 0x0042);  // moon
  u8g2.setFont(open_iconic_embedded_2x);
  u8g2.drawGlyph(0, 47, 0x0048);  // wrench */

  //draw the heat and maintenance indicators
  u8g2.setFont(u8g2_font_7x14_tr);
  u8g2.drawStr(38,47,(maintenanceOn)? "M" : "");  
  u8g2.drawStr(56,47,(heatOn)? "H" : "");  

  //if H and M are not shown, show the humidity
  snprintf(output,  sizeof(output), "%d", (int)currentH);
  u8g2.drawStr(36,47,(!heatOn&&!maintenanceOn)? output : "");  
  
  //draw screen
  u8g2.sendBuffer();  
}

You could call u8g2.begin(). It should do a software reset.

Oliver

thnx. Ill give that a shot!

wolph42:
Everything works!!.......However after a 'while'

If it works at all, I submit that the only bit of code what would be noteworthy is a bit you don't show - your loop time. If a "while" is in fact more time than it takes to do a loop, the code could be innocent and you might be better off looking for the real problem, rather than "resetting the screen every hour or so", which may well be just a temporary fix any way. It could be that the screen goes dark because it is getting hot, so maybe the problem is in power supply.