AS7265X sensor and I2c Multiplexer

hi, i have a problem with my AS7265X sensor.

i need to use 5 sensors, but they have the same address. so i’ve got a TCA9458a board as I2C multiplexer.

i used to connect 2 sensors to the multiplexer using a NodeMcu without any problem, but recently i tried to use a Teensy 4.1 downloading some arduino libraries.

from that experiment i got in trouble with my sensors, getting an error: Sensor does not appear to be connected. Please check wiring. Freezing…

now i’m trying to connect 5 sensors to the multiplexer but their initialization takes a lot of time, while before the test it needed only few seconds.

i think it can be a problem with Wire library, because i select the channel of multiplexer and then i initialize the sensor, but the begin function returns false.i added also a delay but it does not work

can you help me, please?

before the test i hav enever had problems.

#include "SparkFun_AS7265X.h"

const int numSens = 3;

AS7265X sensors[numSens];
void setup() {

  Serial.begin(115200);
  // Serial.setDebugOutput(true);

  Wire.begin();
  for (int i = 0; i < numSens ; i++) {
    TCA9548A(i);
    delay(50);
    if (sensors[i].begin() == false) {
      Serial.print("Sensor ");
      Serial.print(i);
      Serial.println (" does not appear to be connected. Please check wiring. Freezing...");
      while (1);
    }

    //80 AS7265X_GAIN_1X AS7265X_MEASUREMENT_MODE_6CHAN_ONE_SHOT
    //if(i == 0){
    setSensorParam(sensors[i], 1, AS7265X_GAIN_64X, AS7265X_MEASUREMENT_MODE_4CHAN_2);
    Serial.print("Sensor "); Serial.print(i); + Serial.println(" configured");
  }
}

void loop() {

  for (int i = 0; i < numSens; i++) {
    TCA9548A(i);
    sensors[i].takeMeasurements();  //This is a hard wait while all 18 channels are measured
    printData(sensors[i], i, 0.0, 0.0);
  }
}


void TCA9548A(uint8_t bus) {
  Wire.beginTransmission(0x70);  // TCA9548A address is 0x70
  Wire.write(1 << bus);          // send byte to select bus
  Wire.endTransmission();
  //Serial.println(bus);
}


//80 AS7265X_GAIN_1X AS7265X_MEASUREMENT_MODE_6CHAN_ONE_SHOT
void setSensorParam(AS7265X s, uint8_t integCycle, uint8_t gain, uint8_t measurementMode) {
  s.setIntegrationCycles(integCycle);  //50 * 2.8ms = 140ms. 0 to 255 is valid.
  //If you use Mode 2 or 3 (all the colors) then integration time is double. 140*2 = 280ms between readings.

  s.setGain(gain);  //Set gain to 64x

  s.setMeasurementMode(measurementMode);  //One-shot reading of VBGYOR
  s.disableIndicator();

  Serial.println("A,B,C,D,E,F,G,H,R,I,S,J,T,U,V,W,K,L");
}

Have you disabled all but one set of i2c pull-ups on the bus?

no, i haven’t disabled but i’m using a multiplexer to avoid the problem of the same addresses. the multiplexer has pull up resistors(10 k Ohm)

Disable all others, leave one set active an re-try

I’m guessing this has to do with the need for power shifters between any 5v microcontroller (if that’s what you are using) and the boards. The AS7265x is not out of the box plug and play with the sparkfun connectors if using a 5v proc. This is because both signal and power difs between proc and boards, whether you are using 3.3v pin or not. I don’t know if your splitter board has such power management, but I use the i2c pins native on the board and don’t mess around with that connector at all, it’s super fickle.

I am using BSS138 MOSFET boards with 4 discrete channels and dedicated pull-ups per board, and running both single and power wires through those and my problems (which were many, and always as you describe) have finally vanished.

Let me know if you want a writing diagram or pinout, but it’s super simply:

  1. The power pins (HV and LV) set up the “rules”:

    • HV pin says “this is what 5V means”
    • LV pin says “this is what 3.3V means”
    • The MOSFETs use these as reference points
  2. Then when signals come through:

    • MOSFET knows “convert THIS voltage to THAT voltage”
    • Built-in pullups pull to correct voltage levels
    • Both directions know what levels to use

Without both reference voltages:

  • MOSFETs wouldn’t know what voltage to convert to
  • Pullups wouldn’t have right voltages to pull to
  • No proper reference for “high” and “low”

That’s the basic idea. I really don’t think anyone will be able to get consistently good results using this board and the sparkfun connectors without sacrificing to the electron gods, it’s just not off the shelf ready with a 5v proc.