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