Monochrome OLED using u8g2 lib on esp32, failed working properly

Im using esp32, voltage divider and monochrome OLED.

Since the monochrome OLED failed to detect I2C address, I proceed with u8g2 lib. However, the display is not stable. Sometimes its shows, sometime it won't and sometimes it give random trash display. I don't know which part of my programming is wrong. Is it something usually happen when using u8g2 lib?

Please post a link to the actual item that you have bought e.g. Ebay Sale page

Im using esp32, voltage divider and monochrome OLED.

You should never use a voltage divider on I2C. Especially when your ESP32 has 3.3V GPIO logic levels.

David.

Even without the voltage divider, still the oled display sometimes work and sometimes wouldnt't work. direct connection.

Hi wanrulez, welcome.

You've told very little about what display you are using, so we'll have to do some guessing.
It's more likely for this to be a hardware problem than it is a problem with your code.

Quite a while ago, some forum members had similar problems.
I did too, and found a thread about that.
After a while, i found a cause and a "solution" for my display, so have a
look here (click !) to see about that.
It may help you out, but no guarantees.