[SOLVED] library for VL530lox LIDAR sensor

Thu May 18, 2017 2:00 am
I tried to find VL530lox sensor library to work for bluepill board. So far I could not get one. There are few working well with Arduino, but when I tried it gives some error in Wire.write command.
I don’t have enough knowledge in C++ and limited knowledge for C.
Any help or guideline will be appreciated.

Thu May 18, 2017 10:33 am
You will need to provide a lot more information than that. :D For starters….

Which library are you using?

Where did you download it from?

*Exactly* what is/are the error or errors you get?

Do you have a link for the datasheet for the VL530lox module?

Thu May 18, 2017 8:03 pm
google gives a single result
VL53L0X library for Arduino
This is a library for the Arduino IDE that helps interface with ST’s VL53L0X time-of-flight distance sensor. The library makes it simple to configure the sensor and read range data from it via I²C.

https://www.pololu.com/product/2490 @ $13.95
datasheet https://www.pololu.com/file/download/VL … _id=0J1187

that’s not the lidar i expected, mine revolves :lol:

Mon May 22, 2017 3:43 am
found the datasheet, and interestingly it is from ST!
http://www.st.com/en/imaging-and-photon … 53l0x.html
http://www.st.com/content/ccc/resource/ … 279086.pdf
but no, i don’t think it works as a scanning lidar, more as a laser range detector

Sat Jun 03, 2017 9:58 am
I’ve used this sensor on other boards than bluepill (or maple mini). I’m just about to go out for a walk but I’ll take a look at it later!

Fri Aug 04, 2017 7:51 pm
I checked the Adafruit library
and loaded the only one example: it compiles.

I used a core that has some months, 8 April 2017.

Fri Aug 04, 2017 9:32 pm
I have that sensor connected to a maple mini on a breadboard at the moment.

So if I have time I will confirm if the adafruit library works

Note. Adafruit often deliberately wire the config pins on I2C devices to the alternative ( non default ) slave address, which means their library’s only work “out if the box ” on their hardware, because the Chinese made boards tend to use the default address.

In the past I needed to modify their Libs to make them work with some Chinese made modules.

Sat Aug 05, 2017 6:28 am
It happened to me using their BME280 library but then I discovered that the begin function accept an address.
Maybe this library too accept an address as argument in begin.

Sun Aug 06, 2017 12:05 pm
I’ve tried 2 different libraries for the STM VL53L0X.


Both seem to run OK, however both examples have problems which would make the example unusable.

The Adafruit library reports a “Range Status” and the example checks this is != 4

However, when I turned on the debugging in the Adafruit lib, it reports Range Status 2 as “Signal Fail”
And only values with Range Status == 0 are show as “Valid”
Range only seems to be valid when the distance being measure is < 20 cm

This value is much less than ST’s datasheet, which status

It can measure absolute distances up to 2m
http://www.st.com/content/ccc/resource/ … 279086.pdf

I’m pretty sure the problem is in the library config, but its a shame that the library appears to report values when the library is reporting that the range status is “Signal Fail”

The Pololu library gives very similar results to the Adafruit, but the Pololu library had an example of a “single” reading, which has options for long range, and this seems to be the best mode, because the Pololu library reports a range of 8190 if the distance its measuring goes of range.

But ultimately, I’m not that happy with either library.

I thought ST has written their own “driver” for this device, but I can’t find it yet, and looking on ST’s community forum, people didnt seem happy with the lack of documentation on this device

Sun Aug 06, 2017 12:13 pm
Just a quick followup to my last post.

It looks like the Adafruit library contains source code written by ST and published via mbed.

The Polulu library seems to have been written by them from scratch, and contains big blocks of code writing arbitrary values to registers in the VL53lox e.g.

writeReg(0xFF, 0x01);
writeReg(0x00, 0x00);

writeReg(0xFF, 0x00);
writeReg(0x09, 0x00);
writeReg(0x10, 0x00);
writeReg(0x11, 0x00);

writeReg(0x24, 0x01);
writeReg(0x25, 0xFF);
writeReg(0x75, 0x00);

Sun Aug 06, 2017 1:50 pm
[RogerClark – Sun Aug 06, 2017 12:05 pm] –
I thought ST has written their own “driver” for this device, but I can’t find it yet, and looking on ST’s community forum, people didnt seem happy with the lack of documentation on this device

ST software is here
but free registration is required.

I used this sensor with an Arduino and Pololu library only one time. I thought to use this sensor with the cheap robotic car sinche the ultrasonic cheap sensor work worse at 3.3v.

Sun Aug 06, 2017 10:20 pm

Thanks for the link. I am already register with ST ;-) so that won’t be a problem.

I am interested in its uses for a variety things, and for testing I was going to try it in a robotic car.

I also need to port it to use on the Nordic nRF51 series MCU, but that looks more complicated than I imagined, as setting up the myriad of registers takes a lot of code.
I may just port the Pololu version as there is less code to modify, and it seems to run ok, especially in single shot long range mode in their library.

Ideally, I would like to see if I can test at longer ranges, for operation at night !

Mon Aug 14, 2017 9:56 am
I have received a couple of VL530lox and I was going to use them to log my dirt bikes suspension travel, so I looked around for libraries and found only the two liked earlier by Adafruit and Pololu.

The Adafruit compiles and works out of the box, the only problem is that sometimes the sensor will not work without switching cycling the power off/on. A bit frustrating sometimes.

Pololu’s library did not compile without some minor changes but is better in all other aspects IMHO.

Impressed by the VL530lox accuracy and speed.

Mon Aug 14, 2017 10:22 am
I didn’t remember needing to change anything to make the Pololu library work, but perhaps I did.

I agree the Pololu lib seems to work well, and seems to be better than the Adafruit lib.

The Adafruit lib seems to use STM’s files, but the setup of these devices is the hard bit, and Pololu’s setup seems better

I found the single shot mode more useful than the continuous, but I wanted to measure long distances i.e over 1m.

Mon Aug 14, 2017 5:43 pm
[RogerClark – Mon Aug 14, 2017 10:22 am] –
I didn’t remember needing to change anything to make the Pololu library work, but perhaps I did.

I was getting error: call of overloaded ‘write(long unsigned int)’ is ambiguous with writeReg32Bit() I changed it to the following which gets rid of it…not sure if thats the best way :)
// Write a 32-bit register
void VL53L0X::writeReg32Bit(uint8_t reg, uint32_t value)
Wire.write((byte)(value >> 24) & 0xFF); // value highest byte
Wire.write(((byte)value >> 16) & 0xFF);
Wire.write(((byte)value >> 8) & 0xFF);
Wire.write( (byte)value & 0xFF); // value lowest byte
last_status = Wire.endTransmission();

Mon Aug 14, 2017 9:31 pm

yes. I valuely remember that one…

I will see what I did to fix it.

Fri Aug 25, 2017 8:38 am
I think I changed the lib to use uint8_t instead of uint8

Strangely the Wire library uses uint8 as the type for Write() so “uint8” must be defined somewhere, but is not part of the include path for that library

I think this is something that probably needs to be fixed in the core

Leave a Reply

Your email address will not be published. Required fields are marked *