Voting resources, early voting, and poll worker information - VOTE. ... Adafruit is open and shipping.
0

VL53L0X change ranging profiles
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

VL53L0X change ranging profiles

by andibar on Tue Aug 25, 2020 11:07 am

Hello,

I have installed the Adafruit_VL53L0X Library in the Arduino IDE and the example scetch vl53l0x works fine on ESP8266 D1 Mini. Now in the sketch I want to change the range profile to LONG RANGE.

In the sourcecode I found the function configSensor(VL53L0X_Sense_config_t vl_config).
But if I want to call these function, it doesn't work.
In the setup() after lox.begin() it should be possible to call lox.configSensor(VL53L0X_SENSE_LONG_RANGE). But it doesn't work.
VL53L0X_SENSE_LONG_RANGE is unknown. But if the .h is loaded, the enum VL53L0X_Sense_config_t should be known. It is deklared as public.
I tryed to deklare the variable VL53L0X_Sense_config_t vl_config = VL53L0X_SENSE_LONG_RANGE like in the .h file. But VL53L0X_Sense_config_t does not name a type.

How is it possible to change the mode to LONG RANGE or one of the other modes?
How can I call the config function and use the enum type?

regards,
Andreas

andibar
 
Posts: 3
Joined: Tue Aug 25, 2020 10:21 am

Re: VL53L0X change ranging profiles

by andibar on Wed Aug 26, 2020 6:36 am

Solved...

It's C++ and I have to use the class name. Was my folt.
If you want to change the ranging profile:

create the object global (like in the example):
Adafruit_VL53L0X lox = Adafruit_VL53L0X();

change the profile in the setup():
lox.configSensor(Adafruit_VL53L0X::VL53L0X_SENSE_LONG_RANGE);

regards,
Andreas

andibar
 
Posts: 3
Joined: Tue Aug 25, 2020 10:21 am

Re: VL53L0X change ranging profiles

by mtk59 on Thu Aug 27, 2020 10:56 pm

Hi Andreas,

I am trying to do the exact same thing but am also having issues. I followed your solution but I am getting this error message:

Arduino: 1.8.13 (Windows 10), Board: "Adafruit Feather nRF52832, 0.3.2 SoftDevice s132 6.1.1, Level 0 (Release)"

C:\Users\mkurtz\AppData\Local\Temp\arduino_modified_sketch_335351\vl53l0x.ino: In function 'void setup()':

vl53l0x:21:8: error: 'class Adafruit_VL53L0X' has no member named 'configSensor'

21 | test.configSensor(Adafruit_VL53L0X::VL53L0X_SENSE_LONG_RANGE);

| ^~~~~~~~~~~~

vl53l0x:21:39: error: 'VL53L0X_SENSE_LONG_RANGE' is not a member of 'Adafruit_VL53L0X'

21 | test.configSensor(Adafruit_VL53L0X::VL53L0X_SENSE_LONG_RANGE);

| ^~~~~~~~~~~~~~~~~~~~~~~~

exit status 1

'class Adafruit_VL53L0X' has no member named 'configSensor'


Do you know how to solve this?

mtk59
 
Posts: 4
Joined: Sat Apr 06, 2019 5:10 pm

Re: VL53L0X change ranging profiles

by andibar on Fri Aug 28, 2020 4:48 am

Hello,

it depends on which library do you have installed.
I installed the newest library with library manager (Version 1.1.0).

The code that works for me on ESP8266:
Code: Select all | TOGGLE FULL SIZE
#include "Adafruit_VL53L0X.h"

Adafruit_VL53L0X lox = Adafruit_VL53L0X();
VL53L0X_RangingMeasurementData_t measure;

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

  /*Ranging Profile:
    VL53L0X_SENSE_DEFAULT
    VL53L0X_SENSE_LONG_RANGE
    VL53L0X_SENSE_HIGH_SPEED
    VL53L0X_SENSE_HIGH_ACCURACY
  */
  lox.configSensor(Adafruit_VL53L0X::VL53L0X_SENSE_HIGH_ACCURACY);
 
  // power
  Serial.println(F("VL53L0X API Simple Ranging example\n\n"));
}

void loop() {
 
  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 ");
  }
}


Is from the example sketch.
Could you try this out?

regards,
Andreas

andibar
 
Posts: 3
Joined: Tue Aug 25, 2020 10:21 am

Re: VL53L0X change ranging profiles

by mtk59 on Fri Aug 28, 2020 9:41 am

Ahh I found the problem for me. I also have the latest version 1.1 for me installed but I had an older version lingering around that I was referencing too by accident. Thanks for the help!

mtk59
 
Posts: 4
Joined: Sat Apr 06, 2019 5:10 pm

Please be positive and constructive with your questions and comments.