I2C OLED DISPLAY & x2 SCD-41 Sensors

Arduino Nano
TCA9548A I2C Multiplexer
OLED Display .96" 128x64
SCD-41 Sensors (x2)

#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
Adafruit_SSD1306 display(128,64,&Wire,-1);
const int16_t SCD_ADDRESS = 0x62;
const int16_t DISPLAY_ADDRESS = 0x3C;
#define LED_PIN 13
float co2_1, temperature_1, humidity_1;
float co2_2, temperature_2, humidity_2;
uint8_t data[12], counter1,counter2;

void TCA9548A(uint8_t bus){
  Wire.beginTransmission(0x70);
  Wire.write(1 << bus);
  Wire.endTransmission();
}
void setup(){
  Serial.begin(115200);
  Wire.begin();
  delay(1000);
  
  TCA9548A(2);
  Wire.beginTransmission(SCD_ADDRESS);
  Wire.write(0x21);
  Wire.write(0xb1);
  Wire.endTransmission();  

  TCA9548A(3);
  Wire.beginTransmission(SCD_ADDRESS);
  Wire.write(0x21);
  Wire.write(0xb1);
  Wire.endTransmission();  

  TCA9548A(1);
  display.begin(SSD1306_SWITCHCAPVCC,DISPLAY_ADDRESS);
  display.clearDisplay();
  
  pinMode(LED_PIN, OUTPUT);
  delay(5000); 
}
void loop(){
  TCA9548A(2);
  Wire.beginTransmission(SCD_ADDRESS);
  Wire.write(0xec);
  Wire.write(0x05);
  Wire.endTransmission();
  Wire.requestFrom(SCD_ADDRESS, 12);
  counter1 = 0;
  while (Wire.available()){
   data[counter1++] = Wire.read();
  }      
  // floating point conversion according to datasheet
  co2_1 = (float)((uint16_t)data[0] << 8 | data[1]);
  // convert T in degC
  temperature_1 = -45 + 175 * (float)((uint16_t)data[3] << 8 | data[4]) / 65536;
  // convert RH in %
  humidity_1 = 100 * (float)((uint16_t)data[6] << 8 | data[7]) / 65536;

  TCA9548A(3);
  Wire.beginTransmission(SCD_ADDRESS);
  Wire.write(0xec);
  Wire.write(0x05);
  Wire.endTransmission();
  Wire.requestFrom(SCD_ADDRESS, 12);
  counter2 = 0;
  while (Wire.available()) {
    data[counter2++] = Wire.read();
  }      
  // floating point conversion according to datasheet
  co2_2 = (float)((uint16_t)data[0] << 8 | data[1]);
  // convert T in degC
  temperature_2 = -45 + 175 * (float)((uint16_t)data[3] << 8 | data[4]) / 65536;
  // convert RH in %
  humidity_2 = 100 * (float)((uint16_t)data[6] << 8 | data[7]) / 65536;
  
  TCA9548A(1);
  display.clearDisplay();
  display.setTextColor(WHITE);
  display.setTextSize(2);
  display.setCursor(0,0);
  display.print("Grow Room");
  display.setCursor(0,16);
  display.setTextSize(1);
  display.print("T1: ");
  float TempF_1;
  TempF_1 = (temperature_1*1.8)+32;  
  display.print(TempF_1);
  display.println(" F");
  display.print("H1: ");
  display.print(humidity_1);
  display.println(" %");
  display.print("C1: ");
  display.print(co2_1);
  display.println(" ppm");
  display.print("T2: ");
  float TempF_2;
  TempF_2 = (temperature_2*1.8)+32;   
  display.print(TempF_2);
  display.println(" F");
  display.print("H2: ");
  display.print(humidity_2);
  display.println(" %");
  display.print("C2: ");
  display.print(co2_2);
  display.println(" ppm");
  display.display();
  delay(300);
  
  if(co2_1 > 999 || co2_2 > 999){
   digitalWrite(LED_PIN,HIGH);
  }else{
   digitalWrite(LED_PIN,LOW);
  }
}

Now if you can see from the picture? I am getting data repeated. Yes I can get each sensor to display itself by itself. But that's not what I need. I need to be able to display 2. Yes I held (1) in hand and blew in it. The CO2 went up on BOTH. While other was away.
Obviously when you are able to get this point started you can repeat this process (x) amount of times. The data from the sensors are being overwritten. I have changed the HEX variables as you see but did nothing. Without being able to display properly I won't be able to control the relays afterward. When this step is completed it is for a "Mushroom fruiting chamber x2". Which is why I need this to be working as soon as possible! If you live in Wisconsin I will hook you up with some mushrooms for the help! Any and all species. When setup is complete.

growroom

(I uploaded so I don't have to click on the original photo.)

Their proximity... would not the data be exact? Hold one in your hand.

Not sure how a closeup of the "damage" is necessary? But thanks.
Any ideas?

Nope it's code. When I blew on it they BOTH changed(ALL 6 DATA POINTS). And EXACTLY the same #'s sooooo scientifically. It's safe to say that's impossible.

Was one a control (hidden) and one exposed?

Correct YES

Okay... see if you can "force" a value (rather than reading instrument #1, set it to a value) and see if the other follows... then do the same with #2.

[late edit]
Is this a third device? TCA9548A(1); I see you are using that as the OLED.
[/edit]

I am pretty sure that it has to deal with the memory for the data.
Wire.write(0x21);
For example.
But as I said in the second one I changed and same results. Repeating data.
The TCA is the I2C Multiplexer. And the number inside it is the channel.

And you swapped pins... (eliminating the physical and the human to focus on the code)

meaning swap sensors? LOL? Is that a joke? Same results. Yes I have tested each individually when I received them. They work fine. With the standard "Serial print code in examples."

Yes, it's I am a joke.

Did you do an I2C scan and are they different?

Have you ever used a multiplexer before?

Yes... I seem to be in the wrong thread... sorry to ask all the questions I have asked ... et c.

MyScan

There you go.
I guess it's not reading any sensor?
It only found the display and the I2C board.
Weird?

Maybe I need to rephrase my question?

I can get and display 1 sensor to display perfectly not a problem!
It's when connecting 2 or more where you get the problem!
So, using the ( TCA9548A) I2C Multiplexer board you can achieve that.
I did.
But the conflict is the data being written over each other. One takes president over the other. Also I am not sure why they want you to read and get the data (twice once in setup and another in void). But that's how it works? YES I HAVE RULED OUT ALL ERROR! BLEW ON ETC......THE CHANGES ARE EXACT! EVERY TIME! SCIENTIFICALLY IMPOSSIBLE!

I need someone who knows really well about this memory allocation and HEX!
This will help solve my problem........ANYBODY?

For the people wondering?
Here is the picture of just 1 sensor working.

I don't think I2C Scanner will help you because it is going to find the oled and the multiplexer only, which is what you saw.

Try the scanner code posted on the Adafruit tutorial page to see if that can hit your sensors.

Multiplexer I2C Scanner Sketch

Thanks here's the scan.....

MyScan

So it does see them all. Still don't help me much for anything.
As I said I need help with the memory over writing itself with the data.
Thanks.

Edit* Can't reply.

Thanks for the effort. But any other libraries like "Adafruit,Sparkfun" don't work at all!
This was the ONLY way it worked! I would say?.....THEY DON"T SUPPORT WHAT I AM TRYING TODO AT THE MOMENT?...... I can't even get 1 sensor to display using their method. So to attempt to display more than 1 would be asking to smash your head?!
I don't know but this is what I got and what works so far. Got a better source code from "sensirion". Also to answer your question as it may seem in the code? One address is for the register and the other is the memory allocation itself. Why it has (2) Wire .write() methods. I have tried reading over the datasheet for the sensor and no help for multiple devices.

Yes I went through everything here >>> Also where I got sample code and datasheet.
https://sensirion.com/products/catalog/SCD41/

Yes I am calling those in SETUP and VOID. Sensor 1 on channel (2).
I changed them to see what will happen? But nothing. Sorry about posting a test but everything on the first sensor was correct. I did update the code for both though now for nomore confusion. But that's what I had in the begining. So problem remains....

Found I2C 0x0 looks weird. Should only show the 0x62 for the sensor fixed address.

I'm not familiar with this sensor. I assume you are writing commands directly to the sensor registers to avoid using a library? Might want to try it first with the library, instantiating the sensor objects, etc and then work on eliminating the library calls?

Sorry I can't help much more than that.

I looked at the data sheet. You are not calling 0x21b1 or 0xec05 on sensor 2 in your scketch so how does it know when to start and read a measurement? And I don't see a command for 0x4523 or 0xe005 in the datasheet table. ?