0

Challenges With TCA9548A I2C Multiplexer and SHT75
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Challenges With TCA9548A I2C Multiplexer and SHT75

by Ehduino on Sat Jun 05, 2021 2:24 am

Hi, I'm having bit of a challenging time with getting the TCA9548A to talk to a Sensirion SHT75. Currently I am using an Arduino Micro to test the TCA9548A with the SHT75, the TCA9548A examples work fine and the SHT75 also works without the TCA9548A.
Below is the code I'm using, modified from: https://learn.adafruit.com/adafruit-tca ... t?view=all

Code: Select all | TOGGLE FULL SIZE
#include <TCA9548A.h>

/*
 * Query an SHT75 temperature and humidity sensor via an I2C
 * multiplexer TCA9548A clone of the ADAFruit development board
 * of the same name
 *
 * A simple example that queries the sensor every 5 seconds
 * and communicates the result over a serial connection.
 * Error handling is omitted in this example.
 */

 

#include <Sensirion.h>
#include <Wire.h>
#define TCAADDR 0x70

//int incomingByte = 0; // for incoming serial data

/*===============================================Sensirion variables

const uint8_t dataPin  =  20;
const uint8_t clockPin =  21;

float temperature;
float humidity;
float dewpoint;

Sensirion tempSensor = Sensirion(dataPin, clockPin);

/*===============================================End Sensirion variables

void tcaselect(uint8_t i) {
  if (i > 7) return;
  Wire.beginTransmission(TCAADDR);
  Wire.write(1 << i);
  Wire.endTransmission();
}

void setup()
{

  while (!Serial);
  delay(1000);

  Wire.begin();
 
  Serial.begin(9600);
 
}

void loop()
{
 
   tcaselect(1);

//    //send data only when you receive data:
//  if (Serial.available() > 0) {
//    // read the incoming byte:
//    incomingByte = Serial.read();
   
  tempSensor.measure(&temperature, &humidity, &dewpoint);

 

  Serial.print("Temperature: ");
  Serial.print(temperature);
  Serial.print(" C, Humidity: ");
  Serial.print(humidity);
  Serial.print(" %, Dewpoint: ");
  Serial.print(dewpoint);
  Serial.println(" C");
 
  delay(5000); 
}


Any help appreciated, I can take photos in the morning if requested.

Thanks!

Ehduino
 
Posts: 5
Joined: Sat Jun 05, 2021 2:07 am

Re: Challenges With TCA9548A I2C Multiplexer and SHT75

by adafruit_support_bill on Sat Jun 05, 2021 5:39 am

Please post photos showing all your soldering and connections.

adafruit_support_bill
 
Posts: 81544
Joined: Sat Feb 07, 2009 10:11 am

Re: Challenges With TCA9548A I2C Multiplexer and SHT75

by Ehduino on Sat Jun 05, 2021 11:22 am

Below are the photos:
IMG_0031.JPG
IMG_0031.JPG (478.94 KiB) Viewed 209 times

IMG_0031.JPG
IMG_0031.JPG (478.94 KiB) Viewed 209 times
Attachments
IMG_0033.JPG
IMG_0033.JPG (733.58 KiB) Viewed 209 times

Ehduino
 
Posts: 5
Joined: Sat Jun 05, 2021 2:07 am

Re: Challenges With TCA9548A I2C Multiplexer and SHT75

by adafruit_support_bill on Sat Jun 05, 2021 11:51 am

Your sensor is not an i2c device. Although the Sensiron datasheet says:
The sensor
cannot be addressed by I2C protocol, however, the sensor
can be connected to an I2C bus without interference with
other devices connected to the bus. Microcontroller must
switch between protocols.


But to do that, you would need to connect it to the i2c bus. Your code is saying that it is connected to pins 20 and 21 instead of SDA and SCL.

adafruit_support_bill
 
Posts: 81544
Joined: Sat Feb 07, 2009 10:11 am

Re: Challenges With TCA9548A I2C Multiplexer and SHT75

by Ehduino on Mon Jun 07, 2021 1:18 pm

You are correct, the SHT75 uses a kind of bit-banging that looks like i2c but really isn’t, I have used it on its own I2C line without issues, but it does not play well or at all actually, when other 'devices' or on the same line, hence multiplexing. I was under the understanding that the multiplexed device had no idea it was being multiplexed, to the device it was talking directly with the master as if the multiplexer was invisible, which is why the Arduino I2C pins are used (20,21).

Ehduino
 
Posts: 5
Joined: Sat Jun 05, 2021 2:07 am

Re: Challenges With TCA9548A I2C Multiplexer and SHT75

by adafruit_support_bill on Mon Jun 07, 2021 2:40 pm

I was under the understanding that the multiplexed device had no idea it was being multiplexed . . .

That is correct. The device would be unaware of the multiplexer. It is also unaware of which pins it is connected to
. . . to the device it was talking directly with the master as if the multiplexer was invisible, which is why the Arduino I2C pins are used (20,21).

But the device is not connected to pins 20,21. It is connected via the multiplexer to SDA and SCL (pins 2 and 3 on the 32u4 processor you are using). It is the driver's responsibility to send signal via the pins that the device is connected to. Since you are sending signals on pins 20 and 21, the device will never see them.

adafruit_support_bill
 
Posts: 81544
Joined: Sat Feb 07, 2009 10:11 am

Re: Challenges With TCA9548A I2C Multiplexer and SHT75

by Ehduino on Mon Jun 07, 2021 3:12 pm

"But the device is not connected to pins 20,21. It is connected via the multiplexer to SDA and SCL (pins 2 and 3 on the 32u4 processor you are using).", Ouch, that was an amateur mistake I made! I copy/pasted from the main project using a mega, I'll look to see if that changes anything.

Ehduino
 
Posts: 5
Joined: Sat Jun 05, 2021 2:07 am

Re: Challenges With TCA9548A I2C Multiplexer and SHT75

by Ehduino on Fri Jun 11, 2021 5:49 pm

Just to update and close this post, after much research it appears the use of bit banging to get the SHT75 to work over an I2C connection makes using a multiplexer difficult, there seems to be some old posts online that describe progress by using a common clock line or something to that effect. I happened to have an Adafruit AM2315 for another project and although grumpy it is working fine for this project. I have heard the SHT75 replacement, the SHT85 is much more 'I2C friendly', it is a shame I will likely have to turf the SHT75s unless I can find projects that need humidity and temp, but nothing else... As to the AM2315, some advice, when reading data from it read it twice with a <2 second delay between readings, if you do this it is smooth sailing. Also when scanning for it over the I2C line, don't be surprised if it disappears after the first couple scans, like I said, it is grumpy and you have to bug it...
Thanks a lot for your help adafruit_support_bill, you were fast to reply and helped!

Ehduino
 
Posts: 5
Joined: Sat Jun 05, 2021 2:07 am

Re: Challenges With TCA9548A I2C Multiplexer and SHT75

by adafruit_support_bill on Fri Jun 11, 2021 6:14 pm

Good to hear you've got it working. Thanks for the follow-up. It's always a challenge when dealing with not-quite standard protocols.

adafruit_support_bill
 
Posts: 81544
Joined: Sat Feb 07, 2009 10:11 am

Please be positive and constructive with your questions and comments.