Closed Hs-Cheng closed 2 years ago
Hello @Hs-Cheng , the XSHUT pin is fundamental if you use multiple sensors because it avoids conflicts on the I2C bus. When you power the sensors, all of these sensors have the same I2C address (0x52), so if they are connected to the same I2C bus you get an hardware conflict. To avoid it, you must disable all the sensors at the beginning (putting all the XSHUT pins to LOW). Then, you can initialize the sensors one by one as you correctly did in your sketch. If you are using just one sensor, you cannot leave the XSHUT pin floating but at least connected to a Pull-Up resistor to keep the sensor active. Yes, you can use random numbers, the important thing is that they are not contiguous. [0x12, 0x28] are fine. Anyway, your sketch seems fine to me. Doesn't it work? Did you connect correctly all the pins? Best Regards, Carlo
Sorry @Hs-Cheng , now I found an issue in your sketch. You are using the same XSHUT pin on the 2 sensors (pin 17). This is wrong. You must assign a different XSHUT pin to the 2 sensors otherwise you are not able to control them in an independent way. This is because, when you initialize one sensor, the other one must be disable to avoid a conflict on the bus. Please, try for example to assign pin 17 as XSHUT pin for sensor 1 and pin 18 as XSHUT pin for sensor 2. So, you can try something like:
VL53L4CD sensor_vl53l4cd_sat(&DEV_I2C, 17);
VL53L4CD sensor_vl53l4cd_sat2(&DEV_I2C, 18);
Best Regards, Carlo
Hi @cparata ,
Thank you for your reply. I have several follow-up questions (sorry I am not experienced in I2C).
Thank you again for your assistance.
All the best, HC
Hello @Hs-Cheng , you need to turn off all the sensors before starting to call the InitSensor() in cascade. So, as you correctly did in the sketch, you must call begin() and VL53L4CD_Off() for all sensors before and then you can call the InitSensor() one by one. Unfortunately, for VL53L4CD component you can only set the I2C address by software. There is not any mechanism to change it by hardware. Anyway, now is your setup working? Can I close this issue? Best Regards, Carlo
Hi @cparata ,
My setup is working now. Thank you very much for your help. I am going to close this issue.
All the best, HC
@Hs-Cheng I'm currently struggling with getting 2 of the sensors to read together, would it be possible to post your code so I can see how you got it working?
I tried following what you did in the setup to assign the address to the sensors, but I am still only seeing one address, 0x14, when using this in my loop to scan for i2C devices
byte error, address;
int nDevices;
Serial.println("Scanning...");
nDevices = 0;
for(address = 1; address < 127; address++ )
{
// The i2c_scanner uses the return value of
// the Write.endTransmisstion to see if
// a device did acknowledge to the address.
Wire.beginTransmission(address);
error = Wire.endTransmission();
if (error == 0)
{
Serial.print("I2C device found at address 0x");
if (address<16)
Serial.print("0");
Serial.print(address,HEX);
Serial.println(" !");
nDevices++;
}
else if (error==4)
{
Serial.print("Unknown error at address 0x");
if (address<16)
Serial.print("0");
Serial.println(address,HEX);
}
}
if (nDevices == 0)
Serial.println("No I2C devices found\n");
else
Serial.println("done\n");
Resolved the issue by setting the addresses from 0x29 and 0x28 to 0x51 and 0x28.
Hi @nh1628,
I am glad that you solved the problem by modifying the I2C address. Usually the address of each sensor need to be separated by at least 2. Therefore, I guess 0x30 and 0x28 will also work if 0x30 is not occupied by other sensors/ICs.
I wish you all the best with your project. HC
Hi,
My problem is similar to another issue that was closed two weeks ago. I am trying to setup two VL53L4CD sensors together, and I would list my questions below.
I also attached the code of:
Thank you very much for your assistance.
All the best, HC