Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 12:58 28 Oct 2025 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : VL53L0X time-of-fligt distance sensor code

Author Message
ville56
Senior Member

Joined: 08/06/2022
Location: Austria
Posts: 262
Posted: 03:37pm 27 Sep 2025
Copy link to clipboard 
Print this post

For whom it may be of interest ....

I've ported the VL53L0X code from C++ to MMbasic (to my best knowledge, of course). The code is able to handle multiple sensors and is also able to be loaded as library into a PicoMite under MMbasic. The code is tested on a RP2350A and doing fine so far.
In the zip-file there is a file for
- the library code (can also be included 1:1 in the main code if needed)
- a main program to test it (uses a LCD display)
- a .txt file with some documentation

Comments are welcome, there is certainly much room for improvement   and I apologise for my programming style already upfront. It' not very elegant, but it seems to work.

VL53L0X.zip

maybe someone can use it ...

Regards,
Gerald
                                                                 
73 de OE1HGA, Gerald
 
stanleyella

Guru

Joined: 25/06/2022
Location: United Kingdom
Posts: 2667
Posted: 05:29pm 27 Sep 2025
Copy link to clipboard 
Print this post

Here's version for ssd1306 oled display.

OPTION EXPLICIT
OPTION DEFAULT NONE
Dim d$
Const i2caddr=&H29
I2C write i2caddr,0,2,&H89,&H1
Font 2
Pause 200
CLS
Do
getdistance
Pause 100
Loop
'
Sub getdistance
I2C write i2caddr,0,2,0,1
I2C write i2caddr,1,1,&H1E
I2C read i2caddr,0,2,d$
text 0,0,(Str$(Str2bin(uint16,d$,BIG),3,0))+" mm "
End Sub
Edited 2025-09-28 03:31 by stanleyella
 
ville56
Senior Member

Joined: 08/06/2022
Location: Austria
Posts: 262
Posted: 06:41pm 27 Sep 2025
Copy link to clipboard 
Print this post

Sure, if you do not want control over the sensor you can use the default settings and get away with this very simple code. This is one of the charming features of the VL53LX0. I'd liked to do some experiments to see what one can do with the little beast ...  
                                                                 
73 de OE1HGA, Gerald
 
stanleyella

Guru

Joined: 25/06/2022
Location: United Kingdom
Posts: 2667
Posted: 07:22pm 27 Sep 2025
Copy link to clipboard 
Print this post

Matherp wrote it converted from GBasic.
The VL53LX0 is accurate to 10 mm up to 1 M, it's more for gesture control but good for object avoiding robots.
https://www.youtube.com/watch?v=s5-5DNa36jk&t=16s
 
ville56
Senior Member

Joined: 08/06/2022
Location: Austria
Posts: 262
Posted: 08:51pm 27 Sep 2025
Copy link to clipboard 
Print this post

  Quote  
https://www.youtube.com/watch?v=s5-5DNa36jk&t=16s


impressive !!!
                                                                 
73 de OE1HGA, Gerald
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 6338
Posted: 09:19pm 27 Sep 2025
Copy link to clipboard 
Print this post

I played with a pair of modules.
https://www.thebackshed.com/forum/ViewTopic.php?TID=16690&PID=217225#217225#217225

The video is no longer available.

Jim
VK7JH
MMedit
 
stanleyella

Guru

Joined: 25/06/2022
Location: United Kingdom
Posts: 2667
Posted: 03:50pm 28 Sep 2025
Copy link to clipboard 
Print this post

it's a small pcb that could be hidden in a walking stick... ultrasonic is okish, use one port on/off quick and it resonates 40khz then make port input
and it gets echo back.
used to use it for object avoid robots, preferred VL53LX0 for particular application.
blind walking stick but surely someone's done that .. commercially?
glad more VL53LX0 code posted  
 
stanleyella

Guru

Joined: 25/06/2022
Location: United Kingdom
Posts: 2667
Posted: 05:11pm 28 Sep 2025
Copy link to clipboard 
Print this post

mmb i2c is underrated.. imho
you can do loads like port expander (for 2 stepper motors), ssd oled and VL53LX0
same time easy. thanks
 
Print this page


To reply to this topic, you need to log in.

The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2025