This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Arduino 通过TCA9548A 或其他IIC扩展实现12个传感器的数据读取?

Other Parts Discussed in Thread: TCA9548A

求助 TCA9548A可以进行级联使用吗

  • 谢谢指导 很受益
  • 你好 我将两个TCA9548A进行级联以后 用端口检索程序检索不到第二片TCA9548A的地址 两片芯片没有问题

    /**
     * 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()
    {
    }