Go Down

Topic: TCA9548A I2C Multiplexer (Read 1 time) previous topic - next topic

TBOT

Hello, I just recently bought a TCA9548 Multiplexer. I followed the instructions on the adafruit website:
Link
When It wasn't working, I tried the Adafruit forums. But they said,

Quote
Looks like you are using an Arduino 101. That has an Intel Curie processor & I would not be surprised if there are substantial differences in the i2c support for it. You might try posting your question over on the Arduino.cc forums. They are the ones that maintain the libraries for the 101.
So, what should I do?

PaulRB

#1
Jan 23, 2018, 06:00 pm Last Edit: Jan 23, 2018, 06:02 pm by PaulRB
Hi and welcome to the forum.

You could perhaps read this.

TBOT

I know.
Here is my code:
Code: [Select]
/**
 * TCA9548 I2CScanner.pde -- I2C bus scanner for Arduino
 *
 * Based on code c. 2009, Tod E. Kurt, http://todbot.com/blog/
 *
 */

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

#define TCAADDR 0x70

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++) {
      tcaselect(t);
      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()
{
}


Here is my error:
Code: [Select]
Arduino: 1.8.5 (Windows 8.1), Board: "Arduino/Genuino 101"
IC:\Users\user\AppData\Local\Arduino15\packages\Intel\hardware\arc32\1.0.7\system/libarc32_arduino101/framework/include"  "-IC:\Users\user\AppData\Local\Arduino15\packages\Intel\hardware\arc32\1.0.7\cores\arduino" "-IC:\Users\user\AppData\Local\Arduino15\packages\Intel\hardware\arc32\1.0.7\variants\arduino_101" "-IC:\Users\user\AppData\Local\Arduino15\packages\Intel\hardware\arc32\1.0.7\libraries\Wire\src" "C:\Users\user\AppData\Local\Temp\arduino_build_997323\sketch\TCA9548A.ino.cpp" -o "C:\Users\user\AppData\Local\Temp\arduino_build_997323\preproc\ctags_target_for_gcc_minus_e.cpp"
C:\Users\user\Documents\Arduino\TCA9548A\TCA9548A.ino:10:74: fatal error: utility/twi.h: No such file or directory

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

                                                                          ^

compilation terminated.

Using library Wire at version 1.0 in folder: C:\Users\user\AppData\Local\Arduino15\packages\Intel\hardware\arc32\1.0.7\libraries\Wire
exit status 1
Error compiling for board Arduino/Genuino 101.


Maybe this?
Quote
fatal error: utility/twi.h: No such file or directory

robtillaart

Please use an up to date I2C scanner as this seems rather old

Check - https://playground.arduino.cc/Main/I2cScanner

or my multispeed one - https://github.com/RobTillaart/Arduino/tree/master/sketches/MultiSpeedI2CScanner
Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

TBOT

#4
Jan 29, 2018, 08:28 pm Last Edit: Jan 29, 2018, 08:49 pm by TBOT
Okay. Now, the code seems to be okay when I replaced it with arduino's code. I tried test plugging some sensors in, and I got:
Code: [Select]

Scanning...
No I2C devices found

Scanning...
I2C device found at address 0x70  !
done

It would keep repeating this pattern.

Go Up