I used the less than range threshold and had no trouble getting the interrupt to work. When my hand was > 20 cm from the sensor, all output to the serial monotor would stop. When my hand got closer than 20 cm, the output would resume. Didn’t see any issue with the Pololu library; I think it is as complete as needs to be. The best is to just use the ST API, it is by definition the most complete. But good luck trying to understand it. It uses pointers to pointers and is written in the best spaghetti code fashion with few comments, redundant functions, mystery hex values and all kinds of confusion. Shameful, really, that ST treats its retail customers this way!
OK, I take it back, I used an if/then test in the loop not an interrupt to check for range.
@onehorse We’re trying to get the interrupt working so we can put the Photon or Electron to sleep until the VL53L0X sensor detects enough change to trigger the interrupt.
The If/then coding would work fine if we were keeping the micro awake all the time. Trying to take advantage of the low power consumption of the sensor.
It doesn’t look like you have the interrupt’s working in your code other than for the continuous data method.
@peekay123 Added to your code to get a couple interrupts working but they still need some tweaking and that’s why I sent ya the message so you can try what is working on the Teensy 3 and see if it’s working just the same on those also.
And then my 2nd hope was that maybe the code changes may help you figure more of this out also.
That’s right, I am just using the interrupt for data ready. On the STM32L4 I can put the MCU to sleep until the next interrupt is received so nothing special needs to be done. But I agree, being able to interrupt on threshold would be useful. I’ll take a looka t this if I have some time later. It shouldn’t be too hard since the interrupt config register is pretty transparent.
gnal Rate = 109 mega counts per second
Ambient Rate = 10 mega counts per second
Distance = 1022 mm
data rate = 4.31 Hz
RANGE COMPLETE!
Effective SPAD Return Count = 178.00
Signal Rate = 116 mega counts per second
Ambient Rate = 9 mega counts per second
Distance = 1012 mm
data rate = 20.83 Hz
RANGE COMPLETE!
Effective SPAD Return Count = 178.00
Signal Rate = 111 mega counts per second
Ambient Rate = 10 mega counts per second
Distance = 969 mm
data rate = 5.65 Hz
RANGE COMPLETE!
Effective SPAD Return Count = 178.00
Signal Rate = 107 mega counts per second
Ambient Rate = 10 mega counts per second
Distance = 1019 mm
data rate = 1.53 Hz
RANGE COMPLETE!
Effective SPAD Return Count = 178.00
Signal Rate = 111 mega counts per second
Ambient Rate = 9 mega counts per second
Distance = 1015 mm
data rate = 20.41 Hz
RANGE COMPLETE!
Effective SPAD Return Count = 178.00
Signal Rate = 112 mega counts per second
Ambient Rate = 10 mega counts per second
Distance = 1005 mm
data rate = 7.14 Hz
RANGE COMPLETE!
Effective SPAD Return Count = 178.00
Signal Rate = 123 mega counts per second
Different Threshold and CROSSED values will change where the interrupts start and stop but it’s not clear at all exactly which way
As a matter of fact I do have a 47k pullup (to 2.8v) on the interrupt pin (D2) though it seems to work without. I saw some datasheet that mentioned that but it may have been in a vl6180 datasheet, the led forerunner of the vl53l0x. Are you connecting the ViN on the sensor to the 3.3 on the photon. I only use the 2.8v sensor line for the pullup. I left the SHDN pin floating
@RWB Puzzling for sure. I wish I’d kept better notes because the SOS thing happened to me early on with the Adafruit library, although not for @ScruffR, but I can’t remember whether I was able to eliminate the SOS before the change to the new i2c code or not. You may have already tried reducing the serial speed, different connectors, different usb cable, get rid of the cloud…
@Bpr Yea I remember that a power rest of the sensor was required when switching libraries because one of the libraries was initializing something that needed reset while the other library didn’t.
The Polou library works just fine so the sensor is working as it should.