VL53LOX Distance Measurement

tmpAE48The VL53LOX usually comes as a tiny board complete with regulator and is an I2c device capable of measuring short distances.  I thought I’d put it to the test.

The proper description which sounds very impressive is “Time of Flight (ToF) Laser ranging Sensor” – really?   Well, let’s see what it can do. AliExpress sell these for around £5.30 ($7.23) with free postage.

Attached to +5v, ground, SDA and SCL on an Arduino UNO (which means I don’t have to worry about pullup pins for I2c and it just happened to be sitting on my desk at the time) you could start by grabbing the Adafruit library and adding that to an Arduino setup. Read on…

Simply plug the device in –  well, no, firstly solder the lead on – making sure the lead pins are on the side of the regulator – NOT the chip itself – so in the photo above, the leads want to come out of the BACK.

Plug it in – load up the software and monitor on your serial connection. Really it is that simple.

Most of the time the board sends back (several times a second) “out of range” – until you put your hand or other item in front of the sensor.

I works – and works reliably. Every tried using ultrasonics in a room to control lights – only to find the lights turn off every time you sit still and concentrate for a while. Well, no movement needed with this chip.

I got my ruler out and used a little white plastic box I had handy as the obstruction.

Up to 50mm away the unit is rubbish (when I say that it knew the item was a few mm away but no-where near accurate)  – but as you get further away, the accuracy is reasonable. At 200mm it was registering 203mm, at 800mm it was starting to lose the plot even with something large than my hand… with something bigger like a wall it seemed to be ok up to 900mm.

So if you want something to detect that you are sitting at your desk – or maybe catch the cats coming through the catflap – this does indeed seem to be a nice little board. Within range I saw no apparent errors of any significance.

The Adafruit example had 100ms gap between readings and so I took that down to 10mm.  Still no errors.

Taking a brief look at the Adafruit library it looks like you can change the address of the unit internally and perform calibration. For my purposes the standard example works just fine.


16 thoughts on “VL53LOX Distance Measurement

  1. Hello
    I want to implement this sensor with codevision Where do I find the library?

    1. No idea what Codevision is and knowing me I probably only took the bits I needed if I used a library at all.

  2. I have seen the blog Antonio referred to before and the consensus from the comments was that trying to detect a clear liquid reliably was difficult. Hence my thought to try and achieve an easily detected floating target. The application I was thinking about was to turn on a pump when a the level in a tank reached a certain level and then to turn it off when the water level dropped to a lower level. I was looking at a difference in levels of up to a 1000 mm.

  3. Regarding sensing clear water I thought about putting a ping pong ball into a tube, say a length of 40mm plastic waste pipe and immersing the tube into the tank. The ping pong ball would float with the liquid level and hopefully the distance sensor would ‘see’ the ball moving up and down indicating the liquid level. I have got one of these sensors but not tried it yet. I don’t know how much spread the beam from the sensor has but Pete’s experiments seem to suggest a larger target is required at longer distances. The tube might help to stabilise humidity and temperature.

    1. Yes, I have an oil tank with a tube on the side – you’re supposed to be able to tell the fuel level by looking at the pipe. Clearly designed by someone who’s never been near an oil tank, once it gets a bit dirty – it is VERY hard to see the fuel line. I was thinking of putting some kind of tiny fluorescent fishing float in there – but you have me thinking now – I wonder if a simple float of any type was to be used and the sensor fitted at the top of the tube – you should be able to get the distance… and if that is the case then calculating the actual fuel in a round tank should be fairly easy.

  4. I made a C library that’s easy to use and allows putting the device in “long range” mode. I found that the measurements are accurate from 35 to 800mm in short range and 35 to 1200mm in long range mode. The library (with license agreement) from STMicro didn’t appeal to me, so I decided to simplify it. I really dislike (aka HATE) when hardware companies try to be clever and hide their I2C devices behind long lists of magic numbers (registers/data) to use their hardware.

  5. Looks v v interesting. I have been using a nanode with a ping)) sensor to measure river levels for the past 5 years or so, but these ultrasonic sensors do not like the humidity on misty mornings and need replacing approx every none months. Also I worry that they might disturb bats that feed along the river. I’m hoping these laser jobbies can be made fully waterproof with some ir transparent plastic (I was going to try clingfilm or that stuff you put over the windows and shrink tight with a hair dryer) . Keep up your fantasticly useful blog Pete, you really hit the right level for amateurs like me (even if we don’t normally comment) we really appreciate idiot proof guides such as you excel at. Many thanks, a lurker.

  6. Thanks Pete,
    Would you know if it could be used to measure the water level if mounted vertically above the water, looking down? i.e. would it measure the actual water level or the bottom of the pot?
    I suppose steam from hot water would confuse it?
    I’m thinking of a homebrewing application…

    1. Hi, I am using one to measure the amount of oil left in the heating supply tank. I haven’t tried it with water but will experiment and report back.

      I have found that it throws odd measurements sometimes – perhaps temperature dependent although the initialisation routine seems to trigger the calibrate function which should take care of that. I just apply some “eyeball averaging”.


      1. If speed does not matter…

        var smoothing=10;


        Or similar. Change smoothing to suit, an sure average is big enough to handle that calc.

Comments are closed.