VL53L0X Time-of-Flight Ranging Sensor


#103

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.


#104

@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.

Your modified library code is in this post if your interested: VL53L0X Time-of-Flight Ranging Sensor


#105

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.


#106

@onehorse Any help is greatly appreciated!

I picked up one of your BQ 100mA Solar Harvesting chips a few weeks ago of Tindie and it’s a nice well-built board :wink:


#107

Thanks, those are great for low power work…


#109

gotta type enter to wake the serial up, i think


#110

@bpr Your Right! I should have read that code better :blush:


#111

What serial prints after the setup when you run the code?

I just get this and nothing else. The GPIO pin does not change state either:


#112

@RWB I do get that initially, but once I wave something in front of the sensor it starts interrupting away


#113

Does it serial print the interrupt or is it just a state change on the GPIO pin?


#114

here’s a small chunk of what I get:

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


#115

Weird, I get nothing but the startup info on 2 different sensors.

I’ve power cycled the sensors but when I try to run the Adafruit library Scruff put on the Build IDE I get the Flashing RED SOS message again :confused:

Do you have anything connected to the GPIO pin or SHDN pin?


#116

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


#117

@Bpr can you paste your exact code just so I can try it.

What firmware are you running?


#118

using 0.6.0 firmware. The code I’m using now is exactly what peekay123 posted above


#119

Weird. Nothing for me after the startup data. Frustrating :smile:


#120

Did you remove the tiny piece of protective film from the sensor?


#121

Yes, I removed the tape when they arrived. The Polou library works just fine. Not sure what the deal is.


#122

@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…


#123

@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.