Adafruit VL53L0X library

I am currently trying to use the Adafruit library for the VL53L0X distance sensors. I currently have four distance sensors and am trying to run the “vl53l0x_multi_extended.ino” example that comes with the library. In what configuration do I need to have my sensors connected for this to work? I am using an arduino mega for this application. I will include the code below. Thanks!

vl53l0x_multi_extended.ino (13.3 KB)

I can’t find anything that shows the wiring, but the sensors are I2C so all of the SDA lines should be connected together and tied to pin 20 on the Mega and all the SCL lines connected together and tied to pin 21 on the Mega. The vl53l0x_multi_extended.ino sketch will set the I2C addresses for the sensors.

    Reset all sensors by setting all of their XSHUT pins low for delay(10), then
   set all XSHUT high to bring out of reset
    Keep sensor #1 awake by keeping XSHUT pin high
    Put all other sensors into shutdown by pulling XSHUT pins low
    Initialize sensor #1 with lox.begin(new_i2c_address) Pick any number but
   0x29 and it must be under 0x7F. Going with 0x30 to 0x3F is probably OK.
    Keep sensor #1 awake, and now bring sensor #2 out of reset by setting its
   XSHUT pin high.
    Initialize sensor #2 with lox.begin(new_i2c_address) Pick any number but
   0x29 and whatever you set the first sensor to

void Initialize_sensors() {
  bool found_any_sensors = false;
  // Set all shutdown pins low to shutdown sensors
  for (int i = 0; i < COUNT_SENSORS; i++)
    digitalWrite(sensors[i].shutdown_pin, LOW);

  for (int i = 0; i < COUNT_SENSORS; i++) {
    // one by one enable sensors and set their ID
    digitalWrite(sensors[i].shutdown_pin, HIGH);
    delay(10); // give time to wake up.
    if (sensors[i].psensor->begin(sensors[i].id, false, sensors[i].pwire,
                                  sensors[i].sensor_config)) {
      found_any_sensors = true;
    } else {
      Serial.print(i, DEC);
      Serial.print(F(": failed to start\n"));
  if (!found_any_sensors) {
    Serial.println("No valid sensors found");
    while (1)

The shutdown pins will also have to be connected - each to a separate I/O pin.

int SV = 500;

void setup() {

void loop() {
  char L ;

  if (SV >= 450) {
      L = "HIGH";
    else {
      L = "LOW";
  delay(1000);        // delay in between reads for stability

Dear frnds,
when i put this code into arduino board, it does not shows any error but showing square box in serial monitor.
I want to show error msg in a project based on integer “SV” value.
Thanks in advance.

Sorry to forgot point..

In future, integer SV will be replaced with VL53L0X read value.

A char does not make a string.

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