How to connect lcd-display with tca9548 ?

hi,
as i have a lot of interfaces to handle by Arduino Nano,
i try to use at least 3 expanders plus 1 lcd-display(hdd44780 2x16 0x27)

at first in my code try only with the display..

at tca9548 A0,A1,A2 are set to H,L,H for adress 0x75 to avoid any other device conflicting with 0x70

but using code from

pca9548 shows only the 8 ports to be recognized independent of
using 0x70 or 0x75 . Whats that ?

lcd is connected with pullup-resistors at Port 5,
pca9548 is conntected with A.nano with pullup-resistors on i2c-wires too !

Calling lcd.begin(0x27,16,2) shows status 252 (where to find the meaning of 252 ?)

So I guess PCA9548 in unable to register lcd for it.

Heres my code

/**
 * TCA9548 I2CScanner.ino -- I2C bus scanner for Arduino
 *
 * Based on https://playground.arduino.cc/Main/I2cScanner/
 *
 * tca_scanner2 : try to connect lcd-display 
 */

#include "Wire.h"

#include <hd44780.h>
#include <hd44780ioClass/hd44780_I2Cexp.h>

//#define TCAADDR 0x70
#define TCAADDR 0x75

#define PCA_PORTNUM_LCD 5

hd44780_I2Cexp lcd = hd44780_I2Cexp(0x27, 16, 2);
// LCD geometry
const uint8_t LCD_COLS = 16;
const uint8_t LCD_ROWS = 2;

void tcaselect(uint8_t i) {
  if (i > 7) return;
 
  Wire.beginTransmission(TCAADDR);
  Wire.write(1 << i);
  Wire.endTransmission();  
}

uint8_t lcd_status = 0;
String message = "";
// standard Arduino setup()
void setup()
{
    while (!Serial);
    delay(1000);

    Wire.begin();
    
    Serial.begin(115200);
    Serial.println("\nTCAScanner ready!");

  tcaselect(PCA_PORTNUM_LCD);
  lcd_status = lcd.begin(LCD_COLS, LCD_ROWS);
  Serial.println("LCD-Status : " + String(lcd_status));
  if (lcd_status) // non zero status means it was unsuccessful
  {
    // begin() failed so blink error code using the onboard LED if possible
    //hd44780::fatalError(status); // does not return
  }

  message = "tca_scanner2.ino for Nano";
  Serial.println(message);
  lcd.clear();
  lcd.print(message);
  delay(1000);
    
    for (uint8_t t=0; t<8; t++) {
      tcaselect(t);
      Serial.print("TCA Port #"); Serial.println(t);

      for (uint8_t addr = 0; addr<=127; addr++) {
        if (addr == TCAADDR) continue;

        Wire.beginTransmission(addr);
        if (!Wire.endTransmission()) {
          Serial.print("Found I2C 0x");  Serial.println(addr,HEX);
        }
      }
    }
    Serial.println("\ndone");
}

void loop() 
{
    for (uint8_t t=0; t<8; t++) {
      tcaselect(t);
      Serial.print("TCA Port #"); Serial.println(t);

      for (uint8_t addr = 0; addr<=127; addr++) {
        if (addr == TCAADDR) continue;

        Wire.beginTransmission(addr);
        if (!Wire.endTransmission()) {
          Serial.print("Found I2C 0x");  Serial.println(addr,HEX);
          delay(1000);
        }
      }
    }
    Serial.println("\ndone");
    delay(1000);
  
}

may be, i have tomatoes on the eyes again :smile:

Only one set of pullups are required on any I2C line.
It is possible the LCD and the 9548 already have these installed and your adding extra ones only makes it worst so-to-speak.
Each time you parallel these resistors, the overall resistance drops on a parallel resistance basis.
To confirm you need to show all the hardware you have there.

hi bluejets,
someone had written, every i2c-port of pca.., what is connected to any device,has to be 'armished' with pullup-resistors, and i2c-input of pca.. too !
true or not ?

hi,
meanwhile after testing with and without pullup resistors..seems that is not important here..
the result is, that

  • unused ports give 0x27
  • used ports give 0x27 and the adress of the device
  • one port gives the adresses of TWO devices : this seems mysterious to me
    checking wires i didnt find any additional unwanted connection

in detail its the default adress of the wellknown PWM-Expander 0x40
and additionally 0x70 !
the adress of PCA9548 is 0x75 i had set by A0,A1,A2..

any idea ?

i'm glad to inform you that controlling led's
with more than one device at tca9548 works.. :grinning:
now i have to install mcp23017 and pwm-expander..
but all with patience.. :relieved:
the multiple adresses at port 4 seems not to have any meaning.. :face_with_open_eyes_and_hand_over_mouth: