Any example using setDistanceThreshold method in VL53L1X library

Hi,

Trying to use the VL53L1X library of yours to trigger an interrupt on pin 2 of Arduion pro mini when an object falls outside between 10cm and 50cm. ```
distanceSensor.setDistanceThreshold(100, 500, 1);


I'm not sure if I had to use ```
attachInterrupt(digitalPinToInterrupt(2), ISR_Interrupt, FALLING);

And should I use the same pin interrupt number used in attachInterrupt to below line also? ```
SFEVL53L1X distanceSensor(Wire, 10, 2);

Have you tried this combination already and have seen no results or are you asking ahead of time?

I have tried and so far failed.

what I’m trying to achieve here is,

to trigger an interrupt though the GPIO1 pin from this sensor to wake the atmega328p from deep sleep.

Can such thing be done with this sensor or your library?

Thanks!

It should be possible to do. Can you try changing the attachInterrupt() from FALLING to CHANGE and see if that changes the behavior?

Okay I managed to get some helpful pointers from ST community forum and was able to make this work.

Only thing I should point here is that if anyone using the Sparkfun library, make sure to set setInterruptPolarityLow(); if your interrupt is on a LOW signal ```
attachInterrupt(0, wakeUp, LOW);


My test example code here[https://drive.google.com/open?id=1zh263 ... 3PSeuloCHi](https://drive.google.com/open?id=1zh263udDmhSKb2FzuhjzCr3PSeuloCHi).

I have the code for this working and would be happy to share.

However, I am running into an issue - the Sparkfun Library is missing a function that is part of the ST API.

https://cdn.sparkfun.com/assets/e/1/8/4 … 1X_API.pdf

In the ST user manual on page 13, these are the parameters to set for range threshold:

Example:

Detectionconfig.DetectionMode = 1

Detectionconfig.Distance.CrossMode = 3

Detectionconfig.IntrNoTarget = 0

Detectionconfig.Distance.High = 1000

Detectionconfig.Distance.Low = 100

Status = VL53L1_SetThresholdConfig(&VL53L1Dev, &detectionConfig );

This function is used to program the device to report ranging only when an object is detected within 10 cm and 1 m (as in this example).

The function VL53L1_GetThresholdConfig() allows the programmed report threshold configuration to be obatined.

There are two items in this configuration that are missing in the SparkFun library : IntrNoTarget and DetectionMode

Without these two, there are a large number of “false” interrupts where the interrupt is raised but there is not a measurement in the designed range.

Any ideas on how we could add this to the library? Has anyone else done this? As is pointed out already, there is not direct access to the device’s registers.

Thanks,

Chip