0

I'm trying to connect a TCA9548a breakout to my nano (also tried using an uno), but it can't recognise it - using the i2c scanner it just hangs on 'scanning...'

I've tried everything suggested in similar posts - checking connections, adding/not adding pullups (this nano I think already has them) and checking other i2c devices using same setup (which work fine). If I connect another i2c device, without the TCA, and have the i2c scanner working well and finding it, then connect SCL from the TCA (whether or not SDA is also connected) the scanner hangs.

When I was checking connections with the tca connected, it did work just once, finding it. Haven't been able to repeat that though since, I can't remember exactly what I was doing at the time.

Any help please?

Thanks in advance

i2c scanner:

// --------------------------------------
// i2c_scanner
//
// Version 1
//    This program (or code that looks like it)
//    can be found in many places.
//    For example on the Arduino.cc forum.
//    The original author is not know.
// Version 2, Juni 2012, Using Arduino 1.0.1
//     Adapted to be as simple as possible by Arduino.cc user Krodal
// Version 3, Feb 26  2013
//    V3 by louarnold
// Version 4, March 3, 2013, Using Arduino 1.0.3
//    by Arduino.cc user Krodal.
//    Changes by louarnold removed.
//    Scanning addresses changed from 0...127 to 1...119,
//    according to the i2c scanner by Nick Gammon
//    http://www.gammon.com.au/forum/?id=10896
// Version 5, March 28, 2013
//    As version 4, but address scans now to 127.
//    A sensor seems to use address 120.
// Version 6, November 27, 2015.
//    Added waiting for the Leonardo serial communication.
//
//
// This sketch tests the standard 7-bit addresses
// Devices with higher bit address might not be seen properly.
//

#include <Wire.h>


void setup()
{
  Wire.begin();

  Serial.begin(115200);
  while (!Serial);             // Leonardo: wait for serial monitor
  Serial.println("\nI2C Scanner");
}


void loop()
{
  byte error, address;
  int nDevices;

  Serial.println("Scanning...");

  nDevices = 0;
  for(address = 1; address < 127; address++ )
  {
    // The i2c_scanner uses the return value of
    // the Write.endTransmisstion to see if
    // a device did acknowledge to the address.
    Wire.beginTransmission(address);
    error = Wire.endTransmission();

    if (error == 0)
    {
      Serial.print("I2C device found at address 0x");
      if (address<16)
        Serial.print("0");
      Serial.print(address,HEX);
      Serial.println("  !");

      nDevices++;
    }
    else if (error==4)
    {
      Serial.print("Unknown error at address 0x");
      if (address<16)
        Serial.print("0");
      Serial.println(address,HEX);
    }    
  }
  if (nDevices == 0)
    Serial.println("No I2C devices found\n");
  else
    Serial.println("done\n");

  delay(1000);           // wait 5 seconds for next scan
}

tca9548a scanner:

#include "Wire.h"  
extern "C" { 
#include "utility/twi.h"  // from Wire library, so we can do bus scanning
}

#define TCAADDR 0x74

void tcaselect(uint8_t i) {
  if (i > 7) return;

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


// standard Arduino setup()
void setup()
{
    while (!Serial);
    delay(1000);

    Wire.begin();

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

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

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

        uint8_t data;
        if (! twi_writeTo(addr, &data, 0, 1, 1)) {
           Serial.print("Found I2C 0x");  Serial.println(addr,HEX);
        }
      }
    }
    Serial.println("\ndone");
}

void loop() 
{
}
  • The arduino wire library has the bad habit to hang when the hardware i2c bus is wrong. If you use for example a cable instead of short seperate wires, or if the scl is connected to gnd or when pullup resistors are missing. The arduino nano has no pullup resistors, but the Wire library enables the internal pullup resistors, and that should work for short wires. Do you have a voltage meter to measure the scl and sda? They should be near 5v when the i2c bus is not used. – Jot Apr 8 at 21:54
  • Use the first scanner sketch to detect the tca multiplexer. Please forget that second sketch that calls twi_writeTo directly. That is an example from adafruit and I thing they made a terrible mistake by using the Wire library like that. Once the tca chip is working, then you can use the function tcaselect and scan each bus from the tca multiplexer. – Jot Apr 8 at 22:28
  • @Jot Neither sketch detects it. I've just got it connected with the simple blink sketch running on the nano, and a 2K87 pullup from SCL to the Nano +5v, and finding it's only at 1.4V. Is the tca broken perhaps? – Oliver Walters Apr 9 at 9:14
  • It might be broken. Does the tca VIN pin have 5v? On the backside of the tca module are solder pads with tiny connections for the pullup resistors for sda and scl. They are 10k and are default enabled. If you have the tca module on its own (nothing connected) and apply 5v to it, then you can measure the sda and scl pins. If they are low, then it is broken. – Jot Apr 9 at 9:19
  • OK. I've stupidly already soldered it and can't get to that side anymore. Is there a connection the other side to definitively tell me the same thing? Thanks – Oliver Walters Apr 9 at 9:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.