hello, i'm trying to use more AS7265X sensors with a Teensy 4.1. i'm using a TCA9548A as i2c multiplexer because the sensor have the same address. I need to use also a MPU6050 that i prefer to connect separately.
i have connected the MPU6050 to pin 19 and 18(sda scl - WIRE),and the multiplexer to pin 17 and 16(sda1 scl1- WIRE1). in this situation i couldn't start the AS7265X sensor, getting an error during the initialization. The MPU6050 worked correctly.
i tried a lot of configuration to test the sensor and the multiplexer, and i tried to connect the sensor directly to pin 18 and 19 but without result. i'm trying with a simple example but it didn't work.
I would like to specify that the same sensor on the Arduino works perfectly, both with the multiplexer and without. I thought that it could be the Arduino spark libraries not compatible with the Teensy 4.1.
here the code with the multiplexer and the MPU. the libraries of the MPU use Wire and they work:
i receive the error "Sensor does not appear to be connected. Please check wiring. Freezing..", when sensor is initialized
Can anyone give me information?
thank you
i have connected the MPU6050 to pin 19 and 18(sda scl - WIRE),and the multiplexer to pin 17 and 16(sda1 scl1- WIRE1). in this situation i couldn't start the AS7265X sensor, getting an error during the initialization. The MPU6050 worked correctly.
i tried a lot of configuration to test the sensor and the multiplexer, and i tried to connect the sensor directly to pin 18 and 19 but without result. i'm trying with a simple example but it didn't work.
Code:
#include "SparkFun_AS7265X.h"
AS7265X sensor;
#include <Wire.h>
void setup()
{
Serial.begin(115200);
Serial.println("AS7265x Spectral Triad Example");
Wire.begin();
delay (500);
if (sensor.begin() == false)
{
Serial.println("Sensor does not appear to be connected. Please check wiring. Freezing...");
while (1)
;
}
//Once the sensor is started we can increase the I2C speed
Wire.setClock(400000);
sensor.disableIndicator();
Serial.println("A,B,C,D,E,F,G,H,R,I,S,J,T,U,V,W,K,L");
}
void loop()
{
sensor.takeMeasurementsWithBulb(); //This is a hard wait while all 18 channels are measured
Serial.print(sensor.getCalibratedA()); //410nm
//......
Serial.println();
}
here the code with the multiplexer and the MPU. the libraries of the MPU use Wire and they work:
Code:
#include <Wire.h>
#include "SparkFun_AS7265X.h"
#define GYRO_CONFIG_Register 0x1B
#define ACCEL_CONFIG_Register 0x1C
#define ACCEL_XOUT_H_Register 0x3B
#define PWR_MGMT_1_Register 0x6B
uint8_t _i2cAddress = 0x68;
uint8_t receiveBuffer[14];
int nReceived;
int16_t accelX, accelY, accelZ;
int16_t gyroX, gyroY, gyroZ;
int16_t temp;
String header = "distance_s1, distance_s2, $ACC,$GYR,$TMP";
bool open =false;
const int numSens =1;
AS7265X sensors[numSens];
void setup() {
Serial.begin(115200);
// Setup device
SetupMPU6050();
for (int i = 0; i < numSens; i++) {
TCA9548A(i);
//Serial.println();
if (sensors[i].begin() == false) {
Serial.println("Sensor does not appear to be connected. Please check wiring. Freezing...");
while (1)
;
}
setSensorParam(sensors[i], 70, AS7265X_GAIN_16X, AS7265X_MEASUREMENT_MODE_4CHAN_2);
Serial.println("Sensor "); Serial.println(i); + Serial.println(" configured");
}
}
void loop() {
readMPU6050(&accelX, &accelY, &accelZ, &gyroX, &gyroY, &gyroZ, &temp);
// Update the User
//Serial.print("$ACC,\t");
Serial.print(accelX * 2.0f / 32768, 3);
......
delay(100);
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, distance_cm, lux);
}
}
void TCA9548A(uint8_t bus) {
Wire1.beginTransmission(0x70); // TCA9548A address is 0x70
Wire1.write(1 << bus);
Wire1.endTransmission();
}
i receive the error "Sensor does not appear to be connected. Please check wiring. Freezing..", when sensor is initialized
Can anyone give me information?
thank you