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");
}