PANOS ZACHAROULIS
20 Μαΐ 2020, 11:28 μ.μ. (BEFORE 4 DAYS)
TO: Salman
Hello Salman,
Thanks for asking about my problem.
In the original e mail I describe the materials I use.
From what I’ve read I mast find for each accelerator the address to determine it after in each accelerator code.
To do this, I use the code that gives the 8 Channel I2C Hub and I set all the inputs open.
After that i upload the code.
Instead of 5 accelerators that I temporarily put on the HUB ( I tried 2 or 3 also )
The result was only 2 in all cases (responding addresses).
If I put 1, it recognizes 1.
Scanning…
I2C device found at 0x53
I2C device found at 0x70
2 device(s) found
Please your advice.
INFO: COM3
See the code:
#include “TCA9548A.h”
// if you use the software I2C to drive, you can uncommnet the define SOFTWAREWIRE which in TCA9548A.h.
#ifdef SOFTWAREWIRE
#include <SoftwareWIRE.h>
SoftwareWire myWIRE(3, 2);
TCA9548A TCA;
#define WIRE myWIRE
#else
#include <Wire.h>
TCA9548A TCA;
#define WIRE Wire
#endif
#define SERIAL Serial
void setup()
{
SERIAL.begin(9600);
while(!SERIAL){};
// WIRE.begin(); (in the code does not exist space between // wire)
TCA.begin(WIRE);
//defaut all channel was closed
// TCA.openAll();(in the code does not exist space between // TCA)
// TCA.closeAll();(in the code does not exist space between // TCA)
TCA.openChannel(TCA_CHANNEL_0);
TCA.openChannel(TCA_CHANNEL_1);
TCA.openChannel(TCA_CHANNEL_2);
TCA.openChannel(TCA_CHANNEL_3);
TCA.openChannel(TCA_CHANNEL_4);
TCA.openChannel(TCA_CHANNEL_5);
TCA.openChannel(TCA_CHANNEL_6);
TCA.openChannel(TCA_CHANNEL_7);
}
void loop()
{
uint8_t error, i2cAddress, devCount, unCount;
SERIAL.println(“Scanning…”);
devCount = 0;
unCount = 0;
for(i2cAddress = 1; i2cAddress < 127; i2cAddress++ )
{
WIRE.beginTransmission(i2cAddress);
error = WIRE.endTransmission();
if (error == 0)
{
SERIAL.print(“I2C device found at 0x”);
if (i2cAddress<16) SERIAL.print(“0”);
SERIAL.println(i2cAddress,HEX);
devCount++;
}
else if (error==4)
{
SERIAL.print(“Unknow error at 0x”);
if (i2cAddress<16) SERIAL.print(“0”);
SERIAL.println(i2cAddress,HEX);
unCount++;
}
}
if (devCount + unCount == 0)
SERIAL.println(“No I2C devices found\n”);
else {
SERIAL.print(devCount);
SERIAL.print(" device(s) found");
if (unCount > 0) {
SERIAL.print(", and unknown error in “);
SERIAL.print(unCount);
SERIAL.print(” address");
}
SERIAL.println();
}
SERIAL.println();
delay(1000);
}