Displaying on four 12C OLED's with a TCA9548A multilpexer

All, as part of a bigger project, I want one Nano to display some images on some OLEDs, and am trying to use one TCA9548A multiplexer to send those bmp’s to the relevant OLEDs.

I have written the attached sketch which compiles fine, and simply pulls the appropriate bmp from the PitsBMP.h file. However it is not displaying anything on any of the OLEDs

#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include <PitsBMP.h>

#define TCAADDR 0x70
void tcaselect (uint8_t i) {
  if (i > 7) return;

  Wire.beginTransmission(TCAADDR);
  Wire.write(1 << i);
  Wire.endTransmission();
}

#define SCREEN_WIDTH 128
#define SCREEN_HEIGHT 64

Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, -1);



void setup() {
  Serial.begin(9600);
  display.begin();
  Wire.begin();


  // Clear the buffer.
  display.clearDisplay();
  for (int i = 0; i < 7; i++) {
    tcaselect(i);



  }
  // Draw bitmap on the screen

  tcaselect(0);    //multiplex the required OLED
  display.drawBitmap(0, 0, image_data_bits1, 128, 64, 1);

  tcaselect(1);    //multiplex the required OLED
  display.drawBitmap(0, 0, image_data_bits2, 128, 64, 1);


  tcaselect(2);    //multiplex the required OLED
  display.drawBitmap(0, 0, image_data_bits3, 128, 64, 1);


  tcaselect(3);    //multiplex the required OLED
  display.drawBitmap(0, 0, image_data_bits4, 128, 64, 1);

}
void loop() {

  display.display();

}

I have tested both the PitsBMP.h file and the OLED displays so I know they work, I have run 12C scan and it correctly identifies the i2C address as 0x70, and I have verified that the wiring and PCB is good and without shorts or open circuits.

The Nano is connected to the TCA9548A and OLEDs as follows

Nano TCA9548A OLED1 OLED2
GND GND GND GND
5V VIN VIN VIN
A4 SCL
A5 SDA
SC1 SCL
SD1 SDA
SC2 SCL
SD2 SDA

So I’m left thinking that my syntax regarding the TCA9548A multiplexing is wrong. The multiplexer is one that I have also used sucessfully on a different project, although I have no way of independently testing it. As it does show the correct address using i2C scan I think it is OK

Is there something obviously wrong with how I have laid out the sketch?

Cheers

Les

Adafruit cleverly designed their Adafruit_SSD1306 library to fail on non-Adafruit screens.

99.9% 128x64 displays are hard-wired for Slave address 0x3C
Adafruit 128x64 displays are hard-wired for 0x3D

You need to call for each physical display

    display.begin(SSD1306_SWITCHCAPVCC, 0x3C);

I have not checked the source code but I am fairly confident that it will only allocate one 128x64 buffer but happily send the correct register initialisation commands to each display.

David.

Thanks - definitely helps, the 0x3C address is the correct one. I can now get all OLEDs to light up

I spliced in the code in each multiplexed OLED instance like this

 tcaselect(7);    //multiplex the required OLED
 
  display.begin(SSD1306_SWITCHCAPVCC, 0x3c);
  display.clearDisplay();
  display.drawBitmap(0, 0, image_data_bits2, 128, 64, 1);

However there is clearly some kind of conflict, as I can get individual OLED's working fine, but the others will be corrupted. The one that works fine changes depending on which ones are connected, so that seems to discount wiring. It also will display fine (with just the one OLED connected) then if you reset the arduino it then corrupts, with nothing else changing.

I am also finding that once it has displayed a certain bitmap, if you change the bitmap to be displayed, sometimes it will display the new bitmap, other times it will just show the old bitmap but with interference speckles in the background, and others it will just show a completely corrupted screen.

The way things can work in all the individual locations seems to indicate that there is not an issue with circuitry, although I checked again for shorts and open circuits just in case

So either the Adafruit library does not play well with the multiplexer or there is something in the way that I've written the sketch that is corrupting it.

Is there an alternative to the Adafuit library that would meybe be better suited?

Les

Paste your actual program.

You effectively have one software OLED object. You clear the buffer before writing to it. When finished drawing, you call display.display() to send the buffer contents off to the relevant physical OLED.

David.

Your comment on the display.display() statement was it - I simply had one statement at the end, by adding the statement to each multiplexed argument I got it working

Thanks again for the help

Les

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