Driver for VL53LOX TOF sensor

Discuss development of drivers for external hardware and components, such as LCD screens, sensors, motor drivers, etc.
Target audience: Users and developers of drivers.
OutoftheBOTS_
Posts: 774
Joined: Mon Nov 20, 2017 10:18 am

Driver for VL53LOX TOF sensor

Post by OutoftheBOTS_ » Wed Nov 28, 2018 12:18 am

I have 1 of these https://www.aliexpress.com/item/GY-530- ... 18341.html and I need a driver to use it. I would normally write my own drivers but the manufactures don't give out any info on how to drive it but rather just supply a C API. I have not been able to get a driver to work. I have tied the XSHUT to Vcc to ensure the sensor is powering up.

In the slim datasheet from ST they state slave address is 0x52 but a i2c.scan() finds it on 0x29, the driver that I tried that I found online uses address 0x29 as well
Last edited by OutoftheBOTS_ on Wed Nov 28, 2018 12:39 am, edited 1 time in total.

User avatar
dhylands
Posts: 3360
Joined: Mon Jan 06, 2014 6:08 pm
Location: Peachland, BC, Canada
Contact:

Re: Driver for VL53LOX TOF sensor

Post by dhylands » Wed Nov 28, 2018 12:37 am

Pololu has a driver for arduino: https://github.com/pololu/vl53l0x-arduino

I also found some python code for the raspberry pi: https://github.com/johnbryanmoore/VL53L0X_rasp_python

and a MicroPython driver here:
https://bitbucket.org/thesheep/micropyt ... ew-default

And another MicroPython one (for Adafruit's CircuitPython): https://github.com/adafruit/Adafruit_Ci ... vl53l0x.py

I haven't used any of the above, just the results of some google searching.

OutoftheBOTS_
Posts: 774
Joined: Mon Nov 20, 2017 10:18 am

Re: Driver for VL53LOX TOF sensor

Post by OutoftheBOTS_ » Wed Nov 28, 2018 1:00 am

Thanks I have done some playing with them but can't make any work.

There r some registers that after power up should have a some values in the datasheet. I have tried reading them and some r correct and some r incorrect
>>> from machine import I2C
>>> I2C_bus = I2C(0, sda=27, scl=26)
>>> I2C_bus.readfrom_mem(0x29, 0xC0, 1)
b'\x00'
>>> I2C_bus.readfrom_mem(0x29, 0xC1, 1)
b'\x00'
>>> I2C_bus.readfrom_mem(0x29, 0xC2, 1)
b'\x10'
>>> I2C_bus.readfrom_mem(0x29, 0x51, 2)
b'\x00\x99'
>>> I2C_bus.readfrom_mem(0x29, 0x61, 2)
b'\x00\x00'

rpr
Posts: 79
Joined: Sat Oct 27, 2018 5:17 pm

Re: Driver for VL53LOX TOF sensor

Post by rpr » Wed Nov 28, 2018 2:02 am

Can you do an I2C_bus.scan()?

That should give you the address.

I don't have the device but from reading the datasheet (https://www.st.com/resource/en/datasheet/vl53l0x.pdf), the device address is

0 1 0 1 0 0 1 followed by R/W bit.

So it is 0x29 << 1 + 1/0 for read/write. Thus, 0x52 for write to and 0x53 for read from.

So using raw I2C for reading try

I2C_bus.readfrom_mem(0x53, 0xC0, 1)

User avatar
devnull
Posts: 452
Joined: Sat Jan 07, 2017 1:52 am
Location: Singapore / Cornwall
Contact:

Re: Driver for VL53LOX TOF sensor

Post by devnull » Wed Nov 28, 2018 2:46 am

@deshipu has created a library for the VL530LX:

https://bitbucket.org/thesheep/micropython-vl53l0x

OutoftheBOTS_
Posts: 774
Joined: Mon Nov 20, 2017 10:18 am

Re: Driver for VL53LOX TOF sensor

Post by OutoftheBOTS_ » Wed Nov 28, 2018 3:30 am

It never worked for me. Maybe I am not using it correctly. Does anyone know the correct usage?

User avatar
devnull
Posts: 452
Joined: Sat Jan 07, 2017 1:52 am
Location: Singapore / Cornwall
Contact:

Re: Driver for VL53LOX TOF sensor

Post by devnull » Wed Nov 28, 2018 3:41 am

The person to ask would be the developer ;-)

OutoftheBOTS_
Posts: 774
Joined: Mon Nov 20, 2017 10:18 am

Re: Driver for VL53LOX TOF sensor

Post by OutoftheBOTS_ » Wed Nov 28, 2018 4:09 am

Ok I think that I might have found the problem. I also had a TCS34725 colour sensor on the same bus and now that I have switched to playing with it I realize it also has the same slave address of 0x29

OutoftheBOTS_
Posts: 774
Joined: Mon Nov 20, 2017 10:18 am

Re: Driver for VL53LOX TOF sensor

Post by OutoftheBOTS_ » Wed Nov 28, 2018 4:18 am

Ok I have now unplugged the colour sensor and the TOF sensor is working.

bjames28
Posts: 4
Joined: Fri May 17, 2019 12:55 pm

Re: Driver for VL53LOX TOF sensor

Post by bjames28 » Mon Sep 16, 2019 4:37 pm

Hi All,

I am trying to use the VL53LOX TOF sensor with mentioned driver (https://bitbucket.org/thesheep/micropyt ... ew-default

ESP8266 with micropython firmware from 05/2019

One issue is that every time I do a i2c.scan() I got different list of I2C addresses, in the list the 0x29 is present always, but sometimes I have 20 or more other items . Could the usage of external pull-up resistors eliminate the issue?

As for the second problem I have no idea, I searched the net, but could not find any solution:
exec(open('./main.py').read(),globals())
[11, 12, 13, 14, 15, 20, 21, 23, 25, 26, 27, 29, 30, 37, 39, 42, 43, 68, 80, 81, 106, 118, 119]
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<string>", line 13, in <module>
File "VL53L0X_T.py", line 34, in __init__
File "VL53L0X_T.py", line 75, in init
File "VL53L0X_T.py", line 64, in _config
File "VL53L0X_T.py", line 49, in _register
File "VL53L0X_T.py", line 44, in _registers
OSError: [Errno 19] ENODEV

and here is the main.py producing the above output:
from machine import I2C, Pin
from VL53L0X_T import VL53L0X

i2c = I2C(-1, scl = Pin(5), sda = Pin(4))

print(i2c.scan())

sensor = VL53L0X(i2c, address = 0x29)
print(sensor.read())

Any help is appreciated !

Post Reply