VL53L0X TOF in high accuracy mode

Hi,

I'm wondering if anyone has been able to put the VL53L0X in high accuracy mode and report back data? After looking through the data sheet I've come up with these lines of code, trying to tweak the example code a bit. For some reason the ToF sensor won't report any data when I add the timing budget line.Any idea why? By the way I am using the adafruit library.

#include "Adafruit_VL53L0X.h"

Adafruit_VL53L0X lox = Adafruit_VL53L0X();

VL53L0X_Dev_t MyDevice;
VL53L0X_Dev_t *pMyDevice = &MyDevice;


void setup() {
  Serial.begin(115200);

  // wait until serial port opens for native USB devices
  while (! Serial) {
    delay(1);
  }
  
  Serial.println("Adafruit VL53L0X test");
  if (!lox.begin()) {
    Serial.println(F("Failed to boot VL53L0X"));
    while(1);
  }

  // power 
  Serial.println(F("VL53L0X API Simple Ranging example\n\n")); 

VL53L0X_SetMeasurementTimingBudgetMicroSeconds(pMyDevice, 200000);

  Serial.println(("Here")); 
}


void loop() {

  VL53L0X_RangingMeasurementData_t measure;
    
  Serial.print("Reading a measurement... ");
  lox.rangingTest(&measure, false); // pass in 'true' to get debug data printout!

  if (measure.RangeStatus != 4) {  // phase failures have incorrect data
    Serial.print("Distance (mm): "); Serial.println(measure.RangeMilliMeter);
  } else {
    Serial.println(" out of range ");
  }
    
  delay(100);
}
VL53L0X_Dev_t MyDevice;
VL53L0X_Dev_t *pMyDevice = &MyDevice;

VL53L0X_SetMeasurementTimingBudgetMicroSeconds(pMyDevice, 200000);

You cannot copy a part of the object data to the main sketch and call arbitrary functions on it. You MyDevice variable never got initialized. These parts are marked private in the library and are not intended to be used. If you want or must use them you have to modify the library and introduce interface methods for them.

Hmm ok, not sure I fully understand. What is the correct way to call this function then?

MicahK:
Hmm ok, not sure I fully understand. What is the correct way to call this function then?

You can only call this function from inside the library. There is no correct way to call it from the sketch.

pylon:
You can only call this function from inside the library. There is no correct way to call it from the sketch.

Ok that makes sense. I couldn't find how the adafruit library wraps this function into their library. Does anyone have details on how to call this function?

Does anyone have details on how to call this function?

How about to call it at the end of the begin() method? Or add a method so you can call it by the public interface?