NOT READING SENSOR ADDRESS ON ADAFRUIT TCA9548A MUX BREAKOUT

Post here about your Arduino projects, get help - for Adafruit customers!

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
User avatar
adafruit_support_bill
 
Posts: 88154
Joined: Sat Feb 07, 2009 10:11 am

Re: NOT READING SENSOR ADDRESS ON ADAFRUIT TCA9548A MUX BREA

Post by adafruit_support_bill »

The tcaselect example code works well for a single multiplexer. but it does not allow you to de-select all channels. So when using multiple TCA9548, each multiplexer will have at least one channel active at all times.

Code: Select all

void tcaselect(uint8_t i) {
  if (i > 7) return;
 
  Wire.beginTransmission(TCAADDR);
  Wire.write(1 << i);
  Wire.endTransmission();  
}
To deselect all channels, you need to write a 0 to the multiplexer. If you modify tcaselect as follows, you can turn off all channels by passing a -1.

Code: Select all

void tcaselect(uint8_t i) {
  if (i > 7) return;

  if (i < 0){
    Wire.beginTransmission(TCAADDR);
    Wire.write(0);
    Wire.endTransmission();  
    return;
  }
 
  Wire.beginTransmission(TCAADDR);
  Wire.write(1 << i);
  Wire.endTransmission();  
}

User avatar
MICK_1985
 
Posts: 3
Joined: Tue Oct 16, 2018 7:33 pm

Re: NOT READING SENSOR ADDRESS ON ADAFRUIT TCA9548A MUX BREA

Post by MICK_1985 »

Thanks for your answer. It worked with just changing the type of variable from uint8_t to int8_t so it could take the (-1) negative value to deselect all channels.

Thanks for the quick response.

User avatar
adafruit_support_bill
 
Posts: 88154
Joined: Sat Feb 07, 2009 10:11 am

Re: NOT READING SENSOR ADDRESS ON ADAFRUIT TCA9548A MUX BREA

Post by adafruit_support_bill »

Good to hear. Thanks for the follow-up.

User avatar
john_galt
 
Posts: 78
Joined: Thu Oct 29, 2015 6:49 am

Re: NOT READING SENSOR ADDRESS ON ADAFRUIT TCA9548A MUX BREA

Post by john_galt »

Mick,

Could you pleas share your modified "tsaselect" function? I'm having a heck of a time
getting mine to work.

Thank you,


Doug

User avatar
MICK_1985
 
Posts: 3
Joined: Tue Oct 16, 2018 7:33 pm

Re: NOT READING SENSOR ADDRESS ON ADAFRUIT TCA9548A MUX BREA

Post by MICK_1985 »

john_galt wrote:Mick,

Could you pleas share your modified "tsaselect" function? I'm having a heck of a time
getting mine to work.

Thank you,


Doug
Doug,

This is what I got working

void tcaselectmc2(int8_t i){
if (i > 7) return;
if (i < 0){
Wire.beginTransmission(TCAADDRMC2);
Wire.write(0);
Wire.endTransmission();
return;
}
Wire.beginTransmission(TCAADDRMC2);
Wire.write(1<<i);
Wire.endTransmission();
}

I changed the function variable from uint8_t to int8_t so it will take a negative value. I have three MUX in my project and this is for mux2 every time I want to activate one for the channels on mux2 I pass the value (o to 7) and pass (-1) to the other two mux to deactivate them.

void MuxPortDeactivator (int port){

switch(port){
case 1:
tcaselectmc2(-1);
tcaselectmc3(-1);
break;
case 2:
tcaselectmc1(-1);
tcaselectmc3(-1);
break;
case 3:
tcaselectmc2(-1);
tcaselectmc1(-1);
break;
}
}

I call this function every time I want to change the multiplexer I'm going to read and pass the number of the mux I want to read so the other two get deactivated.

Hope this helps.

Cheers.

User avatar
john_galt
 
Posts: 78
Joined: Thu Oct 29, 2015 6:49 am

Re: NOT READING SENSOR ADDRESS ON ADAFRUIT TCA9548A MUX BREA

Post by john_galt »

Mick,

Thank you so much! Now I think I may be able to get mine working.

Doug

Locked
Please be positive and constructive with your questions and comments.

Return to “Arduino”