I2C-Multiplexer wechselt channel nicht

Hi,

ich versuche derzeit verzweifelt zwei identische Sensoren (MLX90621 , Temp-Array sensor) mit der selben I2C-Adresse an einem ATMega644P zu betreiben.
Um das zu ermöglichen verwende ich einen PCA9540B (i2c-multiplexer). Link datenblatt: Datenblatt PCA9540
Das Problem ist, dass der Multiplexer den Channel im Betrieb nicht wechselt und somit zwei mal die selben Messwerte ausgibt.
Verwendete Library: PCA9540BD Lib

Es wird folgender code verwendet:

#include <SPI.h>
#include <Arduino.h>
#include <Wire.h>
#include "MLX90621.h"
#include <PCA9540BD.h>

PCA9540BD multiplexer;
MLX90621 MLX; // create an instance of the Sensor class
uint32_t LastSensorUpdate;
void setup() {
  MLX.initialise (512);
  Serial.begin(9600);
}
void loop() {
  MLX.measure(true); //get new readings from the sensor
  multiplexer.selectChannel(1);
  Serial.println("Channel 1");
  //Serial.print(MLX.getAmbient());
    Serial.print(millis());
  Serial.print("ms");

Serial.print(" |  ");

  for (int y = 3; y < 4; y++) { //go through all the rows

    for (int x = 0; x < 16; x++) { //go through all the columns
      int16_t valueAtXY = MLX.irData[y + x * 4]; // extract the temperature at position x/y
      Serial.print(MLX.getTemperature(y + x * 4));
      Serial.print("  ");
    }
  }
  
  Serial.println("  ");
  multiplexer.selectChannel(0);
  Serial.println("Channel 0");
  MLX.measure(true);
   Serial.print(MLX.getAmbient());
   Serial.print(" |  ");
  for (int y = 3; y < 4; y++) { //go through all the rows

    for (int x = 0; x < 16; x++) { //go through all the columns
      int16_t valueAtXY = MLX.irData[y + x * 4]; // extract the temperature at position x/y
      Serial.print(MLX.getTemperature(y + x * 4));
      Serial.print("  ");
    }
  }
  Serial.println("  ");
  Serial.println("  ");
  
  delay(3000);
}

Hat jemand ne Idee woran das liegen könnte?

Ich hab mal den I2C-Scanner drübe laufen lassen, jeweils mit selectchannel(0) und selectchannel(1): Beide Sensoren werden gesehen. Wenn ich einen von beiden abschalte entfallen beim jeweiligen Channel die I2C-Adressen.

Scanning 1...
I2C device found at address 0x50  !
I2C device found at address 0x51  !
I2C device found at address 0x52  !
I2C device found at address 0x53  !
I2C device found at address 0x54  !
I2C device found at address 0x55  !
I2C device found at address 0x56  !
I2C device found at address 0x57  !
I2C device found at address 0x60  !
I2C device found at address 0x70  ! //Multiplexer!
done

Scanning 2...
I2C device found at address 0x50  !
I2C device found at address 0x51  !
I2C device found at address 0x52  !
I2C device found at address 0x53  !
I2C device found at address 0x54  !
I2C device found at address 0x55  !
I2C device found at address 0x56  !
I2C device found at address 0x57  !
I2C device found at address 0x60  !
I2C device found at address 0x70  ! //Multiplexer!
done

multiplexer.selectChannel(1);
Kommt nicht zur Wirkung.

Du misst beide male über Channel 0.
Also nie über Channel 1

Woran könnte das denn liegen, bzw. wie behebt man das?

Selbst nach diesem klaren Hinweis nicht?

Dann in aller Deutlichkeit:

void loop() 
{
  MLX.measure(true); //get new readings from the sensor
  multiplexer.selectChannel(1);
// ....
  multiplexer.selectChannel(0);
  MLX.measure(true);
// ....
}

Das musst du doch sehen!
Das schreit doch.
Das leuchtet.

Mir fehlen selber die Worte :smiley: Dankeschön für den Hinweis!

Gerne doch...

Die Ursache, des nicht findens: Projektion!