Dual Displays ? If ok then a problem writing text to OLED display


I have a ham radio transceiver project testing using a Mega with a 3.5 inch TFT display and a RTC.

I wanted to use a small 132 x 28 Oled display alongside to display various bits of info, but mostly as an ‘S’ meter reporting received signal strength. This already works within the main code to the 3.5 inch TFT

As it stands at the moment the code and TFT all work successfully.

Now I would like to use the oled display alongside this and am not sure if this is possible.

I bought an ebay .91 inch oled display for i2c with just 4 pins (no reset pin)

I loaded the Adafruit SSD1306 library. I set the line for SSD1306 i2c for 128x32 in the .h file.

I tested the display with the demo code and it all went swimmingly. Logo, text, graphics etc.

Now, in my code I had this amongst my includes —

//############### OLED Display ###########
#include <Adafruit_SSD1306.h>
Adafruit_SSD1306 display(-1);  // -1 = no reset pin
#define OLED_ADDR   0x3C       // i2c address

and this in setup running first after Wire etc. —

// OLED Setup and clear logo
  display.begin(SSD1306_SWITCHCAPVCC, OLED_ADDR); // initialize with the I2C addr 0x3C (for the 128x32)
    display.println("Hello, Rob!");

However on loading the sketch all that happens is the display is blank. If I remove the display.clearDisplay(); then the logo is drawn but then nothing else happens on the oled display.

I tried a level shifter module but as it displays ok on the test program I don’t think this is needed. It made no difference anyway.

I tried an i2c scan and the three devices used all have unique addresses.

I commented out the RTC stuff as I thought there may be a clash but no joy.

What am i missing here?

To me it seems if the logo and display clear work then the display should display the text ok.


In the sketch infront of the setup is the includes and definitions only.

Then in setup, first there is Wire.begin() followed by the oled code as in post. Then the tft code.

As I understood it, program execution order means all the includes and definitions are set, then setup is run top to bottom order. So in theory the first bit of code run after setting the includes and defines should be the oled display code. It will run the logo if i remove the clear instruction.

So does running the display clear mean it is accepting the code line and moves on then to what should be the text display.

In reality it moves on ok to the next tft code. Even if I put a delay after the text display.display.

OK. This gets odder.

I created a test sketch with all my includes and defines.

Then setup with the oled and tft layout code.

Tested it and the oled text prints. So my basic setup works and the oled works.

However, if I add a simple on/off led function and call at end of setup then oled won't display

I created a test sketch with all my includes and defines.

But you didn’t post it.

Good luck.

Sorry I didn't see any point in posting the working code. I only added a led on/off.

It was more of a statement than a question.

I'm on a different computer at the moment but I will post it later.

Sorry I didn't see any point in posting the working code. I only added a led on/off.

Don't try and out-think a good optimiser. You'll lose.

Well, it turns out the text was there all along but 'invisible'.

About to post the test sketch when I did one more alteration to leave the logo displaying to show it worked.

I altered the text co-ordinate and suddenly it was part there in silhouette !

Seems setting WHITE has no effect. Unfortunately setting inverse didn't show it up.

Now I think it's a clash with the GFX_AS library I'm using for fonts or it's to do with definitions.

Sorry if I don't post my full code as it's 14 tabs in size.

@awol happy to send the full code to you personally if you think it would help.


Just ZIP up your project. It does not matter how many tabs you have. Attach the zip.

Even for single INO files, attaching a ZIP is convenient if too big to paste in a message..

The more I thought about it I was convinced it was a library problem.

I looked at Adafruit_ssd1306.h and altered the following to

define BLACK 1

define WHITE 0

define INVERSE 2

Now it sort of works but I have to specify black for white as black prints white.

It works for text and drawing.

Obviously this is a hack but as I know little about libraries I can't find what really needs changing.