VL53L0x

The official pyboard running MicroPython.
This is the reference design and main target board for MicroPython.
You can buy one at the store.
Target audience: Users with a pyboard.
Post Reply
daemeon
Posts: 10
Joined: Wed May 01, 2019 3:05 pm

VL53L0x

Post by daemeon » Wed May 01, 2019 3:18 pm

This is my first ever question in a forum like this. I need help. I am trying to use the lidar module from
https://bitbucket.org/thesheep/micropyt ... ew-default

I am using a pyboard. I am getting this error message:


Traceback (most recent call last):
File "main.py", line 14, in <module>
File "VL53L0X.py", line 116, in __init__
File "VL53L0X.py", line 167, in init
File "VL53L0X.py", line 152, in _flag
File "VL53L0X.py", line 148, in _register
File "VL53L0X.py", line 139, in _registers
OSError: [Errno 5] EIO

I have run a i2c scan and it returns [41]. Does that mean the address is 0x41? I thought it was supposed to be 0x29? I know basic programming. I don't know what this module is doing. Writing stuff to registers, I guess.

User avatar
Roberthh
Posts: 3667
Joined: Sat May 09, 2015 4:13 pm
Location: Rhineland, Europe

Re: VL53L0x

Post by Roberthh » Wed May 01, 2019 3:24 pm

i2c.scan returns decimal values. 41 decimal is 0x29.hex. So you can use as address either 41 or 0x29.

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

Re: VL53L0x

Post by OutoftheBOTS_ » Wed May 01, 2019 9:22 pm

I have used this driver and it worked fine for me :)

daemeon
Posts: 10
Joined: Wed May 01, 2019 3:05 pm

Re: VL53L0x

Post by daemeon » Wed May 01, 2019 11:48 pm

[quote=Roberthh post_id=36211 time=1556724246 user_id=601]
i2c.scan returns decimal values. 41 decimal is 0x29.hex. So you can use as address either 41 or 0x29.
[/quote]

Thank you for that info.

daemeon
Posts: 10
Joined: Wed May 01, 2019 3:05 pm

Re: VL53L0x

Post by daemeon » Wed May 01, 2019 11:51 pm

[quote=OutoftheBOTS_ post_id=36220 time=1556745726 user_id=3423]
I have used this driver and it worked fine for me :)
[/quote]

On a pyboard 1.1? For something that is supposed to be a hobby, I find this very frustrating. I wish I understood programming more. I am fine with basic loops and stuff, but when they start doing 0xsomething, I don't know, and I don't like to not know. I have a master's degree in physics, so I hope I am capable of understanding this.

daemeon
Posts: 10
Joined: Wed May 01, 2019 3:05 pm

Re: VL53L0x

Post by daemeon » Thu May 02, 2019 1:06 am

[quote=OutoftheBOTS_ post_id=36220 time=1556745726 user_id=3423]
I have used this driver and it worked fine for me :)
[/quote]

Could you just direct me to the code (or send me the code?) I need to understand this.

daemeon
Posts: 10
Joined: Wed May 01, 2019 3:05 pm

Re: VL53L0x

Post by daemeon » Thu May 02, 2019 2:15 am

Oh my god, it's working. Figured it out for myself, apparently. Thanks for almost helping me. Anyone know what course I should take (online since I live in Asia) or book I should read to understand how this driver works?

User avatar
jimmo
Posts: 2754
Joined: Tue Aug 08, 2017 1:57 am
Location: Sydney, Australia
Contact:

Re: VL53L0x

Post by jimmo » Thu May 02, 2019 5:57 am

Glad it's working. This is a much more complicated driver compared to most simpler sensors.

There's a lot of things in between "basic loops and stuff" and "writing a driver". As a physicist you'll understand that in the same way there's a lot to learn between "F = ma" and (say) "Maxwell's equations".

To write a driver like this, the author probably started with a reference driver in C, e.g. likely the one from ST: https://my.st.com/content/my_st_com/en/ ... 1.0.2.html

And the reference manual: https://www.st.com/content/ccc/resource ... 279088.pdf

And the datasheet: https://www.st.com/resource/en/datasheet/vl53l0x.pdf

Ultimately this is an I2C device, so the pattern is pretty similar between them - send commands (like you say writing stuff to registers) and read data back. The trick is knowing what commands a given device expects.

The `0x` notation is hexadecimal.

At least you're doing this in MicroPython -- I can speak from experience that this would be even less fun on any other platform. :)

User avatar
pythoncoder
Posts: 5956
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: VL53L0x

Post by pythoncoder » Thu May 02, 2019 8:13 am

@daemeon I strongly recommend learning Python on a PC using an online course or a book. Then notation like 0x42 or b'\x01' would make sense, along with many other language features which go beyond simple loops. With a good grasp of the language you'll be able to follow other people's code. This forum exists specifically to support MicroPython; a reasonable knowledge of Python is assumed.
Peter Hinch
Index to my micropython libraries.

daemeon
Posts: 10
Joined: Wed May 01, 2019 3:05 pm

Re: VL53L0x

Post by daemeon » Fri May 03, 2019 2:54 am

pythoncoder wrote:
Thu May 02, 2019 8:13 am
@daemeon I strongly recommend learning Python on a PC using an online course or a book. Then notation like 0x42 or b'\x01' would make sense, along with many other language features which go beyond simple loops. With a good grasp of the language you'll be able to follow other people's code. This forum exists specifically to support MicroPython; a reasonable knowledge of Python is assumed.
Yes. I know what hexadecimal is. I just don't know about when and why and how to write to registers. Thank you. I have have studied python on the regular computer and I am coming from an arduino C++ background.

Post Reply