I intend on using two VL6180X Time of Flight Range Sensors simultaneously to measure distance; to do this I am using a TCA9548A multiplexer. The microcontroller i am using is an Arduino Uno. I posted a picture of the schematic of my circuit. As of right now i'm only testing one flight sensor.
Here is the code I am using to scan my multiplexer for devises:
/**
TCA9548 I2CScanner.pde -- I2C bus scanner for Arduino
Based on code c. 2009, Tod E. Kurt, http://todbot.com/blog/
*/
#include "Wire.h"
#include <TCA9548A.h>
#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()
{
Wire.begin();
Serial.begin(9600);
Serial.println("\nTCA9548A Scanner 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++) {
// Don't report on the TCA9548A itself!
if (addr == TCAADDR) continue;
// See whether a device is on this address
Wire.beginTransmission(addr);
// See if something acknowledged the transmission
int response = Wire.endTransmission();
if (response == 0) {
Serial.print("Found I2C 0x"); Serial.println(addr, HEX);
}
}
// Slow the loop scanner down a bit
delay(1000);
}
Serial.println("\nScan completed.");
}
void loop()
{
}
This is the output I receive after uploading the code to my UNO
TCA9548A Scanner ready!
TCA Port #0
TCA Port #1
TCA Port #2
TCA Port #3
TCA Port #4
TCA Port #5
TCA Port #6
TCA Port #7
Scan completed.
The output is supposed to display the address that the device uses under the port or bus that the devise is connected to.
TCA Port #0
TCA Port #1
Found I2C 0x29
TCA Port #2
TCA Port #3
TCA Port #4
TCA Port #5
TCA Port #6
TCA Port #7
Scan completed.
I'm concerned that I may have damaged the Multiplexer. I applied 5V to every single pin on the multiplexer while it was attached to my bread board to verify that I wasn't using a bad bread board pin and I feel that may have done it.
I would also like to add that i'm getting a 5V value going to my SDA and SDA pins on the time of flight sensor.
If anyone can provide me input as to why the multimeter isn't reading the senor I would be much appreciated.
I'm concerned that I may have damaged the Multiplexer. I applied 5V to every single pin on the multiplexer while it was attached to my bread board to verify that I wasn't using a bad bread board pin and I feel that may have done it.
That's a quite bad idea. Applying a voltage to any pin is definitely not a clever debugging strategy.
In your wiring diagram you didn't connect the address pins of the TCA9548A. Having these pins floating you cannot reliably address the multiplexer. To use 0x70 as the I2C address you have to connect all three pins to GND.
The TCA9548a is connected in a way in which the assigned address is 0x70. I also included two 10k resistors to be used as resistor pull ups; the 10k resistors connect from 5v to SDA and SCL on the TCA9548a multiplexor.
I would like to know why my Arduino cant find my multiplexor. I tested the scanner on a time of flight sensor and it was able to find its address which was 0x29. Not sure why the scanner was able to find the time of flight sensor but not the multiplexor.
Any insight would be much appreciated.