Espressif esp32-wroom-32 and 4 VL53L0X sensors. CRASHING in seconds!

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

Hi @payton_geigner ,
Welcome to the forum..

never worked with this particular sensor, but quick check leads me to believe you are trying to set an invalid address..
looks like default address is 0x29 and you should be using it as your starting point..
you only need to change 3 of the 4, 1 of them can be 0x29, the last one..

check the following..
connecting-multiple-sensor

good luck.. ~q

I2C addresses below 8 are reserved, can not be used as slave addresses.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.