VL53L0X Time-of-Flight Ranging Sensor


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


@RWB, did you try the code I posted as-is? Did you connect the GPIO pin of the VL53L0X to pin D2 of the Photon. My tests were done by compiling with Build using 0.6.1-rc.1. As @bpr pointed out, you need to move you hand above the sensor to get interrupts.


@peekay123 @bpr My BAD guys :blush:

I didn’t pay attention enough that I know I needed to hook the GPIO pin to the D2 on the Photon.

It’s working perfectly now!

I’m going to keep playing around and see if I can figure out any more of the interrupt puzzle :smile:

Thanks :thumbsup:


@peekay123 I played with your modified library and was not able to figure out how to get the interrupt to work at less than 250mm. It would work to trigger the interrupt between 250-1750mm though.

The sensors are cool but not quite what I was looking for so I’ll keep checking for new libraries for this sensor on the web as time passes.

Panasonic ultra low power PIR sensors https://www.mouser.com/new/panasonic/panasonicpapir/

@bpr @ScruffR @peekay123 I did come across a new ultra low power PIR sensors tonight made by Panasonic that detects motion up to 5 or 12 meters depending on which version you get.

While expensive, these sensors are really nice and compact. They are available in black/white and come in several variants, the lowest power being 1uA, 2uA and 6uA. Also there are long range (12m) and short range (5m).

So these look like a good low power security sensor that can be used to wake up a Photon or Electron and which would allow you to use the VL53L0X sensor in regular mode if you still wanted to measure the distance of something after the PIR sensor wakes up the Photon/Electron. Interesting!


@RWB I do recommend those! I have a gateway board that @hallard that makes available on OSHPARK
that works really well to bridge the two worlds
But I haven’t given up on the damn vl53l0x either, but it’s infuriating!


@bpr I have the RFM95w LORA radio + Atmel 34u2 hooked up to a Photon which is receiving data from the RFM95W/Atmel 34u2 over UART. That gives me a way to send sensor data to a web-connected Photon from up to 1 mile away which is nice.

I’m going to order up some of these Panasonic PIR sensors and see how well they work out :smiley:


I found the panasonic pirs a bit too sensitive (prone to false alarms) when used outside - they trigger when the sun comes up even when I have them under a doorway overhang (and when small cats walk by) - so for a quick “fix” I cannibalized the fresnel lens from an inexpensive Chinese pir and put the panasonic pir behind that which helped considerably but not completely.


Good to know!

What exact model or models are you using? Which ones have you tried?

From my brief testing the VK53K0X will also false alarm from lights or sun in the sensors background so you have to be careful how you deploy that one outside also to avoid false alarms,


Panasonic EKMB1201111.
On the other hand, SimplyTronics has a “Mini pir sensor”, the ST-00082, which is relatively low current 28uA @ 3VDC that works fairly well. But all pir sensors are apparently inherently prone to false alarms except in very controlled settings (indoors better), though I am no expert. Pressure mats, anyone?


I ended up ording 3 different Panasonic versions to test out.

All of them being the more immune 6uA versions.

I picked up these 2.2m meter sensor to see if it’s less prone to false alarms due to its shorter range:


I’ll let you know what I find out after testing them :smiley:


@bpr @peekay123 @ScruffR @shiv

There is a new 2-meter TOF Distance sensor on the market that has a proper Arduino Library with the Sleep and threshold functions built in if anybody is still interested :grin:


The arduino library is here: https://github.com/sparkfunX/Qwiic_Distance-RFD77402


Thanks for the heads up, very interesting. Idle current draw is a smidgen higher. The operating current is lower, but it could be how they measure it. I found the eval board for sale in a couple places, but not the chip by itself.

I am still looking for an alternative to the clunky PIR sensors. The smaller ones shown above from Panasonic are a bit pricey, and still large. Same goes for the AM322 based modules (ST-00082, keyestudio ,etc.).
I am having problems with the VL53 beyond 500mm, the distance goes down if I move it farther. Hopefully the RFD chip works better.
I think I am going to end up cannibalizing a store bought sensor fixture. I need it to work outdoors, below freezing.


You did set the VL53 for long distance reading in such situations?


Digikey has 20k chips in stock now.


@RWB , thanks for the pointer. I confused it with the PCB part number.

@ScruffR , thanks for pointing out the long range setting. I had looked into this and added code for various conditions without success. I used code from Kris Winer examples at https://github.com/kriswiner/VL53L0X in the file VL53L0X_Pololu_Ladybug.ino.
That code showed different settings for long range, high speed or high accuracy.
I then used the example code on the Web IDE and got similar results in either single or continuous mode. I can’t tell for sure, but it seems the sensor.init() function sets up for long range already.

Yesterday I realized that by placing the sensor (a Pololu board) at the head of a long table gives wrong results. If I place the sensor at the edge of the table, then I get the 8190mm I expect. It seems the light is reflecting from the surface of the table and fooling the sensor. This resolves the low measurements as I move the sensor inward from the edge of the table, but the distances are still wrong. Sometimes 100mm off.
I also added code to count the number of timeouts. It counted over 1000 in a couple hours.

So… withing 2 meters and pointing the sensor towards open space (no surface around the sensor board) it could work as a motion/presence sensor. I ignore the accuracy and look for a measurement below 8000mm. It fits my need for a really small motion sensor.
I can’t say it works well as a distance sensor.


The laser beam is in the shape of a cone that expands out wide the further out you get from the sensor. So the cone is hitting and reflecting off the table causing you the issues.

Lights in the background threw off some of my readings so be sure there are no lights in the background of the sensor for best results.


Hi @RWB I want to order the VL53L1X Range sensor for use as a mailbox sensor. In this post you mentioned the mailbox idea with the …OX.
Did you ever get it to work? If so could you share your findings?


I never did get that going.

Instead, I used a Rasberry Pi with MotionEye software to create a network camera that records any motion looking out my front window which is where the mailbox is located.

Check out these projects:



Thanks @RWB.


Has anyone try the VL6180X ?
Download the en.STSW-IMG003
Check the code example vl6180x_range_interrupt.c

Edit: And check this too APDS9960