Many digital accelerometers on 8 channel i2c multiplexer

Good evening to all,

I would like your help with my plan.

I am using the latest Arduino IDE software and have successfully installed the Libraries of the components i use.

A) Arduino Mega 2560 Rev3 (Code: A000067)
B) Mega Shield v1.2 (SKU 103020027)

When I use the examples it does not output any real data from the 3 axis accelerometer.
But I have different problems (address recognition and device amounts).

The SET UP that I want to succeed with your help is the following.

  1. Connect 3 items OF 3-Axis Digital Accelerometer(±16g) (SKU 101020054 )
    ON TO Grove - 8 Channel I2C Multiplexer / I2C Hub (TCA9548A), (SKU 103020293)

AND
2) Connect 2 items OF 3-Axis Digital Accelerometer(±16g) (SKU 101020054 )
ON TO the other Grove - 8 Channel I2C Multiplexer / I2C Hub (TCA9548A), (SKU 103020293)

How I mast combine the codes and Libraries

Thank you in advance for the answers or Advices

Panos

Hi @panosza75, what problem are you facing now? can you please elaborate?

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);
}