VL53L5CX under Micropython
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-03-05 7:18 AM
Hi,
Is there a way to interface VL53L5CX SATEL connected to a STM32F767ZI under micropython ?
Thx
- Labels:
-
Time of flight
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-03-05 7:39 AM
There are a couple of issues here. The first is that the code that talks to the sensor is written in C. And although you could translate that to micropython, I feel it would be much easier to dig into micropython and see if it can call functions written in C. Then it would be easy to integrate.
I did a quick google and came up with:
MicroPython external C modules — MicroPython latest documentation
It sure seems to imply that not only is it possible, it's easy. However, I did NOT read it carefully.
If you do this, keep in mind that the VL53L5 code resolved down to I2C reads and writes in the file called Platform.C
As we don't know which processor you are running on, you have to populate those empty files for your processor.
(See if you can borrow this from GitHub. Lots of projects there.)
I'd say go for it.
And if you get it to go, feel free to brag a bit and put the code on GitHub.
Good luck,
- john
If this or any post solves your issue, please mark them as 'Accept as Solution' It really helps. And if you notice anything wrong do not hesitate to 'Report Inappropriate Content'. Someone will review it.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-03-05 7:45 AM
The VL53L5CX (like any other I2C slave) neither knows nor cares what language you write your code in - all it sees is transactions on the I2C bus.
So you just have to write appropriate code - in any language you like - to do the appropriate transactions on the I2C bus.
https://docs.micropython.org/en/latest/library/machine.I2C.html
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-03-05 8:13 AM
Thank you for your answer
But It seems that VL53LCX does not interface like other I2C sensors but uses an ULD (ultra lite driver).
Is there a driver specific to micropython ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-03-05 8:15 AM
Hello,
Where to find the C code and how to translate it in micropython ?
Why is the VL53L5CX not communicate as usual I2C components ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-03-05 8:17 AM
That's all above the I2C - the VL53LCX is oblivious to that.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-03-05 8:18 AM
Absolutely true! But if L77D uses the ST functions written in C, he is going to have to look in the Platform.c file and implement those functions such as VL53L4CX_WrByte() that access the I2C. These functions are empty in the ST delivery. Doesn't matter how he implements them.
It's my standard warning. I get a lot of calls saying "my I2C doesn't work", and it's because those functions are still empty. I should have put a divide by zero or some error trap in there instead of leaving them empty.
If this or any post solves your issue, please mark them as 'Accept as Solution' It really helps. And if you notice anything wrong do not hesitate to 'Report Inappropriate Content'. Someone will review it.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-03-05 8:30 AM
Sorry but i'm not sure to anderstand both of you
One say to transcript C code to Micropython or interfacing C code with it (where is that code)
One seems to say communication with VL53L5CX is implicit ?
Do not understand the way to follow
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-03-05 8:44 AM
If you want ready-made code, then that code is in C - that's what @John E KVAM said.
Note that you shouldn't need to "transcript" it - you should be able to call it from MicroPython.
What I'm saying is that there's nothing to stop you writing your own code in MicroPython to do the comms (over I2C) from scratch.
@L77d wrote:Do not understand the way to follow
It sounds like you are not experienced with doing this kind of thing from scratch - so probably best to follow what @John E KVAM said.
You could try putting "VL53L5CX MicroPython" into your favourite internet search engine to see if there's any 3rd-party resources or solutions out there ...
