VL53L0X and ZumoReflectanceArray on a ZumoRobot

Hello,

I have connected a VL53L0X ToF-Sensor to the Zumo-Shield-Board pins V5, GND, SCL, SDA, 11. In combination with a Arduino Leonardo R3 board this ToF-Sensor works fine. But when I include code for the reflectanceSensorArray and as soon the QTRSensors detect the ground, the VL53L0X outputs -1 and Timeout has occured.

General Question:
Do I have to care about the adresses of the registers of the i2c bus? Does the VL53L0X and the ReflectanceSensors are writing into the same registers and therefore produces errors?

Best regards,
David

The code that I’m using for testing the VL53L0X in combination with the ZumoReflectanceArray:

#include <Wire.h>
#include <ZumoShield.h>
#include <VL53L0X.h>

#define QTR_TRESHOLD 1000

ZumoMotors motors;
ZumoReflectanceSensorArray reflectanceSensor(QTR_NO_EMITTER_PIN);
VL53L0X distanceSensor;
unsigned int sensor_values[6];
void setup() {
  Wire.begin();
  pinMode(11, INPUT_PULLUP); //on VL53L0X XSHUT pin

  reflectanceSensor.init();
  distanceSensor.init();
  distanceSensor.setTimeout(2000);
  distanceSensor.setMeasurementTimingBudget(200000);
  
  Serial.begin(9600);

}

void loop() {
  checkDistance();
  motors.setSpeeds(200, 200);
  reflectanceSensor.read(sensor_values);
  if(sensor_values[0] < QTR_TRESHOLD){
    Serial.println("right");
    delay(100);
  }
  else if(sensor_values[5] < QTR_TRESHOLD){
    Serial.println("left");
    delay(100);
  }
  else{
    Serial.println("straight");
    delay(100);
  }
}

void checkDistance(){
  int distance = distanceSensor.readRangeSingleMillimeters();

  Serial.print(distance);
  Serial.print("mm");
  if (distanceSensor.timeoutOccurred()) { Serial.print(" TIMEOUT"); }
  Serial.println();
  //if(distance <= 100 ){
    //maxSpeed = true;
   // motors.setSpeeds(400, 400);
  //}
}

This is what the COM-Monitor displays:

As long as the ReflectanceArray is off:

After I switched the ZumoShield-Board on, the ReflectanceArray is on, too:

Hello, David.

I am sorry you are having trouble getting that time-of-flight sensor working with your Zumo. It sounds like you might be worried about a conflict from multiple I²C devices sharing the same address, but none of our QTR sensors (including those on the Zumo reflectance sensor array) are I²C devices, so I do not suspect that to be an issue.

I suspect this issue to be likely because you are using pin 11 on the Leonardo, which the Zumo connects to one of the outputs of the QTR sensors on the reflectance array. XSHUT on the VL53L0X should not really be necessary for using a single sensor; can you try removing your connection between XSHUT and pin 11? You should also remove the part of your code that pulls up pin 11:

pinMode(11, INPUT_PULLUP); //on VL53L0X XSHUT pin

By the way, if you have not already, can you make sure your LED array is appropriately configured for use with a Leonardo by connecting the blue shorting block between the LEDON and A4 pins? You can learn more about that by reviewing the “Adding a Zumo reflectance sensor array (optional)” section of the Zumo’s user’s guide, which you can find under the Resources tab of the Zumo’s product page.

-Jon

Hello Jon,

thank you very much! After connecting LEDON with A4 and deleting the code line with the pin 11, there occured no errors anymore. I left XSHUT unconnected now, but in the documentation of the VL53L0X is written, that XSHUT should be pulled up, so I have chosen pin 11, in the first place.

Thanks again Jon,
you’ve been a great help!

Best wishes,
-David

I am glad things are working now!

By the way, our VL53L0X carrier pulls XSHUT up to VDD to enable the sensor by default. So, leaving XSHUT unconnected should be fine.

-Jon

Thanks for this information. It is useful