I2c multiplexer TCA9548A with the LTC4311 over arduino uno

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.
Locked
User avatar
physocean16
 
Posts: 1
Joined: Wed Oct 06, 2021 7:15 pm

I2c multiplexer TCA9548A with the LTC4311 over arduino uno

Post by physocean16 »

I am currently working on troubleshooting why my sht85 sensor values are not printing to the serial port. I am running four sht85 sensors via an arduino Uno which is connected to the TCA9548A multiplexer which is then extended/ boosted using the LTC4311 for each individual sensor. The Arduino Uno utilizes the Hitlego data logging shield with an electronics salon screw terminal attachment. I have verified that I can operate 4 sensors over a short distance and data log. In addition I can operate one sensor with the arduino Uno and LTC4311 over at least 3-4m length (last two images); however, the issue arises when I want to run 4 at once over the 3-4m length (Setup for the 1st image). To operate one sensor I use the standard sht-autodetect code provided by arduino; To operate all four sensors I run the longer code of the two posted.

I have also checked that I am providing the required 3.3V to the sensors as well and tested the connections for all of the components.

My wiring color coordination is as follows:
Ground = Black
Power = Red
SCL = Blue
SDA = Green

Do I need to also boost the TCA9548A? I believe I do not need to boost the multiplexer as it is merely assigning the addresses for the other sensors, but I could be wrong.....

Any suggestions or solutions to this issue would be greatly appreciated. My backup plan is to resort back to the arduino Nano with the a data logging shield which I have tested and was able to get good data for my project; however, trying to synch and operate 30 individual sensors at once is very time consuming.

Code: Select all


# sht85-auto-detect code 
#include <Wire.h>
#include "SHTSensor.h"


SHTSensor sht;
// To use a specific sensor instead of probing the bus use this command:
// SHTSensor sht(SHTSensor::SHT3X);



void setup() {
  // put your setup code here, to run once:

  Wire.begin();
  Serial.begin(115200);
  delay(1000); // let serial console settle

  if (sht.init()) {
      Serial.print("init(): success\n");
  } else {
      Serial.print("init(): failed\n");
  }
  sht.setAccuracy(SHTSensor::SHT_ACCURACY_MEDIUM); // only supported by SHT3x

}

void loop() {
  // put your main code here, to run repeatedly:

  if (sht.readSample()) {
      Serial.print("Temperature:  ");
      Serial.print(sht.getTemperature(), 2);
      Serial.print(' ');
      Serial.print("RH: ");
      Serial.print(sht.getHumidity(), 2);
      Serial.print(' ');
      Serial.println();
  } else {
      Serial.print("Error in readSample()\n");
  }

  delay(1000);
} 

Code: Select all

# this is the code that was written to run four sensors at once. 

#include <Wire.h>
#include "SHTSensor.h"
#include <SPI.h>
#include <SD.h>         // Include SD library
#include <RTClib.h>
//////////////// intiiliaze the 8 sensors in the box///////////////////////////////////
SHTSensor sht0;
SHTSensor sht1; 
SHTSensor sht2;
SHTSensor sht3; 
//SHTSensor sht4;
//SHTSensor sht5;
//SHTSensor sht6; 
//SHTSensor sht7; 
//////////////////////////////////////////////////////////////////////////////
RTC_DS1307 RTC;
File dataFile;
byte busStatus;
const int chipSelect = 10; // specify the data logging pin onboard the box 
// To use a specific sensor instead of probing the bus use this command:
// SHTSensor sht(SHTSensor::SHT3X);
#define TCAADDR 0x70
void tcaselect(uint8_t i) {
  if (i > 7) return; 
  Wire.beginTransmission(TCAADDR);
  Wire.write(1 << i);
  Wire.endTransmission();  
}
void setup() {
  // put your setup code here, to run once:
  while (!Serial);
    delay(1000);
    Wire.begin();
    Serial.begin(9600);
RTC.begin(); 
  RTC.adjust(DateTime((__DATE__), (__TIME__)));    //sets the RTC to the computer time when the sketch is loaded
   while (!Serial){
}
///////////// Initiliaze the sht85 sensors////////////////////////////////////////////
    tcaselect(0);
 if (sht0.init()) {
      Serial.print("init(): success\n");
  } else {
      Serial.print("init(): failed\n");
  }
      tcaselect(1);
 if (sht1.init()) {
      Serial.print("init(): success\n");
  } else {
      Serial.print("init(): failed\n");
  }
   tcaselect(2);
 if (sht2.init()) {
      Serial.print("init(): success\n");
  } else {
      Serial.print("init(): failed\n");
  }
     tcaselect(3);
 if (sht3.init()) {
      Serial.print("init(): success\n");
  } else {
      Serial.print("init(): failed\n");
  }
//    tcaselect(4);
// if (sht4.init()) {
//      Serial.print("init(): success\n");
//  } else {
//      Serial.print("init(): failed\n");
//  }
//      tcaselect(5);
// if (sht5.init()) {
//      Serial.print("init(): success\n");
//  } else {
//      Serial.print("init(): failed\n");
//  }
//   tcaselect(6);
// if (sht6.init()) {
//      Serial.print("init(): success\n");
//  } else {
//      Serial.print("init(): failed\n");
//  }
//     tcaselect(7);
// if (sht7.init()) {
//      Serial.print("init(): success\n");
//  } else {
//      Serial.print("init(): failed\n");
//  }
  //////////// Initiliazing the SD card and the RTC for time stamping samples/////////////////////////////////////
   Serial.print("Initializing SD card...");
  if (!SD.begin(chipSelect)) {
    Serial.println("initialization failed!");
    while (1);  
      Serial.println("initialization done.");
  }
  Serial.println("Initializing RTC...");
  if(!RTC.begin()) {
    Serial.println("Couldn't find RTC"); 
 
  }
  if (! RTC.isrunning())   {
        Serial.println("RTC is NOT running!");
           while(1);
                 Serial.println("RTC initialization done.");

  }
}
void loop() {
  DateTime now = DateTime(RTC.now().unixtime()+46);
dataFile = SD.open("sensor1.txt", FILE_WRITE);
if(dataFile) {
  // put your main code here, to run repeatedly:
    tcaselect(0);
  if (sht0.readSample()) {
      Serial.print("Temperature1:  ");
      Serial.print(sht0.getTemperature(), 2);
      Serial.print(' ');
      Serial.print("RH1: ");
      Serial.print(sht0.getHumidity(), 2);
      Serial.print(' ');
  } else {
      Serial.print("Error in readSample()\n");
  }
    tcaselect(1);
  if (sht1.readSample()) {
      Serial.print("Temperature2:  ");
      Serial.print(sht1.getTemperature(), 2);
      Serial.print(' ');
      Serial.print("RH2: ");
      Serial.print(sht1.getHumidity(), 2);
      Serial.print(' ');
  } else {
      Serial.print("Error in readSample()\n");
  }
      tcaselect(2);
  if (sht2.readSample()) {
      Serial.print("Temperature3:  ");
      Serial.print(sht2.getTemperature(), 2);
      Serial.print(' ');
      Serial.print("RH3: ");
      Serial.print(sht2.getHumidity(), 2);
      Serial.print(' ');
  } else {
      Serial.print("Error in readSample()\n");
  }
  tcaselect(3);
  if (sht3.readSample()) {
      Serial.print("Temperature4:  ");
      Serial.print(sht3.getTemperature(), 2);
      Serial.print(' ');
      Serial.print("RH4: ");
      Serial.print(sht3.getHumidity(), 2);
      Serial.print(' ');
       } else {
      Serial.print("Error in readSample()\n");
  }
//   tcaselect(4);
//  if (sht4.readSample()) {
//      Serial.print("Temperature5:  ");
//      Serial.print(sht4.getTemperature(), 2);
//      Serial.print(' ');
//      Serial.print("RH5: ");
//      Serial.print(sht4.getHumidity(), 2);
//      Serial.print(' ');
//  } else {
//      Serial.print("Error in readSample()\n");
//  }
//    tcaselect(5);
//  if (sht5.readSample()) {
//      Serial.print("Temperature6:  ");
//      Serial.print(sht5.getTemperature(), 2);
//      Serial.print(' ');
//      Serial.print("RH6: ");
//      Serial.print(sht5.getHumidity(), 2);
//      Serial.print(' ');
//  } else {
//      Serial.print("Error in readSample()\n");
//  }
//      tcaselect(6);
//  if (sht6.readSample()) {
//      Serial.print("Temperature7:  ");
//      Serial.print(sht6.getTemperature(), 2);
//      Serial.print(' ');
//      Serial.print("RH7: ");
//      Serial.print(sht6.getHumidity(), 2);
//      Serial.print(' ');
//  } else {
//      Serial.print("Error in readSample()\n");
//  }
//        tcaselect(7);
//  if (sht7.readSample()) {
//      Serial.print("Temperature8:  ");
//      Serial.print(sht7.getTemperature(), 2);
//      Serial.print(' ');
//      Serial.print("RH8: ");
//      Serial.print(sht7.getHumidity(), 2);
//      Serial.print(' ');
//       } else {
//      Serial.print("Error in readSample()\n");
//  }
Serial.print(' ');
Serial.print(now.year(), DEC);
Serial.print('/');
Serial.print(now.month(), DEC);
Serial.print('/');
Serial.print(now.day(), DEC);
Serial.print(' ');
Serial.print(now.hour(), DEC);
Serial.print(':');
Serial.print(now.minute(), DEC);
Serial.print(':');
Serial.print(now.second(), DEC);
Serial.println();
///////////////////// DATA LOGGING TO SD CARD LINES ////////////////////////////
dataFile.print("  RH1: ");
dataFile.print(sht0.getHumidity(), 2);
dataFile.print("");
dataFile.print("  Temperature1:  ");
dataFile.print(sht0.getTemperature(),2); 

dataFile.print("  RH2: ");
dataFile.print(sht1.getHumidity(), 2);
dataFile.print("");
dataFile.print("  Temperature2:  ");
dataFile.print(sht1.getTemperature(),2); 

dataFile.print("  RH3: ");
dataFile.print(sht2.getHumidity(), 2);
dataFile.print("");
dataFile.print("  Temperature3:  ");
dataFile.print(sht2.getTemperature(),2); 

dataFile.print("  RH4: ");
dataFile.print(sht3.getHumidity(), 2);
dataFile.print("");
dataFile.print("  Temperature4:  ");
dataFile.print(sht3.getTemperature(),2); 

//dataFile.print("  RH5: ");
//dataFile.print(sht4.getHumidity(), 2);
//dataFile.print("");
//dataFile.print("  Temperature5:  ");
//dataFile.print(sht4.getTemperature(),2); 
//
//dataFile.print("  RH6: ");
//dataFile.print(sht5.getHumidity(), 2);
//dataFile.print("");
//dataFile.print("  Temperature6:  ");
//dataFile.print(sht5.getTemperature(),2); 
//
//dataFile.print("  RH7: ");
//dataFile.print(sht6.getHumidity(), 2);
//dataFile.print("");
//dataFile.print("  Temperature7:  ");
//dataFile.print(sht6.getTemperature(),2); 
//
//dataFile.print("  RH8: ");
//dataFile.print(sht7.getHumidity(), 2);
//dataFile.print("");
//dataFile.print("  Temperature8:  ");
//dataFile.print(sht7.getTemperature(),2); 
////////////////// BEGIN PRINTING THE RTC TIME STAMPS OF SAMPLES///////////////////////////////////////
dataFile.print(' ');
dataFile.print(now.year(), DEC);
dataFile.print('/');
dataFile.print(now.month(), DEC);
dataFile.print('/');
dataFile.print(now.day(), DEC);
dataFile.print(' ');
dataFile.print(now.hour(), DEC);
dataFile.print(':');
dataFile.print(now.minute(), DEC);
dataFile.print(':');
dataFile.print(now.second(), DEC);
dataFile.println();
dataFile.close();
}
delay(1000);
}
Attachments
3 sensor arduino uno box.jpg
3 sensor arduino uno box.jpg (600.96 KiB) Viewed 433 times
Simplified Uno sensor.jpg
Simplified Uno sensor.jpg (795.63 KiB) Viewed 433 times
simplified Uno booster.jpg
simplified Uno booster.jpg (832.65 KiB) Viewed 433 times

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

Return to “Arduino”