Page 1 of 1

TOF VL53L0X

Posted: Fri Dec 03, 2021 12:21 am
by soggycashew
Hello, I wanted to play around with the TOF sensor so I bought THIS ONE. I connected the power to 3v3, ground, SCL and SDA and ran the code below. I get an error:

Traceback (most recent call last):
File "<stdin>", line 17, in <module>
OSError: [Errno 5] EIO

which line 17 is i2c.readfrom_mem_into(addr, 0, data).

Code: Select all

from machine import Pin, I2C

i2c = I2C(0, sda=machine.Pin(0), scl=machine.Pin(1), freq=100000)

addr = i2c.scan()[0]
data = bytearray(2)

while True:
    i2c.readfrom_mem_into(addr, 0, data)
    distance = data[0] << 8 | data[1]
    print(distance)
Thoughts?

Re: TOF VL53L0X

Posted: Fri Dec 03, 2021 3:02 am
by scruss
soggycashew wrote:
Fri Dec 03, 2021 12:21 am
Thoughts?
I think you need a library: either uceeatz/VL53L0X: Micropython Library for Lidar Sensor VL53L0X or mcauser/deshipu-micropython-vl53l0x.

(another plug for Awesome MicroPython)

Re: TOF VL53L0X

Posted: Fri Dec 03, 2021 8:00 am
by soggycashew
I got it working with Kevin McAleers github files and his YouTube tutorial on the VL5310X

https://github.com/kevinmcaleer/vl53l0x

Re: TOF VL53L0X

Posted: Fri Dec 03, 2021 2:31 pm
by soggycashew
It works as in gives readings but they are not very accurate. Any other librarys out there?