1/**
2 * TCA9548 I2CScanner.ino -- I2C bus scanner for Arduino
3 *
4 * Based on https://playground.arduino.cc/Main/I2cScanner/
5 *
6 */
7
8#include "Wire.h"
9
10#define TCAADDR 0x70
11
12void tcaselect(uint8_t i) {
13 if (i > 7) return;
14
15 Wire.beginTransmission(TCAADDR);
16 Wire.write(1 << i);
17 Wire.endTransmission();
18}
19
20
21// standard Arduino setup()
22void setup()
23{
24 while (!Serial);
25 delay(1000);
26
27 Wire.begin();
28
29 Serial.begin(115200);
30 Serial.println("\nTCAScanner ready!");
31
32 for (uint8_t t=0; t<8; t++) {
33 tcaselect(t);
34 Serial.print("TCA Port #"); Serial.println(t);
35
36 for (uint8_t addr = 0; addr<=127; addr++) {
37 if (addr == TCAADDR) continue;
38
39 Wire.beginTransmission(addr);
40 if (!Wire.endTransmission()) {
41 Serial.print("Found I2C 0x"); Serial.println(addr,HEX);
42 }
43 }
44 }
45 Serial.println("\ndone");
46}
47
48void loop()
49{
50}