Hi, I'm using a espressif esp32-wroom-32 and 4 VL53L0X sensors. All the sensors have the same I2C address, so I'm using the XSHUT pins to change the names of the 4 sensors. But, when I run the code I only get the first couple lines, then it crashes. I have tried to rerun the code a bunch of times. When it does run I only get "65535" timeout. Pins 25, 26, 27, 32 are my XSHUT pins on the sensors. Here is my code,
#include <Wire.h>
#include <VL53L0X.h>
VL53L0X sensor;
VL53L0X sensor2;
VL53L0X sensor3;
VL53L0X sensor4;
int a;
int b;
int c;
int d;
void setup() {
pinMode(25, OUTPUT);
pinMode(26, OUTPUT);
pinMode(27, OUTPUT);
pinMode(32, OUTPUT);
digitalWrite(25, LOW);
digitalWrite(26, LOW);
digitalWrite(27, LOW);
digitalWrite(32, LOW);
delay(500);
Wire.begin();
Serial.begin(115200);
digitalWrite(25, HIGH);
delay(150);
Serial.println("00");
sensor.init(true);
Serial.println("01");
sensor.setAddress((uint8_t)01);
delay(100);
digitalWrite(25, LOW);
Serial.println("02");
digitalWrite(26, HIGH);
delay(150);
sensor2.init(true);
Serial.println("03");
sensor2.setAddress((uint8_t)02);
delay(100);
digitalWrite(26, LOW);
Serial.println("04");
digitalWrite(27, HIGH);
delay(150);
sensor3.init(true);
Serial.println("05");
sensor3.setAddress((uint8_t)03);
delay(100);
digitalWrite(27, LOW);
Serial.println("06");
digitalWrite(32, HIGH);
delay(150);
sensor4.init(true);
Serial.println("07");
sensor4.setAddress((uint8_t)04);
delay(100);
digitalWrite(32, LOW);
Serial.println("08");
delay(500);
Serial.println("addresses set");
digitalWrite(25, HIGH);
digitalWrite(26, HIGH);
digitalWrite(27, HIGH);
digitalWrite(32, HIGH);
Serial.println("all on");
sensor.init();
sensor.setTimeout(500);
sensor.startContinuous();
sensor2.init();
sensor2.setTimeout(500);
sensor2.startContinuous();
sensor3.init();
sensor3.setTimeout(500);
sensor3.startContinuous();
sensor4.init();
sensor4.setTimeout(500);
sensor4.startContinuous();
Serial.println("all started");
}
void loop() {
a = sensor.readRangeContinuousMillimeters();
Serial.println(a);
b = sensor2.readRangeContinuousMillimeters();
Serial.println(b);
c = sensor3.readRangeContinuousMillimeters();
Serial.println(c);
d = sensor4.readRangeContinuousMillimeters();
Serial.println(d);
}