Tiny4kOLED icon indicating copy to clipboard operation
Tiny4kOLED copied to clipboard

Need to detect OLED connected - otherwise program locks

Open Billybob42 opened this issue 6 months ago • 1 comments

Hello, is there a way to detect if the OLED is connected before sending the oled.begin? I have an application where I want to connect the OLED just for monitoring and troubleshooting, otherwise the OLED is removed. However, when I remove the OLED the program locks up during the oled.begin(xxxxxxx) statement if the oled isn't present.

I'm used to the adafruit library where you can use this code:

if(!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) { // Address 0x3D for 128x64 Serial.println(F("SSD1306 allocation failed")); for(;;); }

Is there anything similar in Tiny4kOLED or some method I can detect if the OLED is connected within my program?

Billybob42 avatar Jun 11 '25 13:06 Billybob42

If you define TINY4KOLED_QUICK_BEGIN then the check that the screen is available, is skipped. See https://github.com/datacute/Tiny4kOLED/blob/master/src/Tiny4kOLED_Wire.h#L50

You can then call Wire.beginTransmission and Wire.endTransmission, checking the result.

datacute avatar Jun 13 '25 05:06 datacute