TOF VL53L0X

RP2040 based microcontroller boards running MicroPython.
Target audience: MicroPython users with an RP2040 boards.
This does not include conventional Linux-based Raspberry Pi boards.
Post Reply
soggycashew
Posts: 55
Joined: Sat Sep 18, 2021 10:21 pm

TOF VL53L0X

Post by soggycashew » Fri Dec 03, 2021 12:21 am

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?

User avatar
scruss
Posts: 360
Joined: Sat Aug 12, 2017 2:27 pm
Location: Toronto, Canada
Contact:

Re: TOF VL53L0X

Post by scruss » Fri Dec 03, 2021 3:02 am

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)

soggycashew
Posts: 55
Joined: Sat Sep 18, 2021 10:21 pm

Re: TOF VL53L0X

Post by soggycashew » Fri Dec 03, 2021 8:00 am

I got it working with Kevin McAleers github files and his YouTube tutorial on the VL5310X

https://github.com/kevinmcaleer/vl53l0x

soggycashew
Posts: 55
Joined: Sat Sep 18, 2021 10:21 pm

Re: TOF VL53L0X

Post by soggycashew » Fri Dec 03, 2021 2:31 pm

It works as in gives readings but they are not very accurate. Any other librarys out there?

Post Reply