If oled connected-> initialise

Hello,

Hi have a project wich works perfectly fine, we need to initiate the oled within the setup part of the code.

But i want the oled display more as optional feature, is there a way to detect if there is an oled on the i2c bus?

Maybe the if statement/if case could be applied someone with some tips hints or perhaps an example?

Yes, you just ask whether the specific slave device is on the bus. e.g.

    Wire.beginTransmission(0x3C);
    byte result = Wire.endTransmission(1);

Read the Wire documentation for the result values Arduino - WireEndTransmission

99.9% of current SSD1306 / SH1106 style OLEDs will ACK correctly.

The first OLEDs to appear on the Ebay market did not ACK correctly. Unless your OLED is 5 years old you should have a good one.

David.

Thanks David, that little hint did it!

This topic was automatically closed after 66 days. New replies are no longer allowed.