If you refer with “Timed Ranging” to “Continous Mode Ranging” with a definable delay between range cycles, then yes - both libraries do.
In the Pololu one there is a Continous.ino that shows a back to back ranging and the comment in there suggests to provide the delay in milliseconds if you don’t want max speed back to back ranging.
For the Adafruit library I’m still struggling with getting it up on Build, so I haven’t had chance to test it properly - but since that’s the “full” (as far as can see) API set provided by STM, there is no doubt it’s supported there too.
For the latter question about the ranging profiles, it’s possible with both, but only the Adafruit one has a dedicated API while Pololu has stripped away a lot of the complex APIs (for ease of standard use) and you’d need to set and read registers “manually”.
I have 2 of these sensors coming Monday and I'm wanting and hoping I can use them to trigger their interrupt pin to wake a Photon or Electron when something passes in front of the sensor past a predefined distance.
I'm assuming that is what the "Ranging Interrupt Triggers" do?
You should be able to set a threshold distance and can set the interrupt to either trigger when a reading is closer than that (e.g. intrusion alarm) or when the reading is further away (e.g. lost contact to object).
I must say, I’m getting really fed up with the broken “Contribute Library” feature in Particle Build, but it should already be public on Build (although I can’t see it).
@ScruffR, I think it would be worth it to document some of the things one needs to get in order to port a library to work with Photon/Electron and Build. Obviously the guide/Wiki would be just that and not a sure-fire way of porting a library. I was simply stuck on the initial steps (Arduino.h etc.). One has to know what the Particle build system includes by default, what some header files may be called or what a header file is substituted with in build etc.
There were some threads that dealt with that, but since Libraries 2.0 and IDE 2.0 which will bring some improvements and better compatibility are (over)due, there is not much point to invest extra effort into this “sinking ship”
@shiv, once Libraries 2.0 come out, it will include a lot of built-in Arduino compatibility. However, the hardware-specific libraries will remain the real challenge.
@ScruffR I received 2 of the VL53L0X today and tried to get it working with your code on the Build IDE and the code off your GitHub and flashed via the Particle DEV.
Both ways end up with the Electron flashing a RED SOS pattern right after this line of serial print:
If I unplug the i2c lines I do not get the RED SOS errors, so it seems that when the main loop starts it triggers a crash which triggers the SOS message.
Dealing with this same situation with my class. I have a ton of sensors and a ton of students. I am trying to simplifying how to setup a sensor, the .ino .h .cpp files. Digital and Analog sensors are fairly easy but I2C, uArt and SPI take a bit of coordination of several files.
Here is a list of my RobotShop sensors and I probably have the same number from Seeedstudio
@ScruffR@shiv Using the normal code example the sensor maxes out at 4 feet / 1260 mm.
I copied the Arduino long range example code over to ScruffR’s library port and it works!
In long range mode the sensor will measure up to 6.2 feet away vs. 4 feet with the normal settings which makes a big difference for me.
It’s working great as a trip sensor spanning a 5.5 foot wide hallway with stable output.
I did notice that Christmas lights in the background it will cause random readings to show up using the long range settings so try to keep background lights to a minimum.
/* This example shows how to use continuous mode to take
range measurements with the VL53L0X. It is based on
vl53l0x_ContinuousRanging_Example.c from the VL53L0X API.
The range readings are in units of mm. */
#define _PARTICLE_BUILD_IDE_
#if defined(_PARTICLE_BUILD_IDE_)
# include "VL53L0X/VL53L0X.h"
#else
# include "VL53L0X.h"
#endif
#if !defined(PARTICLE)
# include <Wire.h>
#endif
VL53L0X sensor;
#define LONG_RANGE
// Uncomment ONE of these two lines to get
// - higher speed at the cost of lower accuracy OR
// - higher accuracy at the cost of lower speed
//#define HIGH_SPEED
#define HIGH_ACCURACY
void setup()
{
Serial.begin(9600);
Wire.begin();
sensor.init();
sensor.setTimeout(250);
#if defined LONG_RANGE
// lower the return signal rate limit (default is 0.25 MCPS)
sensor.setSignalRateLimit(0.1);
// increase laser pulse periods (defaults are 14 and 10 PCLKs)
sensor.setVcselPulsePeriod(VL53L0X::VcselPeriodPreRange, 18);
sensor.setVcselPulsePeriod(VL53L0X::VcselPeriodFinalRange, 14);
#endif
#if defined HIGH_SPEED
// reduce timing budget to 20 ms (default is about 33 ms)
sensor.setMeasurementTimingBudget(20000);
#elif defined HIGH_ACCURACY
// increase timing budget to 200 ms
sensor.setMeasurementTimingBudget(200000);
#endif
}
void loop()
{
int distancemm = sensor.readRangeSingleMillimeters();
if (distancemm >= 9000) //Change 9000 to the maximum distance you want to get readings from. Only readings below this number will serial print.
{
// action A
}
else
{
Serial.println(distancemm);
}
}
Now the only thing left to figure out is how to get the interrupt GPIO pin working and how to set the threshold that triggers it.