0.96 inch, 1.3 inch, 0.91 inch OLED display Arduino ESP32 guide white screen proble I2C address scanner code

1. Universal Example code works in all display with U8G2 library

#include <Arduino.h>
#include <U8g2lib.h>
#include <Wire.h>

// For 0.91" OLED (SSD1306 128x32):
//U8G2_SSD1306_128X32_UNIVISION_F_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE);

// For 0.96" OLED (SSD1306 128x64):
//U8G2_SSD1306_128X64_NONAME_F_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE);

// For 1.3" OLED (SH1106 128x64):
U8G2_SH1106_128X64_NONAME_F_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE);
// --------------------------------------------------------------------------------

void setup() {
  u8g2.begin();
}

void loop() {
  u8g2.clearBuffer();         // clear the internal memory
  u8g2.setFont(u8g2_font_ncenB08_tr); // choose a suitable font
  u8g2.drawStr(0,10,"Hello World!");  // write something to the internal memory
  u8g2.sendBuffer();          // transfer internal memory to the display
  delay(1000);  
}









2. I2C Scanner Code- https://github.com/futuristiciox/P345._I2C_Address_Scanner_All_Connected_2026_sketch_jan29a

3. Example 2:

#include <Arduino.h> #include <U8g2lib.h> #include <Wire.h> // --- UNCOMMENT YOUR DISPLAY TYPE --- // U8G2_SSD1306_128X32_UNIVISION_F_HW_I2C u8g2(U8G2_R0, U8X8_PIN_NONE); // 0.91" U8G2_SSD1306_128X64_NONAME_F_HW_I2C u8g2(U8G2_R0, U8X8_PIN_NONE); // 0.96" // U8G2_SH1106_128X64_NONAME_F_HW_I2C u8g2(U8G2_R0, U8X8_PIN_NONE); // 1.3" void setup() { u8g2.begin(); } void loop() { // Array of fonts from small to large const uint8_t* fonts[] = { u8g2_font_6x10_tr, // Small u8g2_font_ncenB12_tr, // Medium u8g2_font_ncenB18_tr, // Large u8g2_font_logisoso24_tr // Extra Large }; for (int i = 0; i < 4; i++) { u8g2.clearBuffer(); // 1. Draw "Pixel Dust" (Random dots to test background pixels) for (int dots = 0; dots < 50; dots++) { u8g2.drawPixel(random(128), random(64)); } // 2. Set Font and Calculate Centering u8g2.setFont(fonts[i]); int width = u8g2.getStrWidth("Hello"); // Get width of text in pixels int x = (128 - width) / 2; // Center horizontally int y = (u8g2.getDisplayHeight() / 2) + (i * 2); // Center vertically-ish // 3. Draw the Zooming Text u8g2.drawStr(x, y, "Hello"); u8g2.sendBuffer(); delay(600); // Pause so you can inspect the pixels } // 4. Final Full-Screen Flash (The ultimate "Dead Pixel" check) u8g2.clearBuffer(); u8g2.drawBox(0, 0, 128, 64); u8g2.sendBuffer(); delay(500); }

Comments